Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @bot_modules.bot_command("modules", "Allows the server admins to toggle modules like dice or poll", ["list", "<activate|deactivate> <module name>"], admin=True)
- async def modules_command(ctx: bot_modules.CommandContext):
- try:
- commands = []
- for i in bot_modules.commands.values():
- commands.append(i.cmd)
- commands.remove("eval")
- commands.remove("modules")
- if ctx.args[1] == "activate":
- if len(ctx.args) < 3:
- await ctx.fail(title="Error", description="You need to specify wich module to activate!\nFor a list of modules, use **{}modules list**!".format(ctx.prefix))
- else:
- settings = config.load_settings(ctx.discord.message.guild.id)
- if ctx.args[2] in commands:
- if ctx.args[2] in settings["disabled_plugins"]:
- settings["disabled_plugins"].remove(ctx.args[2])
- config.change_settings(ctx.discord.message.guild.id, settings)
- await ctx.succeed(title="Activated", description="The module **{}** has been activated!".format(ctx.args[2]))
- else:
- await ctx.fail(title="Error", description="**{}** is already active".format(ctx.args[2]))
- else:
- await ctx.fail(title="Error", description="**{}** is not a module or is not changeable, like modules itself or eval".format(ctx.args[2]))
- elif ctx.args[1] == "deactivate":
- if len(ctx.args) < 3:
- await ctx.fail(title="Error", description="You need to specify wich module to deactivate!\nFor a list of modules, use **{}modules list**!".format(ctx.prefix))
- else:
- settings = config.load_settings(ctx.discord.message.guild.id)
- if ctx.args[2] in commands:
- if ctx.args[2] in settings["disabled_plugins"]:
- await ctx.fail(title="Error", description="**{}** is already deactivated".format(ctx.args[2]))
- else:
- settings["disabled_plugins"].append(ctx.args[2])
- config.change_settings(ctx.discord.message.guild.id, settings)
- await ctx.succeed(title="Activated", description="The module **{}** has been deactivated!".format(ctx.args[2]))
- else:
- await ctx.fail(title="Error", description="**{}** is not a module or is not changeable, like modules itself or eval".format(ctx.args[2]))
- elif ctx.args[1] == "list":
- settings = config.load_settings(ctx.discord.message.guild.id)
- _list = ""
- for i in commands:
- if i in settings["disabled_plugins"]:
- _list += ":x: " + i + "\n"
- else:
- _list += ":white_check_mark: " + i + "\n"
- await ctx.succeed(title="List of all commands:", description=_list)
- else:
- await ctx.fail(title="Error", description="**{}** is not an available option, use **{}help modules** to see how to use.".format(ctx.args[1], ctx.prefix))
- except IndexError:
- await ctx.fail(title="Error", description="You need to specify what to do,\nuse **{}help modules** to see how to use.".format(ctx.prefix))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement