PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 10, 2022

[FIXED] How To Make Bot Wait For 2 Reactions

 July 10, 2022     discord, discord.py, message, python     No comments   

Issue

I Want My Discord.py Bot To Wait For 2 Reactions...

The Code:

def check(reaction, user):
return user == message.author and str(reaction.emoji) == '1️⃣'
def check(reaction, user):
return user == message.author and str(reaction.emoji) == '2️⃣'

mm = await message.send(embed=embed1)
    await mm.add_reaction("1️⃣")
    await mm.add_reaction("2️⃣")
    reaction, user = await bot.wait_for("reaction_add",check=check,timeout=180)
    reaction, user = await bot.wait_for("reaction_add",check=check,timeout=180)
    if reaction:
        await mm.edit(embed=embed1)
    elif reaction:
        await mm.edit(embed=embed3)

Solution

Within your check function, you can check if the user's reaction is one in a given list, or you can use an or statement. In this example, I will use the former. Then, you can check which reaction it is, and continue from there. Do view the revised code below.

def check(reaction, user):
    # Check if user is the author of the message
    # AND if the reaction emoji is in a list of set reactions, 1️⃣ and 2️⃣
    return user == ctx.author and str(reaction.emoji) in ["1️⃣","2️⃣"]

await mm.add_reaction("1️⃣")
await mm.add_reaction("2️⃣")
reaction, user = await bot.wait_for("reaction_add",check=check,timeout=180)
if str(reaction.emoji) == "1️⃣":
    # do something
elif str(reaction.emoji) == "2️⃣":
    # do something else


Answered By - Bagle
Answer Checked By - Robin (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing