Skip to content
Advertisement

How can i make that when a poll reaches por example 5 votes send the message to another channel

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

@cog_ext.cog_slash(name='poll', description='Create a poll')
@commands.has_role(Staff_role)
async def poll(self, ctx, message):
    embed=discord.Embed(title=f'Poll por {ctx.author}', description=f'{message}',color=embed_color)
    msg=await ctx.send(embed=embed)
    emoji = '✅'
    await msg.add_reaction(emoji)
    emoji = '🚫'
    await msg.add_reaction(emoji)

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:

@commands.Cog.listener()
async def on_reaction_add(self,reaction, user):
    if reaction.count == 2 and reaction.emoji == "✅":
        await reaction.message.reply(f"Votacion Aceptada")
    elif reaction.count == 2 and reaction.emoji == "❌":
        await reaction.message.delete()

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

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement