首页 > 解决方案 > discord.py/PIL 发送图像/gif 文件错误 50006

问题描述

我正在处理 discord.py plus PIL 上的一些图像/gif 文件,但有时当我尝试从文件发送图像/gif 时,它会给我这个错误:

Ignoring exception in command battle:
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 85, in wrapped
    ret = await coro(*args, **kwargs)
  File "./discordbot.py", line 1487, in battle
    await battlevs(ctx, int(o))
  File "./discordbot.py", line 1838, in battlevs
    await ctx.send(file=file)
  File "/usr/local/lib/python3.6/site-packages/discord/abc.py", line 1047, in send
    message_reference=reference)
  File "/usr/local/lib/python3.6/site-packages/discord/http.py", line 254, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/bot.py", line 939, in invoke
    await ctx.command.invoke(ctx)
  File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 863, in invoke
    await injected(*ctx.args, **ctx.kwargs)
  File "/usr/local/lib/python3.6/site-packages/discord/ext/commands/core.py", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: HTTPException: 400 Bad Request (error code: 50006): Cannot send an empty message

(该文件在一个名为battlevs 的函数中发送) 我的源代码大约有200 行,所以除非真的需要,否则我不会在这里发布它。请帮忙。

标签: pythondiscord.pypython-imaging-library

解决方案


推荐阅读