R
R
RamboDash2021-07-30 22:49:18
Python
RamboDash, 2021-07-30 22:49:18

How to count the number of reactions on a post in Discord?

Hello, I'm making a poll function for my bot, and I want it to sum up after a certain time. The polling function itself is implemented through reactions (one reaction for each option). To summarize, I need the bot to count the number of each reaction. How can this be implemented?

My code:

@bot.command(name='poll')
async def poll(ctx, question, option1 = None, option2 = None):
    if option1 == None and option2 == None:
        embed = discord.Embed(
            title="Poll",
            description=f"{question}",
            color = discord.Color.blue()
        )
        msg = await ctx.channel.send(embed=embed)
        message = await ctx.channel.fetch_message(msg.id)
        await message.add_reaction("")
        await message.add_reaction("")
    embed = discord.Embed(
        title="Poll",
        description=f"{question}",
        color=discord.Color.blue()
    )
    embed.add_field(name=f"{option1}", inline=False)
    embed.add_field(name=f"{option2}", inline=False)
    msg = await ctx.channel.send(embed=embed)
    message = await ctx.channel.fetch_message(msg.id)
    await message.add_reaction("")
    await message.add_reaction("")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
bitler, 2021-07-31
@bitler

https://discordpy.readthedocs.io/en/stable/api.htm...
https://discordpy.readthedocs.io/en/stable/api.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question