Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change nickname (discord.py)

I want to make a command that changes a nickname to a specific user (Let it be Example # 1234). This command accepts an argument in which a new nickname must be entered, to which the old nickname must be changed - g!Chnick "ExampleNick". I do not know how to change the nickname to users of the Discord server, I tried it through the Guild class, I tried it through the Member class. (Sorry for bad english)

like image 215
eax-ebx Avatar asked Dec 05 '22 09:12

eax-ebx


1 Answers

It's not hard! For example you can use:

@client.command(pass_context=True)
async def chnick(ctx, member: discord.Member, nick):
    await member.edit(nick=nick)
    await ctx.send(f'Nickname was changed for {member.mention} ')

Don't forget a important thing, bot MUST have a permission for changing nicknames and can't change server owner nickname. Test it on other bots or members of server

My advice for you is reading discord.py documentation.

like image 156
Clonexy Avatar answered Dec 10 '22 11:12

Clonexy