From d698380cd7872c4e1f9a5af517041287d89138ad Mon Sep 17 00:00:00 2001 From: deadzilla Date: Tue, 9 Jun 2026 18:19:18 +0500 Subject: [PATCH] =?UTF-8?q?fix:=20=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2?= =?UTF-8?q?=D0=B8=D0=BB=20crash=20=D0=B2=20on=5Fcommand=5Ferror=20=D0=BF?= =?UTF-8?q?=D1=80=D0=B8=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BE=D0=B2=D1=8B?= =?UTF-8?q?=D1=85=20=D0=BA=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=B0=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - ctx.command.name: добавлена проверка ctx.command на None - ctx.interaction: добавлен hasattr() — атрибута нет у commands.Context (текстовые команды !prefix), что вызывало AttributeError --- bot.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/bot.py b/bot.py index 6fef1e4..564255c 100644 --- a/bot.py +++ b/bot.py @@ -51,13 +51,16 @@ async def on_command_error(ctx, error): return # Терминал — детали для разработчика + cmd_name = ctx.command.name if ctx and ctx.command else '?' logger.error( - f"Ошибка команды {ctx.command.name if ctx else '?'}: {error}", + f"Ошибка команды {cmd_name}: {error}", exc_info=True, ) # Discord — только если команда не ответила сама - if ctx and ctx.interaction and ctx.interaction.response.is_done(): + # ctx.interaction есть только у slash-команд (AutoshardedInteractionContext) + # Для текстовых команд (!prefix) атрибута нет — используем hasattr + if ctx and hasattr(ctx, 'interaction') and ctx.interaction and ctx.interaction.response.is_done(): return try: