Skip to content
This repository was archived by the owner on Jan 21, 2026. It is now read-only.

Commit aefb160

Browse files
committed
fix: prevent embed field overflow in help menu by splitting commands based on character count
- Changed from fixed 10-command chunks to dynamic chunking based on 1000 char limit - Truncate command descriptions longer than 80 chars to prevent overflow - Properly number continuation fields for better organization
1 parent 39c9714 commit aefb160

1 file changed

Lines changed: 30 additions & 6 deletions

File tree

cogs/help.py

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,17 +168,41 @@ def _create_category_embed(self, cog_name: str) -> discord.Embed:
168168
# Format: command name + signature + description
169169
signature = f"{cmd.name} {cmd.signature}".strip()
170170
desc = cmd.short_doc or "No description"
171+
# Limit description length to prevent overflow
172+
if len(desc) > 80:
173+
desc = desc[:77] + "..."
171174
commands_list.append(f"`{signature}`\n└─ {desc}")
172175

173176
if commands_list:
174-
# Split into chunks if too long
175-
chunk_size = 10
176-
for i in range(0, len(commands_list), chunk_size):
177-
chunk = commands_list[i:i+chunk_size]
178-
field_name = "Commands" if i == 0 else "Commands (continued)"
177+
# Split into chunks by character count (max 1000 to be safe)
178+
current_chunk = []
179+
current_length = 0
180+
field_number = 0
181+
182+
for cmd_text in commands_list:
183+
cmd_length = len(cmd_text) + 2 # +2 for "\n\n" separator
184+
185+
# If adding this command would exceed limit, start new field
186+
if current_length + cmd_length > 1000 and current_chunk:
187+
field_name = "Commands" if field_number == 0 else f"Commands (continued {field_number})"
188+
embed.add_field(
189+
name=field_name,
190+
value="\n\n".join(current_chunk),
191+
inline=False
192+
)
193+
current_chunk = []
194+
current_length = 0
195+
field_number += 1
196+
197+
current_chunk.append(cmd_text)
198+
current_length += cmd_length
199+
200+
# Add remaining commands
201+
if current_chunk:
202+
field_name = "Commands" if field_number == 0 else f"Commands (continued {field_number})"
179203
embed.add_field(
180204
name=field_name,
181-
value="\n\n".join(chunk),
205+
value="\n\n".join(current_chunk),
182206
inline=False
183207
)
184208
else:

0 commit comments

Comments
 (0)