微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

命令引发异常:TypeError: 'Image' object is not callable,请找人看看?

如何解决命令引发异常:TypeError: 'Image' object is not callable,请找人看看?

from PIL import Image
from io import BytesIO

...

@client.command()
async def rip(ctx,member:discord.Member=None):
    if not member:
        member = ctx.author
    
    rip = Image.open("rip.jpeg")
    
    asset = member.avatar_url_as(size=128)
    data = BytesIO(await asset.read())
    pfp = Image.open(data)
    
    pfp = pfp.resize((850,850))
    
    rip.paste(pfp (489,1169))
    
    rip.save("prip.jpg")
    
    await ctx.send(file = discord.File("prip.jpg"))

错误Command raised an exception: TypeError: 'Image' object is not callable

解决方法

也许你可以试试这个:

with open('my_image.png','rb') as f:
picture = discord.File(f)
await channel.send(file=picture)

它已经在 discord.py 中,所以你不需要导入任何东西(discor 除外

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。