问题描述
我想执行一个将昵称更改为特定用户的命令(让它成为示例#1234).该命令接受一个参数,在该参数中必须输入新的昵称,并且必须将旧的昵称更改为-g!Chnick"ExampleNick".我不知道如何为Discord服务器的用户更改昵称,我通过Guild类进行了尝试,通过Member类进行了尝试.(对不起,英语不好)
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)
推荐答案
这并不难!例如,您可以使用:
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
我的建议是阅读discord.py文档.
My advice for you is reading discord.py documentation.
这篇关于如何更改昵称(discord.py)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!