如何创建一个匿名的不和谐民意调查机器人

时间:2020-09-08 07:34:00

标签: python python-3.x discord discord.py discord.py-rewrite

我正在创建一个匿名的不和谐民意调查机器人。到现在为止,我已经能够确定哪个用户已经投票了,如果已经投票了,他们就不能再投票了,但是我无法确定民意调查的创建者知道哪个反应获得了多少票的方式。谁和哪个反应没有投票。

这是我的代码:

@commands.Cog.listener()
async def on_raw_reaction_add(self, payload):
    member = payload.user_id

    conn = await aiosqlite.connect('test.db')
    c = await conn.cursor()
    await c.execute("SELECT user_id FROM reactions WHERE user_id = ? AND message_id = ?", (member, payload.message_id))
    users = await c.fetchone()
    await c.execute("SELECT message_id FROM reactions")

    message = await self.bot.get_channel(payload.channel_id).fetch_message(payload.message_id)

    for reaction in message.reactions:
        if (not payload.member.bot and users == None and payload.member in await reaction.users().flatten()):
            await payload.member.send("Your reaction is recorded")
            await message.remove_reaction(reaction.emoji, payload.member)
            await c.execute("INSERT INTO reactions (user_id,message_id) VALUES (?,?)", (member, payload.message_id))
            await c.execute("SELECT * FROM reactions")
            z = await c.fetchall()
            print(z)
            await conn.commit()
        elif users != None:
            await payload.member.send("You can't vote again")
            await message.remove_reaction(reaction.emoji, payload.member)

我尝试存储的是反应,它在SQL中计数,但是我 不能前进。

请帮助我,并选择任何可能的方法

0 个答案:

没有答案