Answer the question
In order to leave comments, you need to log in
How to do a click check of a reaction by comparing the message id?
I have a pay function in my code that sends money to a server member. To confirm the payment, you must click on the appropriate reaction, which is pre-set by the bot. A check has been implemented to see if the author or another person added this reaction, and accordingly to the reaction. But there is one problem, if, say, you send 2 pay commands, and click on the reaction on one of the messages, the code will automatically work on the second one. Is there any way to fix this?
@commands.command()
async def pay(self, ctx, member: discord.Member, amount: int):
if member == ctx.author:
await ctx.send(f'***```Ошибка - перевод самому себе запрещён!```***')
return
else:
pass
confirm = await ctx.send(
embed=discord.Embed(
title=f'{ctx.author.name}, Вы точно хотите перевести деньги {member} в количестве {amount} $ ?',
timestamp=ctx.message.created_at)
)
message_id = confirm.id
accept = '✅'
decline = '❌'
await confirm.add_reaction(accept)
await confirm.add_reaction(decline)
valid_reactions = ['✅', '❌']
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in valid_reactions
reaction, user = await self.bot.wait_for('reaction_add', timeout=60.0, check=check)
if str(reaction.emoji) == accept:
# тут рабочий код
return await ctx.send(f'***```Успешно!```***')
# так как реакции всего 2, если код выше ничего не возвращает, идём дальше
await ctx.send(f'***```Перевод отменён!```***')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question