Reputation: 3602
I am in the process of creating a question bot. Here the bot asks different questions and also gives different ways to respond. I would like to keep this possibility. But I need an event, which removes the reactions under this message, after a user has submitted it. I haven't really found anything unfortunately, but would do something with a raw_reaction
event, would I be right and how would that need to look? I also think that I would also need to define all the code to get the reactions of the message, is this so?
My code so far:
@commands.command()
async def trivia_q(self, ctx):
await ctx.send("Test, check your DMs")
def check(m):
return ctx.author == m.author and isinstance(m.channel, discord.DMChannel)
e = discord.Embed(color=discord.Color.gold())
e.title = "New question, new luck."
e.description = "**When was Steve Jobs born?**"
e.add_field(name="1️⃣", value="02/24/1955", inline=False)
e.add_field(name="2️⃣", value="03/24/1955", inline=False)
e.add_field(name="3️⃣", value="02/24/1965", inline=False)
e.set_footer(text="You have x-x to answer this question.", icon_url=self.bot.user.avatar_url)
e.timestamp = datetime.datetime.utcnow()
question = await ctx.send(embed=e)
await question.add_reaction("1️⃣")
await question.add_reaction("2️⃣")
await question.add_reaction("3️⃣")
try:
question = await self.bot.wait_for('reaction_add', timeout=60.0, check=check)
except asyncio.TimeoutError:
await ctx.author.send("You took to long to react.")
return
await asyncio.sleep(10)
e2 = discord.Embed(color=discord.Color.gold())
e2.title = "New question, new luck."
e2.description = "Test1"
e2.add_field(name="1️⃣", value="02/24/1955")
e2.add_field(name="2️⃣", value="03/24/1955")
e2.add_field(name="3️⃣", value="02/24/1965")
e2.set_footer(text="You have x-x to answer this question.")
e2.timestamp = datetime.datetime.utcnow()
await question.edit(embed=e2)
await question.add_reaction("1️⃣")
await question.add_reaction("2️⃣")
await question.add_reaction("3️⃣")
Edit: I guess this will be a DM only command, not sure yet - Maybe makes it easier.
The error code I get is now:
TypeError: check() takes 1 positional argument but 2 were given
How would I continue?
Upvotes: 1
Views: 1118
Reputation: 578
You can remove all reactions from a message at once:
question = await ctx.send(embed=e)
await question.clear_reactions()
If you are trying to do this after a user has responded, use the await bot.wait_for("message", check=some_check_function)
See: https://discordpy.readthedocs.io/en/latest/api.html#discord.Client.wait_for
Upvotes: 1