【发布时间】:2021-05-28 20:55:34
【问题描述】:
我想为我的机器人制作一个石头剪刀布游戏: The bot creates an embed with instructions and reacts with a "rock", "paper", and "scissor" emoji, which the user has to click to input his/her choice.
但问题是代码没有进一步执行并显示错误。
代码如下:
@client.command(aliases = ["rock_paper_scissors","rps"])
async def _rps(ctx): #rps is short for rock, paper, scissor
emojis = ['✊', '????️', '✌️']
embedVar = discord.Embed(title="CHOOSE YOUR WEAPON!",description = "Choose between rock, paper, or scissors, {}." . format(ctx.author.mention), color = 0xff9900)
embedVar.add_field(name=":fist: ROCK", value="React with :fist: emoji to choose rock.", inline = False)
embedVar.add_field(name=":hand_splayed: PAPER", value="React with :hand_splayed: emoji to choose paper.", inline = False)
embedVar.add_field(name=":v: SCISSORS", value="React with :v: emoji to choose scissors.", inline = False)
emb = await ctx.send(embed = embedVar)
for emoji in emojis:
await emb.add_reaction(emoji)
def chk(reaction):
return reaction.emb == emb and reaction.channel == ctx.channel
react = await client.wait_for('reaction_add', check=chk)
if react == '✊':
await ctx.send("You chose rock!")
elif react == '????️':
await ctx.send("You chose paper!")
elif react == '✌️':
await ctx.send("You chose scissors!")
我收到此错误:
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: chk() takes 1 positional argument but 2 were given
我尝试了许多修复方法,但都是徒劳的。
另外,我希望机器人只接受最初通过命令请求石头剪刀布游戏的用户(换句话说,消息的作者)的输入,但我不确定如何实现,我试过了,但是没有用。
我该如何解决这个问题?
【问题讨论】:
标签: discord.py