From 301c806b94509acce79d48c26d750b94e8ffaeb0 Mon Sep 17 00:00:00 2001 From: Florian SYLVAIN Date: Sun, 7 Mar 2021 19:04:12 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20-=20The=20bot=20owner=20can=20now?= =?UTF-8?q?=20load=20and=20unload=20extensions=20with=20$loadext=20{ext}?= =?UTF-8?q?=20and=20$unloadext=20{ext}.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- python/main.py | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/python/main.py b/python/main.py index 6548624..2629a5d 100644 --- a/python/main.py +++ b/python/main.py @@ -12,10 +12,35 @@ async def on_ready(): print('We have logged in as ' + bot.user.name + '.') +@bot.command(hidden=True) +@commands.is_owner() +async def loadext(ctx, extension): + try: + bot.load_extension(extension) + await ctx.send(str(extension) + ' successfully loaded.') + except discord.ext.commands.ExtensionNotFound: + await ctx.send('Extension not found.') + except discord.ext.commands.ExtensionAlreadyLoaded: + await ctx.send('Extension already loaded.') + except discord.ext.commands.NoEntryPointError as a: + await ctx.send(a) + except ExtensionFailed as b: + await ctx.send(b) + + +@bot.command(hidden=True) +@commands.is_owner() +async def unloadext(ctx, extension): + try: + bot.unload_extension(extension) + await ctx.send(str(extension) + ' successfully unloaded.') + except discord.ext.commands.ExtensionNotFound: + await ctx.send('Extension not found.') + except discord.ext.commands.ExtensionNotLoaded: + await ctx.send('Extension not loaded.') + + if __name__ == "__main__": for extension in startup_extensions: - try: - bot.load_extension(extension) - except Exception as e: - print(e) + bot.load_extension(extension) bot.run(TOKEN_BOT)