我有一个命令可以通过 2 个按钮来回移动一系列图像:
left = '⏪'
right = '⏩'
def predicate(message, l, r):
def check(reaction, user):
if reaction.message.id != message.id or user == Bot.user:
return False
if l and reaction.emoji == left:
return True
if r and reaction.emoji == right:
return True
return False
return check
一些东西
mmsg = ("1.png", "2.png", "3.png", "4.png")
index = 0
while True:
msg = await Bot.send_file(ctx.message.channel, mmsg[index])
l = index != 0
r = index != len(mmsg) - 1
if l:
await Bot.add_reaction(msg, left)
if r:
await Bot.add_reaction(msg, right)
Bot.wait_for_reaction
reaction, ctx.message.author = await Bot.wait_for_reaction(check=predicate(msg, l, r))
if reaction.emoji == left:
index -= 1
elif reaction.emoji == right:
index += 1
await Bot.delete_message(msg)
但是当你以外的人点击按钮时,命令起作用,这不应该发生,只有执行命令的人才能点击按钮,如谓词检查所示,应该怎么做?
相关分类