discord.errors.Forbidden:403 FORBIDDEN(错误代码:50013):缺少权限

Nem*_*yer 4 python python-3.x discord.py

我最近创建了一个仅允许发送消息和读取消息历史记录的机器人。在我自己的服务器上,bot 似乎完美无缺,但是某个用户尝试在他自己的服务器上使用该 bot 并discord.errors.Forbidden: 403 FORBIDDEN (error code: 50013): Missing Permissions弹出错误。

await message.channel.send(file=discord.File(io.BytesIO(meme), filename="meme.png"))
Run Code Online (Sandbox Code Playgroud)

上面的行是导致错误的原因。我想我需要“附加文件”权限,但出于某种原因,它在我的测试服务器上没有它就可以工作。

完整追溯:

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
Run Code Online (Sandbox Code Playgroud)

小智 23

我的问题是,添加的角色比机器人的角色具有更高的优先级(即使有权限) - 因此它在角色列表中的位置更高。只需将其拖得更高就可以了!


小智 6

正如您所说,错误代码:50013表示您无权执行该操作。

ATTACH_FILES不是您必须拥有的唯一权限,您可能还需要SEND_MESSAGESVIEW_CHANNEL因为它们是“隐式权限”,请检查您是否也拥有它们。