@Soneiko

Не работает исключение exeptions?

@pybot.command()
async def to(ctx, member: discord.Member):
    emojis = ['✅', '❌']
    load = discord.Embed(title='', description = f"")
    load.set_author(name= pybot.user.name, icon_url= pybot.user.avatar_url)
    load.set_footer(text= f"✅ - принять запрос, ❌ - отклонить запрос.")
    message = await ctx.send(embed = load)
    for emoji in emojis:
        await message.add_reaction(emoji)

    try:
        def check(reaction, user):
            if user.bot is False and user.id == member.id:
                return (user and str(reaction.emoji) == '✅') or (user and str(reaction.emoji) == '❌')
            elif user.bot is True:
                pass


        reaction, user = await pybot.wait_for('reaction_add', timeout= 1, check=check)
        await message.clear_reactions()
    except asyncio.TimeoutError:
        await message.edit("Время истекло") 
    else:
            if reaction.emoji == '✅':
                load = discord.Embed(title='', description = f"")
                load.set_author(name= pybot.user.name, icon_url= pybot.user.avatar_url)
                load.set_footer(text= f"")
                load.set_image(url = f"")
                await message.edit(embed = load)
            elif reaction.emoji == '❌':
                load = discord.Embed(title='', description = f"")
                load.set_author(name= pybot.user.name, icon_url= pybot.user.avatar_url)
                load.set_footer(text= f"")
                await message.edit(embed = load)
                pass
            else:
                pass

Есть кусок кода. В чем проблема, я в wait_for задал время ожидания после чего должна запуститься ошибка TimeoutError
и обработаться этот кусок кода
except asyncio.TimeoutError:
        await message.edit("Время истекло")

но почему-то оно его не отлавливает
606dff39deccc620649177.png
в строке
reaction, user = await pybot.wait_for('reaction_add', timeout= 1, check=check)
  • Вопрос задан
  • 102 просмотра
Пригласить эксперта
Ответы на вопрос 1
SoreMix
@SoreMix Куратор тега Python
yellow
А это не дефолтное исключение?

except TimeoutError:
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы