I'm trying to make a command for a bot that when everybody that have been mentioned in the message reacts to the bot's response, it mentions the original message author
That's what i tried
if msg.content.startswith('/iniciar'):
async with msg.channel.typing():
mentions = ""
for mention in msg.mentions:
mentions = mentions + " " + mention.mention
bot_msg: discord.Message = await msg.channel.send(mentions + ' confirmem presença reagindo abaixo.')
await bot_msg.add_reaction('✅')
for mention in msg.mentions:
def check(reaction, user):
return user == mention and str(reaction.emoji) == '✅'
try:
reaction, user = await client.wait_for('reaction_add', check=check)
finally:
reactionusers: list = await reaction.users().flatten()
reactionusers.remove(reactionusers[0])
print(reactionusers)
print(msg.mentions)
if reactionusers == msg.mentions:
await msg.channel.send(msg.author.mention)
else:
return
Okay well first off, you'll need to consider a few things in this current implementation. For one, you'll probably want to save the message ID that you want the bot to watch somewhere. Whether this is SQL, a Shelve, whatever
For this, when the /iniciar function is called, save the message ID in whatever preferred long-term storage method you prefer, somewhere the bot can check.
Then you'll want to consider how you're activating this codeblock, which I can't see in your current given code. I'd suggest, for your purposes, using on_reaction_add which has documentation here: https://discordpy.readthedocs.io/en/latest/api.html#discord.on_reaction_add
Use Reaction.message to grab the message object, and read the relevant information for who is mentioned in the message into a list (similar to how you're doing).
When a user reacts to the message and on_reaction_add is called:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With