[Python] How to solve error 403 while using the Discord library in Python

Discussão em 'Python' iniciado por Stack, Fevereiro 14, 2025.

  1. Stack

    Stack Membro Participativo

    I am getting an error while executing the following code:

    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)


    I am getting this error on line 244:

    in wrapped raise CommandInvokeError(exc) from exc
    discord.ext.commands.errors.CommandInvokeError: Command raised an exception: Forbidden: 403 Forbidden (error code: 50013): Missing Permissions


    Maybe this is a line with a nickname change, but the bot has administrator functions enabled, so I don't even know what the error is.

    Continue reading...

Compartilhe esta Página