From d740869609da0828f897f6a2a7ae09320b0bbcc7 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 5 Nov 2020 00:53:12 +0100 Subject: [PATCH] Update check and send error with traceback on fail --- administrator/check.py | 10 ---------- extensions/extension.py | 14 +++++++++----- 2 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 administrator/check.py diff --git a/administrator/check.py b/administrator/check.py deleted file mode 100644 index b6d6871..0000000 --- a/administrator/check.py +++ /dev/null @@ -1,10 +0,0 @@ -from discord.ext import commands -from administrator import config - - -class NotOwner(commands.CheckFailure): - pass - - -async def is_owner(ctx: commands.Context): - return ctx.author.id == config.get("admin_id") diff --git a/extensions/extension.py b/extensions/extension.py index 93e6e83..b113e9f 100644 --- a/extensions/extension.py +++ b/extensions/extension.py @@ -1,6 +1,7 @@ +from traceback import format_exc + from discord.ext import commands from discord import Embed -from administrator.check import is_owner from administrator.logger import logger @@ -16,7 +17,7 @@ class Extension(commands.Cog): return "Manage bot's extensions" @commands.group("extension", pass_context=True) - @commands.check(is_owner) + @commands.is_owner() async def extension(self, ctx: commands.Context): if ctx.invoked_subcommand is None: embed = Embed(title="Extensions") @@ -25,33 +26,36 @@ class Extension(commands.Cog): await ctx.send(embed=embed) @extension.group("load", pass_context=True) - @commands.check(is_owner) + @commands.is_owner() async def extension_load(self, ctx: commands.Context, name: str): try: self.bot.load_extension(name) except Exception as e: await ctx.message.add_reaction("\u26a0") + await ctx.send(f"{e.__class__.__name__}: {e}\n```{format_exc()}```") else: await ctx.message.add_reaction("\U0001f44d") @extension.group("unload", pass_context=True) - @commands.check(is_owner) + @commands.is_owner() async def extension_unload(self, ctx: commands.Context, name: str): try: self.bot.unload_extension(name) except Exception as e: await ctx.message.add_reaction("\u26a0") + await ctx.send(f"{e.__class__.__name__}: {e}\n```{format_exc()}```") else: await ctx.message.add_reaction("\U0001f44d") @extension.group("reload", pass_context=True) - @commands.check(is_owner) + @commands.is_owner() async def extension_reload(self, ctx: commands.Context, name: str): try: self.bot.unload_extension(name) self.bot.load_extension(name) except Exception as e: await ctx.message.add_reaction("\u26a0") + await ctx.send(f"{e.__class__.__name__}: {e}\n```{format_exc()}```") else: await ctx.message.add_reaction("\U0001f44d")