🐛 Added some more logging for bug fixing
This commit is contained in:
@ -5,17 +5,22 @@ class EventCog(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
# Sets the game and logs when the bot logs in
|
||||
# Syncs commands, sets the game, and logs when the bot logs in
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
self.bot.log("Logged in as "+self.bot.user.name+", "+str(self.bot.user.id), level = 20)
|
||||
await self.bot.databaseFuncs.syncCommands()
|
||||
self.bot.log("Logged in as "+self.bot.user.name+", "+str(self.bot.user.id), level = 25)
|
||||
game = discord.Game("Use /help for commands")
|
||||
await self.bot.change_presence(activity=game)
|
||||
await self.bot.change_presence(activity=game, status = discord.Status.online)
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_disconnect(self):
|
||||
await self.bot.change_presence(status = discord.Status.offline)
|
||||
|
||||
# Logs when user sends a command
|
||||
@commands.Cog.listener()
|
||||
async def on_slash_command(self, ctx):
|
||||
self.bot.log(f"{ctx.author.display_name} ran /{ctx.name}", str(ctx.channel_id), level = 20)
|
||||
self.bot.log(f"{ctx.author.display_name} ran /{ctx.name}", str(ctx.channel_id), level = 25)
|
||||
|
||||
# Logs if a command experiences an error
|
||||
@commands.Cog.listener()
|
||||
@ -36,5 +41,17 @@ class EventCog(commands.Cog):
|
||||
self.bot.log([f"exception in /{ctx.name}", f"{exceptionString}"],str(ctx.channel_id), 40)
|
||||
await ctx.send("Something went wrong (error code 000)")
|
||||
|
||||
# Logs if an error occurs
|
||||
@commands.Cog.listener()
|
||||
async def on_error(self, method):
|
||||
exception = traceback.format_exc()
|
||||
stopAt = "\nThe above exception was the direct cause of the following exception:\n\n"
|
||||
if stopAt in exception:
|
||||
index = exception.index(stopAt)
|
||||
exception = exception[:index]
|
||||
|
||||
exceptionString = "".join(exception)
|
||||
self.bot.log([f"exception in /{method}", f"{exceptionString}"], level = 40)
|
||||
|
||||
def setup(bot):
|
||||
bot.add_cog(EventCog(bot))
|
||||
|
Reference in New Issue
Block a user