From 7b9a3081cf2d5de6aad3617f0b2d67c62f37a85b Mon Sep 17 00:00:00 2001 From: Timo <35654063+tibue99@users.noreply.github.com> Date: Sat, 9 Dec 2023 13:07:13 +0100 Subject: [PATCH] Fix help command edge cases --- ezcord/cogs/help.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/ezcord/cogs/help.py b/ezcord/cogs/help.py index 8943211..63af6c1 100644 --- a/ezcord/cogs/help.py +++ b/ezcord/cogs/help.py @@ -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 @@ -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]: @@ -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