mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-21 02:16:09 -05:00
Reduce calls to config in the on_command_add event (#3764)
* lets reduce config calls here Signed-off-by: Drapersniper <27962761+drapersniper@users.noreply.github.com> * stop using `bot.guilds` in `on_command_add` Co-authored-by: jack1142 <6032823+jack1142@users.noreply.github.com>
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user