added error logging

This commit is contained in:
phixxy 2024-11-05 17:36:14 -08:00
parent ddca750093
commit 487d91ba2e

View file

@ -29,6 +29,7 @@ class MessageXP(BotBaseCog):
@commands.Cog.listener() @commands.Cog.listener()
async def on_message(self, message: discord.Message): async def on_message(self, message: discord.Message):
try:
author_id = message.author.id author_id = message.author.id
if author_id == self.bot_id: if author_id == self.bot_id:
return return
@ -47,6 +48,8 @@ class MessageXP(BotBaseCog):
with open(os.path.join(self.data_dir, "xp.json"), "w") as xp_file: with open(os.path.join(self.data_dir, "xp.json"), "w") as xp_file:
json.dump(xp_data, xp_file) json.dump(xp_data, xp_file)
except Exception as e:
self.logger.error(f"Error adding XP: {e}")
def create_xp_file(self): def create_xp_file(self):
with open(self.data_dir + "xp.json", "w") as xp_file: with open(self.data_dir + "xp.json", "w") as xp_file: