如何在@ bot.event discord.py中使反应起作用

时间:2020-07-25 07:40:35

标签: python discord.py-rewrite

嘿,我正在尝试制作“服务器创意”频道 在每封邮件中,机器人会添加以下反应“✅”“❌”: 我知道我的代码中缺少某些内容,请帮助我修复所有问题

@bot.event
async def on_message(message):
    channel = bot.get_channel(736296983412867202)
    ctx = await bot.get_context(message)

    def check(reaction, user):
        if user == bot.user:
            return False
         if str(reaction.emoji) not in ("✅","❌"):
            return False
        if reaction.message.content != msg.content:
            return False
        return True

    v = await message.add_reaction("✅")
    x = await message.add_reaction("❌")

    staff_ideas_channel = bot.get_channel(736306606886748230)

    await asyncio.sleep(20)
    print('wokeup from sleep')
    if x.reaction() > v.reaction():
        await ctx.message.delete()
        print('hungry for x')
        return
    elif x.reaction() < v.reaction():
        await ctx.message.delete()
        await staff_ideas_channel.send(message)
        print('hungry for v')
        return

    if x.reaction() == v.reaction():
        await ctx.message.delete()
        print('not hungrry')
    else:
        print("error")

我收到此错误:

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\discord\client.py", line 312, in _run_event
    await coro(*args, **kwargs)
  File "D:\david's folder\Python\Discord Bots\peach bot private\bot.py", line 41, in on_message
    if x.reaction() > v.reaction():
AttributeError: 'NoneType' object has no attribute 'reaction'

该怎么办?

0 个答案:

没有答案