How to fix it? "discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access"

Question:

I got this error after adding a slash to the command. What can this be connected with?
Information from google did not help at all.

  1. The bot has administrator rights on the server;
  2. I found information that the account must have MFA, turned it on – the error did not disappear.

my code is:

    from discord.ext import commands
    from discord import app_commands
    import asyncio
    
    from config import settings
    
    bot = commands.Bot(intents=discord.Intents.all(), command_prefix=settings['prefix'])
    
    class abot(discord.Client):
        def __init__(self):
            super().__init__(intents=discord.Intents.default())
            self.synced = False
        async def on_ready(self):
            await self.wait_until_ready()
            if not self.synced:
                await tree.sync(guild=discord.Object(id=settings['id'])) #error in this stroke
                self.synced = True
            print('ONLINE')
    
    bot = abot()
    tree = app_commands.CommandTree(bot)
    
    @tree.command(name='ping', description='Ping me', guild=discord.Object(id=settings['id']))
    async def self(interaction: discord.Integration):
        author = interaction.message.author
        await interaction.response.send_message(f'hello, {author.mention}')
        
    bot.run(settings['token'])

error is:

raise Forbidden(response, data)
discord.errors.Forbidden: 403 Forbidden (error code: 50001): Missing Access
Asked By: Hak

||

Answers:

There could be 2 reasons your bot is not working.

  1. The bot’s role may not be high enough in the role hierarchy. Go to the server your bot is in and go to settings. Then, go to roles and find the bot’s role. Move the role up to as high as it can go, above most other roles.
  2. You may have not enabled the correct Privileged Intents in the Discord Developer Portal. To fix this, go to the Discord Developer Portal, then find your bot and click on it, go to the bot tab and scroll down to Privileged Gateway Intents. Enable all of them just to check if your bot works after they are enabled.
Answered By: Jack Arsenfield

The problem was that I put the bot ID in the guild_id instead of the chat ID.

Answered By: Hak
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.