From 2923c9c876f37bd8a5e3f2cf5fc337a2a38641f1 Mon Sep 17 00:00:00 2001 From: Phxntxm Date: Sat, 9 Jul 2016 09:39:25 -0500 Subject: [PATCH] Added a load, unload, and reload modules for live use to not need to restart the bot --- cogs/mod.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/cogs/mod.py b/cogs/mod.py index 273aa88..e453fc4 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -21,6 +21,37 @@ class Mod: msg = ' '.join(msg) await self.bot.say(msg) await self.bot.delete_message(ctx.message) + + @commands.command() + @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)) + + @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)) + + @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)) def setup(bot):