Reputation: 309
I'm creating a "delete faction" command for my faction bot which asks the user to confirm that they want to delete their faction using reactions. My code is as follows:
embed = discord.Embed(
title=":warning: Are you sure?",
colour=discord.Colour.purple(),
description=f"Are you sure you want to delete **{name_capital}**? "
f"*Your members will lose their roles and so will you.*"
)
txt = await ctx.send(embed=embed)
await txt.add_reaction("✅")
await txt.add_reaction("❌")
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) == "✅" or "❌"
try:
reaction, user = await self.client.wait_for('reaction_add', timeout=8.0, check=check)
except asyncio.TimeoutError:
embed = discord.Embed(
title=":x: Deletion cancelled",
colour=discord.Colour.purple(),
description="Message timed out"
)
await txt.delete()
await ctx.send(embed=embed)
else:
if reaction.emoji == "❌":
await txt.delete()
elif reaction.emoji == "✅":
pass # delete faction code
The command works for the most part. But, it also works for other users who react to the message, despite me stating that not to happen in the check function.
What is wrong and how can I fix it?
Upvotes: 1
Views: 329
Reputation: 116
Just a guess, but your check function could be malformed. Should be like this:
def check(reaction, user):
return user == ctx.author and (str(reaction.emoji) == "✅" or "❌")
Upvotes: 1