Skip to content

Commit

Permalink
help.py: Workaround for cogs with more than 100 commands
Browse files Browse the repository at this point in the history
  • Loading branch information
FrozenChen committed Oct 5, 2024
1 parent eac33db commit 86ecb3c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions utils/help.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import discord
import random
import math

from discord import Interaction
Expand Down Expand Up @@ -277,6 +278,11 @@ async def send_cog_help(self, cog: Cog):
# All my homies hate Assistance
# If there is >25 commands create multiple Selects and add a suffix indicating what commands are inside [A-C]
if len(commands) > SELECT_MAX_VALUES:
# Workaround some cogs having way too many commands, let's go gambling
if len(commands) > 100:
random.shuffle(commands)
commands = commands[:100]
commands.sort(key=lambda x: x.name)
for i in range(0, len(commands), SELECT_MAX_VALUES - 1):
view.add_item(CommandSelect(cog, commands[i:i + SELECT_MAX_VALUES - 1], self.context,
suffix=f"[{commands[i].name[0].upper()}-{commands[i:i + SELECT_MAX_VALUES - 2][-1].name[0].upper()}]"))
Expand Down

0 comments on commit 86ecb3c

Please sign in to comment.