【发布时间】:2020-11-26 19:34:55
【问题描述】:
大部分都很好,但我如何让它只编辑用户发送的最新消息?如果有人键入相同的命令两次,然后对第二条消息做出反应,只要它在超时之前的 60 秒窗口中,它就会编辑 both 消息。代码如下:
px = await ctx.send(embed=e)
for name in reactions:
emoji = get(ctx.guild.emojis, name=name)
try: await px.add_reaction(emoji or name)
except: return
def check(reaction, user):
return user == ctx.author and str(reaction.emoji) in reactions
while True:
try:
reaction, user = await self.bot.wait_for("reaction_add", timeout=60, check=check)
if str(reaction.emoji) == "right":
p += 1
# doing the command again but + 1 page
await px.edit(embed=e)
elif str(reaction.emoji) == "left":
p -= 1
# doing the command again but - 1 page
await px.edit(embed=e)
else:
await px.remove_reaction(reaction, user)
except asyncio.TimeoutError:
break
我只希望它编辑该用户最近使用的命令。谢谢。
【问题讨论】:
标签: python python-3.x discord discord.py discord.py-rewrite