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.
- The bot has administrator rights on the server;
- 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
Answers:
There could be 2 reasons your bot is not working.
- 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.
- 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.
The problem was that I put the bot ID in the guild_id instead of the chat ID.
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.
- The bot has administrator rights on the server;
- 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
There could be 2 reasons your bot is not working.
- 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.
- 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.
The problem was that I put the bot ID in the guild_id instead of the chat ID.