fix: исправил crash в on_command_error при текстовых командах
- ctx.command.name: добавлена проверка ctx.command на None - ctx.interaction: добавлен hasattr() — атрибута нет у commands.Context (текстовые команды !prefix), что вызывало AttributeError
This commit is contained in:
parent
978340f0dd
commit
d698380cd7
7
bot.py
7
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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user