1

У меня есть команда голосование которая создаёт ембед и добавляет лайки и дизлайки. Мне нужно чтобы он подсчитал количество реакций лайк и дизлайк и сравнил

@bot.command()
@commands.has_permissions( view_audit_log = True )
async def vote(ctx, time:int, *, text=None):
    await ctx.message.add_reaction('✅')
    emb = discord.Embed(
        title=f"Started vote",
        color=0xffffff
        ) #Embed
    emb.add_field(name='Vote for:', value=text,inline=False)
    emb.add_field(name='Time:', value=time,inline=False)
    emb.set_footer(text=f'{ctx.message.author}', icon_url=ctx.message.author.avatar_url)
    await ctx.send('@everyone')
    mess = await ctx.send( embed = emb )
    await mess.add_reaction('👍')
    await mess.add_reaction('👎')
    print(f'[SUCCESS] Started vote for {text}')
    await asyncio.sleep(time)
    print('vote ended')
    mess = await mess.channel.fetch_message(mess.id)
    emb = discord.Embed(
        title=f"Ended vote",
        color=0xffffff
        ) #Embed
    emb.add_field(name='Vote for:', value=text,inline=False)
    emb.add_field(name='Time:', value=time,inline=False)
    if liked > disliked:
        emb.add_field(name='Vote successful',inline=False)
    elif liked < disliked:
        emb.add_field(name='Vote failed',inline=False)
    else:
        emb.add_field(name='Votes are same', value='Revote needed',inline=False)
    emb.set_footer(text=f'{ctx.message.author}', icon_url=ctx.message.author.avatar_url)
    await ctx.send( embed = emb )

1 ответ 1

1
for reaction in mess.reactions:
    if reaction.emoji == '👍':
        liked = reaction.count
    elif reaction.emoji == '👎':
        disliked = reaction.count

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.