Skip to content

Commit

Permalink
Fix help command edge cases
Browse files Browse the repository at this point in the history
  • Loading branch information
tibue99 committed Dec 9, 2023
1 parent b0390a2 commit 7b9a308
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions ezcord/cogs/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ def get_group(cog: Cog) -> str | None:

def replace_placeholders(s: str, **kwargs: str):
for key, value in kwargs.items():
if not value:
continue
s = s.replace(f"{{{key}}}", value)
return s

Expand Down Expand Up @@ -91,6 +93,17 @@ async def help(self, ctx):
group = get_group(cog)
name = group if group else name
name = name.title()

if len(name) == 0:
log.warning(
"A cog has a name with length 0. "
"This cog will not be displayed in the help command."
)
continue

if len(name) > 100:
name = name[:90] + "..."

if name not in commands:
commands[name] = {}
if "cmds" not in commands[name]:
Expand All @@ -105,6 +118,11 @@ async def help(self, ctx):
desc = cog.description
if not cog.description:
desc = t("default_description", name)
if not desc:
log.warning(
f"The default description for cog '{name}' is invalid. "
f"This can be changed in the language file."
)

commands[name]["description"] = desc

Expand Down

0 comments on commit 7b9a308

Please sign in to comment.