Finding author of a message

前端 未结 3 544
一生所求
一生所求 2021-01-20 14:49

If someone writes \"?name (arg)\" I want my bot to say the author of the message + \", your name is\" + arg. I can\'t find of the author of the message thou

相关标签:
3条回答
  • 2021-01-20 15:28

    To get the name of the author of the message, you will need to use context

    @client.command(pass_context=True)
    async def name(ctx):
        username = ctx.message.author.name
        ...
    
    0 讨论(0)
  • 2021-01-20 15:41

    You can also use User.display_name, which will try to to use the users server-specific nickname, but will fall back to the general username if that is not found:

    @client.command(pass_context=True)
    async def name(ctx):
        username = ctx.message.author.display_name
    
    0 讨论(0)
  • 2021-01-20 15:46

    To get the name of the author of the message you can use the:

    message.author.id
    
    0 讨论(0)
提交回复
热议问题