【发布时间】:2021-04-06 07:38:06
【问题描述】:
我正在使用 Pillow 处理图像,然后想将其发送到 Discord。我的代码:https://paste.pythondiscord.com/comebefupo.py
使用 image.show() 时,处理后的图像显示良好。
但是,当我想将图像上传到 Discord 时,机器人卡住并且没有抛出错误:
got bytes from direct image string
got bytes from member/user pfp or str
opened image
opened draw
drew top text
drew bottom text
prepared buffer
prepared file
# Bot just gets stuck here, no errors
根据多个来源(1、2),我正在做正确的事情,将图像保存到 BytesIO 流中,然后使用seek(0)。
根据不和谐文件的documentation,它需要一个io.BufferedIOBase,这是(我相信)我输入的。
编辑: 首先保存图像,然后发送。
# Return whole image object
return image
self.convert_bytes(image_bytes, top_text, bottom_text).save('image.png')
await ctx.send(file=discord.File('image.png'))
我不知道为什么会这样,而另一件事却没有......
【问题讨论】:
标签: python-3.x discord.py bytesio