我正在尝试编写一个简单的机器人,该机器人可以通过键入如下命令来更改人们的姓名
remote: Could not find a version that satisfies the requirement
werkzeug.utils (from -r
/tmp/build_76ae13b60ea2d97b6932e1f7934aba42/requirements.txt (line 4))
(from versions: )
remote: No matching distribution found for werkzeug.utils (from -r
/tmp/build_76ae13b60ea2d97b6932e1f7934aba42/requirements.txt (line 4))
remote: ! Push rejected, failed to compile Python app.
remote:
remote: ! Push failed
remote: Verifying deploy...
remote:
remote: ! Push rejected to stormy-everglades-84084.
remote:
To https://git.heroku.com/stormy-everglades-84084.git
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/stormy-everglades-84084.git'
当前我已经编写了此功能
.name @Someone new_nickname
但是,现在调用此命令的唯一方法是将新昵称放在被标记的人之前,就像这样:
@client.command(process_context=True)
async def name(ctx, *, member: discord.Member):
print('{}'.format(member))
await client.change_nickname(member, 'new_name')
所以我的问题是,我该如何编写此功能以允许我先标记此人,然后再写昵称?
答案 0 :(得分:1)
它是pass_context
,而不是process_context
。您只需要将member
参数放在新名称的仅关键字参数之前:
@client.command(pass_context=True)
async def name(ctx, member: discord.Member, *, new_name):
await client.change_nickname(member, new_name)