added logging

This commit is contained in:
phixxy 2024-01-25 02:34:22 -08:00
parent 4f1baaa652
commit 2069fb788d

View file

@ -19,9 +19,11 @@ class Admin(commands.Cog):
async def kill(self, ctx): async def kill(self, ctx):
"Kills the bot" "Kills the bot"
if ctx.author.id in self.admin_ids: if ctx.author.id in self.admin_ids:
self.bot.logger.info(f"Kill command ran by {ctx.author.id}")
exit() exit()
else: else:
await ctx.channel.send("You don't have permission to do that.") await ctx.channel.send("You don't have permission to do that.")
self.bot.logger.info(f"Kill command attempted by {ctx.author.id}")
@commands.command( @commands.command(
description="Reset", description="Reset",
@ -31,10 +33,12 @@ class Admin(commands.Cog):
) )
async def reset(self, ctx): async def reset(self, ctx):
if ctx.author.id in self.admin_ids: if ctx.author.id in self.admin_ids:
self.bot.logger.info(f"Reset command ran by {ctx.author.id}")
python = sys.executable python = sys.executable
os.execl(python, python, *sys.argv) os.execl(python, python, *sys.argv)
else: else:
await ctx.channel.send("You don't have permission to do that.") await ctx.channel.send("You don't have permission to do that.")
self.bot.logger.info(f"Reset command attempted by {ctx.author.id}")
@commands.command( @commands.command(
description="Update", description="Update",
@ -44,6 +48,7 @@ class Admin(commands.Cog):
) )
async def update(self, ctx): async def update(self, ctx):
if ctx.author.id in self.admin_ids: if ctx.author.id in self.admin_ids:
self.bot.logger.info(f"Reset command ran by {ctx.author.id}")
output = subprocess.run(["git","pull"],capture_output=True) output = subprocess.run(["git","pull"],capture_output=True)
if output.stderr: if output.stderr:
await ctx.send("Update Attempted") await ctx.send("Update Attempted")
@ -52,6 +57,11 @@ class Admin(commands.Cog):
await ctx.send(output.stdout.decode('utf-8')) await ctx.send(output.stdout.decode('utf-8'))
else: else:
await ctx.send("You don't have permission to do this.") await ctx.send("You don't have permission to do this.")
self.bot.logger.info(f"Update command attempted by {ctx.author.id}")
async def setup(bot): async def setup(bot):
await bot.add_cog(Admin(bot)) try:
bot.logger.info(f"Successfully added Admin cog")
await bot.add_cog(Admin(bot))
except:
bot.logger.exception(f"Failed to add Admin cog")