diff --git a/redbot/core/commands/commands.py b/redbot/core/commands/commands.py index 4b52b1e66..e2215958f 100644 --- a/redbot/core/commands/commands.py +++ b/redbot/core/commands/commands.py @@ -905,15 +905,15 @@ def get_command_disabler(guild: discord.Guild) -> Callable[["Context"], Awaitabl ``False`` if the context is within the given guild. """ try: - return __command_disablers[guild] + return __command_disablers[guild.id] except KeyError: async def disabler(ctx: "Context") -> bool: - if ctx.guild == guild: + if ctx.guild is not None and ctx.guild.id == guild.id: raise DisabledCommand() return True - __command_disablers[guild] = disabler + __command_disablers[guild.id] = disabler return disabler diff --git a/redbot/core/events.py b/redbot/core/events.py index 815c4ad9e..0417b5364 100644 --- a/redbot/core/events.py +++ b/redbot/core/events.py @@ -262,10 +262,11 @@ def init_events(bot, cli_flags): disabled_commands = await bot._config.disabled_commands() if command.qualified_name in disabled_commands: command.enabled = False - for guild in bot.guilds: - disabled_commands = await bot._config.guild(guild).disabled_commands() + guild_data = await bot._config.all_guilds() + for guild_id, data in guild_data.items(): + disabled_commands = data.get("disabled_commands", []) if command.qualified_name in disabled_commands: - command.disable_in(guild) + command.disable_in(discord.Object(id=guild_id)) async def _guild_added(guild: discord.Guild): disabled_commands = await bot._config.guild(guild).disabled_commands()