How to change nickname (discord.py)

老子叫甜甜 提交于 2020-04-28 10:52:35

问题


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)


回答1:


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.




回答2:


See documentation there and change nickname via await member.edit(nick="New Nickname"). Or show your code.



来源:https://stackoverflow.com/questions/59340143/how-to-change-nickname-discord-py

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!