Discord.py 重写机器人不会改变我的昵称

时间:2021-03-30 15:01:33

标签: python python-3.x discord discord.py

我一直在通过为我的小型朋友服务器构建一个 Discord 机器人来学习 Python 3.8。我希望我的朋友能够更改我的昵称,但 Discord 似乎不允许这样做,除非我给每个人相同的等级。

我的想法是给我的 bot 最高角色,让他们使用 bot 命令来更改我的昵称(这将是第二高的角色),但我收到以下错误:

Traceback (most recent call last):
  File "/home/cqqlguy/.local/lib/python3.8/site-packages/discord/client.py", line 333, in _run_event
    await coro(*args, **kwargs)
  File "/home/cqqlguy/CQQLBOT/CQQLBOT.py", line 516, in on_message
    await cqqluser.edit(nick = newnick)
  File "/home/cqqlguy/.local/lib/python3.8/site-packages/discord/member.py", line 601, in edit
    await http.edit_member(guild_id, self.id, reason=reason, **payload)
  File "/home/cqqlguy/.local/lib/python3.8/site-packages/discord/http.py", line 241, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50013): Missing Permissions

相关代码如下:


@bot.event
async def on_message(message):
    lowermess = message.content
    dMess = lowermess.lower()

    if dMess.startswith("$changenick "):
            newnick = lowermess.split(" ", 1)[1] #whatever the user enters after the command
            changeuser = guild.get_member(id) #id would be my user ID
            await changeuser.edit(nick = newnick)

这似乎适用于不是我的用户,但机器人被赋予了比每个人都更高的角色,所以我不确定为什么它没有为我改变它。

0 个答案:

没有答案