BotBoi345
BotBoi345

Reputation: 59

'Bot' object has no attribute 'wait_for_reaction'

error: 'Bot' Has No Attribute Called 'wait_for_reaction', Here's The Code:

if int(pp) >= 19:
        gh = await message.send('''
Your Number Is Higher Or Is 20... Click ⬆ To Continue''')
        await gh.add_reaction("⬆")
        await bot.wait_for_reaction('⬆', gh)

btw bot = command.Bot()

Upvotes: 1

Views: 789

Answers (2)

Ratery
Ratery

Reputation: 2917

You need to use wait_for:

await bot.wait_for("raw_reaction_add", timeout=180, check=lambda payload: payload.member == ctx.author and str(payload.emoji) == "⬆")

Upvotes: 2

Bagle
Bagle

Reputation: 2346

bot.wait_for_reaction is no longer a part of discord.py and has been deprecated. Instead, you should be using bot.wait_for(), making the bot 'wait for' a reaction, and checking if the reaction's author is the author of the message. Do view a further explanation in the revised code below:

if int(pp) >= 19:
        gh = await message.send('''
Your Number Is Higher Or Is 20... Click ⬆ To Continue''')
        await gh.add_reaction("⬆")

        # New code starts here #

        # Define your check
        # Checks if the reaction author is the author of the message
        # and if the reaction emoji is '⬆'
        def check(reaction, user):
                return user == message.author and str(reaction.emoji) == '⬆'

        try:
                reaction, user = await bot.wait_for("reaction_add",check=check,timeout=10)
        except asyncio.TimeoutError: # That way the bot doesn't wait forever for a reaction
                await message.send("Ran out of time, interaction ended")
                return
        if reaction: 
                # 'if statement' is regarded if the given reaction is valid (and not None)
                # Continue with the rest of your code

Above working

Questions like this:

Upvotes: 1

Related Questions