我试图在discord.py中创建一个图像操作命令,我希望它能够获取用户发送的图像并将其粘贴到另一个图像中,但每次都会导致discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: a bytes-like object is required, not 'int'"
这是我的密码:
@client.command()
async def procureajuda(ctx):
pessoa = (ctx.message.attachments[0])
hm = (pessoa)
hm = (await hm.save(fp = 'ha.png', seek_begin = False, use_cached = False))
h = BytesIO (hm)
hm = Image.open (h)
template = Image.open ("E:/Projetos/Copper/templates/procure ajuda.png")
hm = hm.resize ((360,201))
template.paste (hm, (0,0))
template.save("pro.png")
await ctx.send(file = discord.File("pro.png"))
我试着去掉BytesIO部分(因为我不知道还能做什么),结果出现了一个不同的错误,比如'int' object has no attribute 'read'
编辑:对不起,忘了回溯
Ignoring exception in command procureajuda:
Traceback (most recent call last):
File "E:\programas 2\python 3.9\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "E:\Projetos\Copper\copper.py", line 78, in procureajuda
h = BytesIO (hm)
TypeError: a bytes-like object is required, not 'int'
discord发送支持io.BuffereDiabase作为参数。 您可以使用io.BytesIO尝试以下操作:
相关问题 更多 >
编程相关推荐