Browse Source

Raise context menu command limit to 15 to match Discord

pull/10422/head
Rapptz 4 months ago
parent
commit
026a882d52
  1. 12
      discord/app_commands/tree.py

12
discord/app_commands/tree.py

@ -257,7 +257,7 @@ class CommandTree(Generic[ClientT]):
-------- --------
CommandLimitReached CommandLimitReached
The maximum number of commands was reached for that guild. The maximum number of commands was reached for that guild.
This is currently 100 for slash commands and 5 for context menu commands. This is currently 100 for slash commands and 15 for context menu commands.
""" """
try: try:
@ -277,9 +277,9 @@ class CommandTree(Generic[ClientT]):
counter = Counter(cmd_type for _, _, cmd_type in ctx_menu) counter = Counter(cmd_type for _, _, cmd_type in ctx_menu)
for cmd_type, count in counter.items(): for cmd_type, count in counter.items():
if count > 5: if count > 15:
as_enum = AppCommandType(cmd_type) as_enum = AppCommandType(cmd_type)
raise CommandLimitReached(guild_id=guild.id, limit=5, type=as_enum) raise CommandLimitReached(guild_id=guild.id, limit=15, type=as_enum)
self._context_menus.update(ctx_menu) self._context_menus.update(ctx_menu)
self._guild_commands[guild.id] = mapping self._guild_commands[guild.id] = mapping
@ -338,7 +338,7 @@ class CommandTree(Generic[ClientT]):
Or, ``guild`` and ``guilds`` were both given. Or, ``guild`` and ``guilds`` were both given.
CommandLimitReached CommandLimitReached
The maximum number of commands was reached globally or for that guild. The maximum number of commands was reached globally or for that guild.
This is currently 100 for slash commands and 5 for context menu commands. This is currently 100 for slash commands and 15 for context menu commands.
""" """
guild_ids = _retrieve_guild_ids(command, guild, guilds) guild_ids = _retrieve_guild_ids(command, guild, guilds)
@ -361,8 +361,8 @@ class CommandTree(Generic[ClientT]):
# read as `0 if override and found else 1` if confusing # read as `0 if override and found else 1` if confusing
to_add = not (override and found) to_add = not (override and found)
total = sum(1 for _, g, t in self._context_menus if g == guild_id and t == type) total = sum(1 for _, g, t in self._context_menus if g == guild_id and t == type)
if total + to_add > 5: if total + to_add > 15:
raise CommandLimitReached(guild_id=guild_id, limit=5, type=AppCommandType(type)) raise CommandLimitReached(guild_id=guild_id, limit=15, type=AppCommandType(type))
data[key] = command data[key] = command
if guild_ids is None: if guild_ids is None:

Loading…
Cancel
Save