Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

python - 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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...