wait_for检查不起作用discord.py

时间:2020-08-29 07:58:45

标签: python discord discord.py

    if (message.content == "<@" + str(client.user.id) + ">" or message.content == "<@!" + str(client.user.id) + ">" or message.content == "<@&" + str(client.user.id) + ">"):
        con = sqlite3.connect(str(message.guild.id) + ".db")
        cursor = con.cursor()
        cursor.execute("SELECT * FROM users WHERE users.id == " + str(message.author.id))
        userinfo = cursor.fetchall()
        if (userinfo == []):
            cursor.execute("INSERT INTO users Values(?, ?, ?, ?, ?)", (message.author.id, 0, 0, 0, "False"))
        con.commit()
        con.close()
        embed = discord.Embed(color=0x00ff00, title="Automat", description="**안녕하세요, " + message.guild.name + " 입니다.**\n무엇을 도와드릴까요?\n\n:regional_indicator_a: 내 정보 확인\n:regional_indicator_b: 잔액 충전\n:regional_indicator_c: 제품 구매\n:regional_indicator_d: 재고 상태").set_footer(text="프리미엄 봇자판기 Automat | 문의 : ! N Boss#1234")
        msg = await message.author.send(embed=embed)
        await msg.add_reaction("?")
        await msg.add_reaction("?")
        await msg.add_reaction("?")
        await msg.add_reaction("?")

        def check(reaction, user):
            return user == message.author and str(reaction.emoji) == "?" or "?" or "?" or "?"
        try:
            reaction, user = await client.wait_for('reaction_add', timeout=10, check=check)

我希望我的机器人只回复message.author的反应, 但是我的机器人会自行响应。 如何使我的漫游器仅响应message.author的反应?

1 个答案:

答案 0 :(得分:1)

添加到您的支票:

        def check(reaction, user):
            return user == message.author and str(reaction.emoji) == "?" or "?" or "?" or "?" and not user.bot
        try: