diff --git a/cogs/mod.py b/cogs/mod.py index e453fc4..a0bf7c0 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -26,32 +26,44 @@ class Mod: @checks.isAdmin() async def load(self, *, module : str): """Loads a module""" - if not len(module) > 0: - await self.bot.say("Please provide a module!") - return - self.bot.load_extension(module) - await self.bot.say("I have just loaded the {} module".format(module)) + try: + if not len(module) > 0: + await self.bot.say("Please provide a module!") + return + self.bot.load_extension(module) + await self.bot.say("I have just loaded the {} module".format(module)) + except Exception as e: + fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```' + await bot.say(fmt.format(type(e).__name__, e)) @commands.command() @checks.isAdmin() async def unload(self, *, module : str): """Unloads a module""" - if not len(module) > 0: - await self.bot.say("Please provide a module!") - return - self.bot.unload_extension(module) - await self.bot.say("I have just unloaded the {} module".format(module)) + try: + if not len(module) > 0: + await self.bot.say("Please provide a module!") + return + self.bot.unload_extension(module) + await self.bot.say("I have just unloaded the {} module".format(module)) + except Exception as e: + fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```' + await bot.say(fmt.format(type(e).__name__, e)) @commands.command() @checks.isAdmin() async def reload(self, *, module : str): """Reloads a module""" - if not len(module) > 0: - await self.bot.say("Please provide a module!") - return - self.bot.unload_extension(module) - self.bot.load_extension(module) - await self.bot.say("I have just reloaded the {} module".format(module)) + try: + if not len(module) > 0: + await self.bot.say("Please provide a module!") + return + self.bot.unload_extension(module) + self.bot.load_extension(module) + await self.bot.say("I have just reloaded the {} module".format(module)) + except Exception as e: + fmt = 'An error occurred while processing this request: ```py\n{}: {}\n```' + await bot.say(fmt.format(type(e).__name__, e)) def setup(bot):