Reputation: 19
Right now this is the current code I am using:
@client.command(pass_context=True)
async def nname(ctx, member: discord.Member, nick):
name = member.display_name
await member.edit(nick= name + ' (' + nick + ')')
await ctx.send(f'Nickname was changed for {member.mention} ')
So what it does is when someone enters .nname Username nickname it'll update their nickname to have their chosen nickname in parentheses. Is there a way I can get whoever is calling the .nname() functions username and edit their nickname for the server without having them enter their own username first? So end result they can just do .nname nickname and it will just update to Username (nickname)
Upvotes: 0
Views: 85
Reputation: 3592
You can define the member
as the author of the message, so do the following:
@client.command(pass_context=True)
async def nname(ctx, nick):
member = ctx.message.author # Member is now the author of the message
name = member.display_name
await member.edit(nick= name + ' (' + nick + ')')
await ctx.send(f'Nickname was changed for {member.mention} ')
Upvotes: 2