如果有人写“?name (arg)”,我希望我的机器人说出消息的作者 + “,你的名字是” + arg。 但我找不到消息 的作者。
@client.command()
async def name(their_name):
await client.say("{0}, your name is {1}.".format("""author of the message goes here""", their_name))
最佳答案
要获取消息作者的姓名,您需要使用 context
@client.command(pass_context=True)
async def name(ctx):
username = ctx.message.author.name
...
关于python - 查找消息的作者,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/46611016/