I’m trying to make a poll, but all the ones I see have a limit of time created with asyncio, but I want to make that when the a poll reaches 5 reaction of the emoji ✅ instead of having a limit of time, send the message to another channel, I already have the poll itself done
JavaScript
x
10
10
1
@cog_ext.cog_slash(name='poll', description='Create a poll')
2
@commands.has_role(Staff_role)
3
async def poll(self, ctx, message):
4
embed=discord.Embed(title=f'Poll por {ctx.author}', description=f'{message}',color=embed_color)
5
msg=await ctx.send(embed=embed)
6
emoji = '✅'
7
await msg.add_reaction(emoji)
8
emoji = '🚫'
9
await msg.add_reaction(emoji)
10
How can I check if a embed of a specific channel have 5 reactions of a specific emoji send the message that got that 5 reactions to another channel?
Advertisement
Answer
I have done it, but you must change if if your bot turns off anytime, if it’s always on this code should work:
JavaScript
1
7
1
@commands.Cog.listener()
2
async def on_reaction_add(self,reaction, user):
3
if reaction.count == 2 and reaction.emoji == "✅":
4
await reaction.message.reply(f"Votacion Aceptada")
5
elif reaction.count == 2 and reaction.emoji == "❌":
6
await reaction.message.delete()
7
It just check how many reacctions has the message of X emoji, and if it equals to something, it does that thing, I recomend putting ==
instead of >
or >=
because everytime someone votes it will resend the message