def load_modules(): module_list = get_module_names() for module in module_list: # my_module = importlib.import_module("modules.%s" % module) # klass = getattr(my_module, module) # bot.add_cog(klass(bot)) bot.load_extension("modules.%s" % module)
async def module(self, ctx, action, name=None, url=None): if ctx.message.author.id == 218444620051251200: if action == "add": download_module(url, name) check = check_module(name) if check == "fine": await ctx.send( "⬇ | Module '%s' has been downloaded successfully and checked. No errors found! Enabling module..." % name) add_module(name) # my_module = importlib.import_module("modules.%s" % name) # klass = getattr(my_module, name) # self.bot.add_cog(klass(self.bot)) self.bot.load_extension('modules.%s' % name) await ctx.send("✅ | Module '%s' has been enabled!" % name) else: await ctx.send( "🚫 | Module '%s' has been downloaded successfully but check failed.\nError: `%s`" % (name, check)) elif action == "remove": if name: self.bot.unload_extension('modules.%s' % name) delete_module_file(name) remove_module(name) # self.bot.remove_cog(name) print("Module '%s' has been disabled." % name) await ctx.send("✅ | Module '%s' has been removed!" % name) else: await ctx.send( "🚫 | Please specify the name of the module you want to remove." ) elif action == "list": await ctx.send(get_module_names()) elif action == "show": if name: await ctx.send( "✅ | Module '%s' has been uploaded successfully! Link: <https://hastebin.com/%s>" % (name, json.loads( requests.post( 'https://hastebin.com/documents', data=open('modules/' + name + '.py').read()).text)['key'])) else: await ctx.send( "🚫 | Please specify the name of the module you want to remove." ) else: await ctx.send( "🚫 | Invalid action. Valid actions are: add, remove, enable, disable, list, show" ) else: await ctx.send( "🚫 | Only my overlord, realmayus is permitted to execute this command." )
def setup(): print(get_module_names()) bot.add_cog(CoreCog(bot)) load_modules() bot.run(get_token())