NemPlayer
NemPlayer

Reputation: 846

discord.errors.Forbidden: 403 FORBIDDEN (error code: 50013): Missing Permissions

I've recently created a bot which is only allowed to send messages and read message history. In my own servers, the bot seemed to work flawlessly, but a certain user tried using the bot on his own server and the error discord.errors.Forbidden: 403 FORBIDDEN (error code: 50013): Missing Permissions popped up.

await message.channel.send(file=discord.File(io.BytesIO(meme), filename="meme.png"))

The line above is what's causing the error. I'm thinking that I need the 'Attach Files' permission, but for some reason it works without it on my testing servers.

Full traceback:

Traceback (most recent call last):
  File "/home/nemplayer/.local/lib/python3.7/site-packages/discord/client.py", line 270, in _run_event
    await coro(*args, **kwargs)
  File "bot/bot.py", line 78, in on_message
    await message.channel.send(file=discord.File(io.BytesIO(meme), filename="meme.png"))
  File "/home/nemplayer/.local/lib/python3.7/site-packages/discord/abc.py", line 806, in send
    content=content, tts=tts, embed=embed, nonce=nonce)
  File "/home/nemplayer/.local/lib/python3.7/site-packages/discord/http.py", line 218, in request
    raise Forbidden(r, data)
discord.errors.Forbidden: 403 FORBIDDEN (error code: 50013): Missing Permissions

Upvotes: 14

Views: 73211

Answers (4)

Camcrapb12
Camcrapb12

Reputation: 43

You need to move the bot's original role position above every other role/role you want to manage.

Upvotes: 1

Hwangowski
Hwangowski

Reputation: 371

my issue was that the added role had higher priority than the bot's role (even with permissions) - so it was higher in the role list. just drag it higher and it should work!

Upvotes: 37

KNTY
KNTY

Reputation: 457

I also experienced these kinds of issues while I was working on my project. to solve this issue, simply navigate to the Discord developer portal, pick OAuth2, select the URL Generator, set the bot permissions to Administrator, copy the link, and select your practice server, now have an access to all functionalities while developing your own bot.Discord Developer Portal

Upvotes: 0

Superpanchi
Superpanchi

Reputation: 91

As you said, error code: 50013 means that you don't have permission to perform that action.

ATTACH_FILES is not the only permission you must have, you may also need SEND_MESSAGES and VIEW_CHANNEL as they are "Implicit Permissions", check if you have them too.

Upvotes: 8

Related Questions