0
@commands.Cog.listener()
async def on_member_join(self, member):
test = randint(1000, 99999)

def check(m):
    return m.content == f'{captcha}' and m.author.id == member.id

try:
    msg = await self.client.wait_for('message', timeout=30.0, check=check)
    await msg.add_reaction("✅")

except asyncio.TimeoutError:
    await msg.add_reaction("❌")
    await member.send('TimeOut')
    await member.kick(reason='TimeOut')
else:
    await member.send('Thank')

Ошибка:

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:\Py\lib\site-packages\discord\client.py", line 312, in _run_event await coro(*args, **kwargs) File "c:\Users\Stanisla\Desktop\Turtle-Bot\cogs\Moderation.py", line 135, in on_member_join await msg.add_reaction("❌") UnboundLocalError: local variable 'msg' referenced before assignment

1 ответ 1

1

Мне кажется строка await msg.add_reaction("❌") у вас должна быть до except: по логике. В случае исключения по таймауту у вас в msg не успевает ничего записаться, из-за этого ошибка.

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.