这是什么错误

问题描述 投票:0回答:1
import discord
from discord.ext import commands

intents = discord.Intents.default()
intents.members = True
intents.message_content = True


peoples = [
    {'Name': 'Artem', 'id': 'steamid:1234'},
    {'Name': 'Sergey', 'id': 'steamid:1434'},
    {'Name': 'Bogdan', 'id': 'steamid:1534'}
]

bot = commands.Bot(command_prefix='/', intents=intents)

@bot.event
async def on_ready():
    print(f'We have logged in as {bot.user.name}')

@bot.command()
async def accept(ctx, value: str):
    id_v = None
    print(value)
    print(f"Command 'accept' invoked by {ctx.author.name} ({ctx.author.id}) with argument {value}")

    for i in peoples:
        print(i['id'])
        if i['id'] == value:
            id_v = i
            print(id_v['id'])
            break

    if id_v is not None:
        new_nickname = str(id_v['Name'])
        print(new_nickname)
        await ctx.author.edit(nick=new_nickname)
        await ctx.send(f"{new_nickname} принято ✅")
        print(f"Nickname updated for {ctx.author.name}")

    else:
        await ctx.send(f"Значение {value} не найдено в списке.")

# Replace 'YOUR_BOT_TOKEN' with your actual bot token
token = ''

# Run the bot
bot.run(token)

第 244 行,已包裹 从 exc 引发 CommandInvokeError(exc) Discord.ext.commands.errors.CommandInvokeError:命令引发异常:禁止:403禁止(错误代码:50013):缺少权限

也许这是昵称更改的一行,但机器人启用了管理员功能,所以我什至不知道错误是什么。

python discord discord.py
1个回答
0
投票

即使启用了管理员权限,如果机器人的角色“低于”您要修改的成员的角色,机器人仍然可能没有足够的权限来更改某人的昵称。如果您要使用它,没有其他方法,只能将“Bot”角色拖到角色层次结构中的最高位置,高于包括“Owner”在内的所有其他角色。

以下是角色层次结构示例。

| Roles
  | Bot (higher than Owner, Head Admin, etc so I can change the nicknames of all of them, etc let them enjoy my service)
  | Owner
  | Head Admin
  | Moderator
  | Verified
  | @everyone

请记住,如果您没有正确配置机器人或泄漏令牌,将机器人置于高于所有角色的位置可能最终会导致严重的安全问题。

© www.soinside.com 2019 - 2024. All rights reserved.