I am making a verification bot and the staff members have to accept or deny the user once the verification is sent with a reaction to the message. But if a staff member denies a user, The bot will ask for a reason which will be sent to the user. The issue is that when the bot is waiting for the staff member to send the reason if a message is sent in any other channel then the bot will use that message as the reason.
elif str(reaction) == "❌":
remove_id(member.id)
await verif_channel.send(":warning: Please provide a reason :warning:")
try:
deny_channel = member.guild.get_channel(889690902359080970)
msg = await self.bot.wait_for("message", timeout=600)
why = msg.content
embed_reason = discord.Embed(
title=":warning: You have been denied! :warning:",
description="You have been denied from the server for the following reason: (You are still allowed to reverify by reacting to the message in <#734570330064028002>) \n\n"
"{}".format(f"📑Reason: {why}"),
color=int(hex_color, 16))
await member.send(embed=embed_reason)
await verif_channel.send(f"❌ I have denied {member.mention}")
embed2 = discord.Embed(
title="Verification Request",
description=f"Verification request of {member.mention}",
color=int(hex_color, 16)
)
embed2.set_thumbnail(url=member.avatar_url)
embed2.add_field(name="How did you find this server?", value=found, inline=False)
embed2.add_field(name="How old are you?", value=age, inline=False)
embed2.add_field(name="This is a server related question", value=about, inline=False)
embed2.add_field(name="What are you looking to get out of this server?", value=seek, inline=False)
embed2.add_field(name="User was:", value=f"Denied for {why}", inline=False)
embed2.set_author(name=member.name)
embed2.set_footer(text=f"User ID: {member.id}")
channel = member.guild.get_channel(863099566672707594)
await channel.purge(limit=4)
await deny_channel.send(embed=embed2)
except discord.Forbidden:
await verif_channel.send(f"❌ Denied {member.mention}\n"
f"User has blocked DMs")
I am trying to change it so that the bot will look for a message in the channel from the user that reacted to the message. I tried a few different ways but I don't really know how I would get the id of the user that reacted to the message.
The best way to check if a message has been sent by a specific person is to use a check function
. Please view the code below.
# Define the check function within your code
def check(msg):
return msg.author == reaction.author and not msg.author.bot
# This checks if the author of the message is the author of the ❌ reaction
# AND checks if the message author is a bot or not
msg = await self.bot.wait_for("message", check=check, timeout=600)
Helpful link(s):
client.wait_for
- discord.py docs