Discord.py Detecting Reactions
I am making a Discord.py bot that uses DMs. I have a command where the bot will DM you asking for you to react to the action you are trying to do the issue is when the user adds th
Solution 1:
So it turns out
return user == msg.author andstr(reaction.emoji) == '<:Yes:755187983585509517>'
I was checking the BOT adding a reaction not the user, hopefully this saves someone else time.
Solution 2:
Here is a suggestion command I came up with:
@client.command()asyncdefsuggest(ctx, *, suggestion):
author = ctx.message.author
file = open("suggestions.txt", "a+")
file.write(str(author) + " : " + suggestion + "\n")
embed = discord.Embed(title='Suggestion',
description="This Was Suggested By",
color=0xE0B802)
embed.set_footer(text=f"Made By {ctx.author.mention}")
embed.set_author(name=f"{author}")
embed.add_field(name=author, value=suggestion)
await ctx.send("Suggestion Submitted")
msg = await channel.send(embed=embed)
await msg.add_reaction('👍')
await msg.add_reaction('👎')
await ctx.send(f"{ctx.author.mention} suggested {suggestion}!")
It will send an embed with the suggestion and add the reactions along with having the author that created the suggestion in its footer.
Solution 3:
you could try a wait_for
. Examples are here
@client.eventasyncdefon_message(message):
if message.content.startswith('$thumb'):
channel = message.channel
await channel.send('Send me that 👍 reaction, mate')
defcheck(reaction, user):
return user == message.author andstr(reaction.emoji) == '👍'try:
reaction, user = await client.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await channel.send('👎')
else:
await channel.send('👍')
(taken from the discord.py API reference https://discordpy.readthedocs.io/en/stable/api.html#discord.Client.wait_for
Post a Comment for "Discord.py Detecting Reactions"