📝 Better logging of on_slash_command

Logs the entire command now
This commit is contained in:
NikolajDanger
2021-04-02 23:46:04 +02:00
parent 3a9c2b7e16
commit 8369ab0000
2 changed files with 11 additions and 2 deletions

View File

@ -13,8 +13,7 @@ class EventCog(commands.Cog):
# Logs when user sends a command
@commands.Cog.listener()
async def on_slash_command(self, ctx):
logMessage = f"{ctx.author.display_name} ran /{ctx.name}"
self.bot.log(logMessage, str(ctx.channel_id), level = 25)
await self.bot.eventHandler.on_slash_command(ctx)
# Logs if a command experiences an error
@commands.Cog.listener()

View File

@ -5,6 +5,16 @@ class EventHandler():
def __init__(self, bot):
self.bot = bot
async def on_slash_command(self, ctx):
if ctx.subcommand_name is not None:
subcommand = f" {ctx.subcommand_name} "
else:
subcommand = " "
args = " ".join([str(i) for i in ctx.args])
fullCommand = f"/{ctx.command}{subcommand}{args}"
logMessage = f"{ctx.author.display_name} ran {fullCommand}"
self.bot.log(logMessage, str(ctx.channel_id), level = 25)
async def on_ready(self):
await self.bot.databaseFuncs.syncCommands()
self.bot.log("Logged in as "+self.bot.user.name+", "+str(self.bot.user.id), level = 25)