【发布时间】:2021-01-12 20:59:56
【问题描述】:
所以下面的代码有一个我没能解决的问题。
机器人会发送第二个“testMessasge”,然后对该消息和主消息做出反应。这里的问题是,当我只想对第一条消息做出反应时,我可以对任一消息做出反应以触发代码。
不胜感激。
async def foo(ctx, booleanValue, randomClass, stringValue='', otherData=None):
files, embed = createEmbed(ctx, randomClass)
message = await ctx.send(files=files, embed=embed)
await message.add_reaction(data.getEmoji('1'))
testMessage = await ctx.send('TEST')
await testMessage.add_reaction(data.getEmoji('1'))
def check(reaction, user):
return (user == ctx.message.author and str(reaction.emoji) == data.getEmoji('1'))
async def waitForEmoji(ctx, isBattle):
print(ctx.message.author)
try:
reaction, user = await bot.wait_for('reaction_add', timeout=300.0, check=check)
except asyncio.TimeoutError:
await ctx.send(ctx.message.author.display_name + 's connection closed.')
else:
print(user)
print(ctx.message.author)
【问题讨论】:
标签: discord discord.py