Замена embed-вывода !help на простой текст
This commit is contained in:
parent
d0a4f45e68
commit
8d346943da
68
bot.py
68
bot.py
@ -24,6 +24,68 @@ if TYPE_CHECKING:
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TextHelpCommand(commands.HelpCommand):
|
||||
"""Выводит справку по командам простым текстом вместо embed."""
|
||||
|
||||
def get_command_signature(self, command: commands.Command) -> str:
|
||||
return f"!{command.qualified_name} {command.signature}"
|
||||
|
||||
async def send_bot_help(
|
||||
self, mapping: dict[discord.ext.commands.Command, list[discord.ext.commands.Command]]
|
||||
) -> None:
|
||||
lines: list[str] = ["Доступные команды:"]
|
||||
|
||||
for cog_or_none, cog_commands in mapping.items():
|
||||
if cog_or_none is None:
|
||||
# Команды без cog (встроенная help) — пропускаем
|
||||
continue
|
||||
for command in cog_commands:
|
||||
if not command.hidden:
|
||||
desc = command.short_doc or ""
|
||||
lines.append(f" !{command.name} - {desc}")
|
||||
|
||||
lines.append("\nВведите !<название команды> для использования.")
|
||||
await self.get_destination().send("\n".join(lines))
|
||||
|
||||
async def send_cog_help(
|
||||
self, cog: discord.ext.commands.Cog
|
||||
) -> None:
|
||||
commands_with_desc = cog.get_commands()
|
||||
lines: list[str] = [f"Команды [{cog.qualified_name}]:"]
|
||||
for command in commands_with_desc:
|
||||
if not command.hidden:
|
||||
desc = command.short_doc or ""
|
||||
lines.append(f" !{command.name} - {desc}")
|
||||
|
||||
await self.get_destination().send("\n".join(lines))
|
||||
|
||||
async def send_command_help(self, command: commands.Command) -> None:
|
||||
lines: list[str] = [f"!{command.qualified_name} {command.signature}"]
|
||||
if command.doc:
|
||||
lines.append(command.short_doc or command.help)
|
||||
if command.aliases:
|
||||
lines.append(f"\nАлиасы: {', '.join('!' + a for a in command.aliases)}")
|
||||
|
||||
await self.get_destination().send("\n".join(lines))
|
||||
|
||||
async def send_group_help(
|
||||
self, group: commands.Group
|
||||
) -> None:
|
||||
lines: list[str] = [f"!{group.qualified_name} {group.signature}"]
|
||||
if group.doc:
|
||||
lines.append(group.short_doc or group.help)
|
||||
|
||||
for command in group.commands:
|
||||
if not command.hidden:
|
||||
desc = command.short_doc or ""
|
||||
lines.append(f" !{command.name} - {desc}")
|
||||
|
||||
await self.get_destination().send("\n".join(lines))
|
||||
|
||||
async def send_error_message(self, error: str) -> None:
|
||||
await self.get_destination().send(error)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
intents = discord.Intents.default()
|
||||
@ -34,7 +96,11 @@ class BotRunner:
|
||||
"""Управляет жизненным циклом бота."""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.bot = commands.Bot(command_prefix="!", intents=intents)
|
||||
self.bot = commands.Bot(
|
||||
command_prefix="!",
|
||||
intents=intents,
|
||||
help_command=TextHelpCommand(),
|
||||
)
|
||||
self.bot._start_time = time.time()
|
||||
self.stop_event = threading.Event()
|
||||
self.bot_ready = threading.Event()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user