Skip to content
Advertisement

Finding author of a message

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 though.

@client.command()
async def name(their_name):
    await client.say("{0}, your name is {1}.".format("""author of the message goes here""", their_name))

Advertisement

Answer

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
    ...
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement