问题
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