【问题标题】:discord bot AFK commanddiscord bot AFK 命令
【发布时间】:2021-03-17 10:14:40
【问题描述】:

所以我正在尝试执行 AFK 命令,但昵称不起作用。这是我的代码。

@Client.command(name="AFK")
async def afk(context):
    name = context.author.display_name
    author = context.author
    guild = context.guild
    AFKrole = discord.utils.get(guild.roles, name="AFK")
    if not AFKrole:
        AFKrole = await guild.create_role(name="AFK")
    await context.member.edit(nick=f"[AFK]{name}")
    await author.add_roles(AFKrole)
    await context.send(f"I have added {author} to AFK.")

【问题讨论】:

  • 嗯,这是因为bot无权更改公会所有者的昵称。您必须创建备用帐户并在其上尝试此命令。

标签: python-3.x discord.py


【解决方案1】:

试试:

await ctx.author.edit(nick=f'[AFK]{name}') #ctx = context, but you can change it to context

或尝试授予它 manage_nicknames 权限。
click here

【讨论】:

  • 对不起,它不够详细,因为你想要它给我(也许)
猜你喜欢
  • 2020-12-20
  • 2018-03-04
  • 1970-01-01
  • 2020-10-25
  • 2018-10-21
  • 2021-03-01
  • 1970-01-01
  • 2021-04-11
  • 2021-01-21
相关资源
最近更新 更多