0

I'm struck with a weird problem, here is the code :

                embed_msg = await ctx.channel.send(embed=embed)
                await embed_msg.add_reaction('')
                await embed_msg.add_reaction('')
                reaction, user = await self.bot.wait_for('reaction_add')
                if str(reaction.emoji) == '':
                     print('GOOD ! ')
                elif str(reaction.emoji) == '':
                     print('BAD !')
                     return

Problem is, when I start the bot and I try this, there's a 1/10 chance that this will work but 9/10 that the 'BAD !' condition trigger itself. I have no clues what to do about that

Thanks for the help

  • 1
    Does it work if you add a `check` that verifies the message is correct? – Eric Jin Apr 19 '22 at 16:28
  • Does this answer your question? [Discord.py-rewrite wait\_for() how do i use?](https://stackoverflow.com/questions/52571844/discord-py-rewrite-wait-for-how-do-i-use) – TheFungusAmongUs Apr 19 '22 at 17:52
  • I would not say it is a duplicate, but yes, look at that question. It should give you info about `wait_for` checks. – Eric Jin Apr 19 '22 at 18:10

1 Answers1

0

Assuming that self.bot.wait_for returns a user object, you can check if the reaction was added by a bot or not. Because the bot may be reacting to its own message. This will not work if it is not a user object. Sorry if I messed up the indentation.

embed_msg = await ctx.channel.send(embed=embed)
await embed_msg.add_reaction('')
await embed_msg.add_reaction('')
reaction, user = await self.bot.wait_for('reaction_add')
if str(reaction.emoji) == '':
    if not user.bot:
        print('GOOD ! ')
elif str(reaction.emoji) == '':
    if not user.bot:
        print('BAD !')
        return
Yurata
  • 44
  • 2