diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index 1657f219e..bdbaf2f08 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -35,6 +35,8 @@ from redbot.core import ( from .utils.predicates import MessagePredicate from .utils.chat_formatting import humanize_timedelta, pagify, box, inline +from .commands.requires import PrivilegeLevel + if TYPE_CHECKING: from redbot.core.bot import Red @@ -1912,6 +1914,12 @@ class Core(commands.Cog, CoreLogic): ) return + if self.command_manager in command_obj.parents or self.command_manager == command_obj: + await ctx.send( + _("The command to disable cannot be `command` or any of its subcommands.") + ) + return + async with ctx.bot.db.disabled_commands() as disabled_commands: if command not in disabled_commands: disabled_commands.append(command_obj.qualified_name) @@ -1934,6 +1942,16 @@ class Core(commands.Cog, CoreLogic): ) return + if self.command_manager in command_obj.parents or self.command_manager == command_obj: + await ctx.send( + _("The command to disable cannot be `command` or any of its subcommands.") + ) + return + + if command_obj.requires.privilege_level > await PrivilegeLevel.from_ctx(ctx): + await ctx.send(_("You are not allowed to disable that command.")) + return + async with ctx.bot.db.guild(ctx.guild).disabled_commands() as disabled_commands: if command not in disabled_commands: disabled_commands.append(command_obj.qualified_name) @@ -1990,6 +2008,10 @@ class Core(commands.Cog, CoreLogic): ) return + if command_obj.requires.privilege_level > await PrivilegeLevel.from_ctx(ctx): + await ctx.send(_("You are not allowed to enable that command.")) + return + async with ctx.bot.db.guild(ctx.guild).disabled_commands() as disabled_commands: with contextlib.suppress(ValueError): disabled_commands.remove(command_obj.qualified_name)