refactor: убрать дублирование в TextHelpCommand.send_bot_help()
Ветки if/else по cog_or_none выполняли идентичную логику. Объединены в один цикл — standalone-команды и команды из cog обрабатываются одинаково.
This commit is contained in:
parent
4f2e3ec05b
commit
0f944eafe7
9
bot.py
9
bot.py
@ -39,14 +39,7 @@ class TextHelpCommand(commands.HelpCommand):
|
|||||||
) -> None:
|
) -> None:
|
||||||
lines: list[str] = ["Доступные команды:"]
|
lines: list[str] = ["Доступные команды:"]
|
||||||
|
|
||||||
for cog_or_none, cog_commands in mapping.items():
|
for _cog_or_none, cog_commands in mapping.items():
|
||||||
if cog_or_none is None:
|
|
||||||
# Standalone-команды (без cog) — показываем если не hidden
|
|
||||||
for command in cog_commands:
|
|
||||||
if not command.hidden:
|
|
||||||
desc = command.short_doc or ""
|
|
||||||
lines.append(f" !{command.name} - {desc}")
|
|
||||||
continue
|
|
||||||
for command in cog_commands:
|
for command in cog_commands:
|
||||||
if not command.hidden:
|
if not command.hidden:
|
||||||
desc = command.short_doc or ""
|
desc = command.short_doc or ""
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user