diff --git a/cogs/utils.py b/cogs/utils.py index bc07220..f39dcc6 100644 --- a/cogs/utils.py +++ b/cogs/utils.py @@ -540,74 +540,6 @@ async def embeds_add_embed_author(self, ctx: ApplicationContext, embed_name: str else: localembed = _embeds.build_embed(ctx.guild.id, embed_name=embed_name) await ctx.respond(f"## :white_check_mark: Footer section successfully added to server embed `{embed_name}\nHere's a preview of your modified embed:`", embed=localembed) - - # Isobot Command Registry Management System - commandmanager = SlashCommandGroup("commandmanager", "Manage isobot's command registry.") - - @commandmanager.command( - name="list_all_commands", - description="Lists all of isobot's commands." - ) - async def list_all_commands(self, ctx: ApplicationContext): - if ctx.author.id != 738290097170153472: - return await ctx.respond("You can't use this command!", ephemeral=True) - all_cmds = _commands.list_commands() - parsed_output = str() - for cmd in all_cmds: - parsed_output += f"\n`{cmd}`" - await ctx.respond(parsed_output) - - @commandmanager.command( - name="switch_flag", - description="Switches a flag for a specific command." - ) - @option(name="command", description="The command entry that you want to manipulate", type=str) - @option(name="flag", description="The flag that you want to enable", type=str, choices=["disabled", "bugged"]) - @option(name="status", description="Choose whether you want the flag to be True or False.", type=bool) - async def switch_flag(self, ctx: ApplicationContext, command: str, flag: str, status: bool): - if ctx.author.id != 738290097170153472: - return await ctx.respond("You can't use this command!", ephemeral=True) - if flag == "disabled": _commands.command_disabled_flag(command, status) - elif flag == "bugged": _commands.command_bugged_flag(command, status) - await ctx.respond(f":white_check_mark: Flag edited successfully for `/{command}`.") - - @commandmanager.command( - name="remove", - description="Removes a command permanently from the command registry." - ) - @option(name="command", description="The command that you want to remove.", type=str) - async def _remove(self, ctx: ApplicationContext, command: str): - if ctx.author.id != 738290097170153472: - return await ctx.respond("You can't use this command!", ephemeral=True) - _commands.remove_command(command) - await ctx.respond(f":white_check_mark: Command `/{command}` successfully removed from database.") - - @commandmanager.command( - name="add", - description="Add new command to the command registry." - ) - @option(name="command_name", description="What is the actual command name?", type=str) - @option(name="stylized_name", description="Enter a good-looking version of the command name.", type=str) - @option(name="description", description="Enter a description for this command.", type=str) - @option(name="command_type", description="What category does this command belong to?", type=str) - @option(name="usable_by", description="Who can use this command?", type=str) - @option(name="cooldown", description="How many seconds is the command cooldown for?", type=int, default=None) - async def _add(self, ctx: ApplicationContext, command_name: str, stylized_name: str, description: str, command_type: str, usable_by: str, cooldown: int = None): - if ctx.author.id != 738290097170153472: - return await ctx.respond("You can't use this command!", ephemeral=True) - _commands.add_command( - command_name, - stylized_name, - description, - command_type, - usable_by, - cooldown=cooldown - ) - localembed = discord.Embed(title=":white_check_mark: New Command Successfully Added!", description=f"`/{command_name}\n\n{description}`", color=discord.Color.green()) - localembed.add_field(name="Command Type", value=command_type) - localembed.add_field(name="Usable By", value=usable_by) - localembed.add_field(name="Cooldown", value=cooldown) - await ctx.respond(embed=localembed) # User Commands @commands.user_command(name="Show User Information") diff --git a/framework/isobot/commands.py b/framework/isobot/commands.py index 77a2a9c..7e365d7 100644 --- a/framework/isobot/commands.py +++ b/framework/isobot/commands.py @@ -17,11 +17,6 @@ def load(self) -> dict: with open(f"{client_data_dir}/config/commands.json", 'r', encoding="utf-8") as f: data = json.load(f) return data - def save(self, data: dict) -> int: - """Saves the cached database to local machine storage.""" - with open(f"{client_data_dir}/config/commands.json", 'w+', encoding="utf-8") as f: json.dump(data, f) - return 0 - def fetch_raw(self) -> dict: """Returns the commands database in a raw `json` format.""" return self.load() @@ -30,40 +25,3 @@ def list_commands(self) -> list: """Returns all the added commands as a `list`.""" cmds = self.load() return cmds.keys() - - def command_disabled_flag(self, command: str, status: bool): - """Enables or disables the `disabled` flag for a command.""" - cmds = self.load() - cmds[command]["disabled"] = bool - self.save(cmds) - return 0 - - def command_bugged_flag(self, command: str, status: bool): - """Enables or disables the `bugged` flag for a command.""" - cmds = self.load() - cmds[command]["bugged"] = bool - self.save(cmds) - return 0 - - def add_command(self, command_name: str, stylized_name: str, description: str, command_type: str, usable_by: str, *, cooldown: int = None): - """Adds a new command entry into the command registry.""" - cmds = self.load() - cmds[command_name] = { - "name": stylized_name, - "description": description, - "type": command_type, - "cooldown": cooldown, - "args": None, - "usable_by": usable_by, - "disabled": False, - "bugged": False - } - self.save(cmds) - return 0 - - def remove_command(self, command): - """Removes a command permanently from the command registry.""" - cmds = self.load() - del cmds[command] - self.save(cmds) - return 0