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

时间:2021-04-12 14:38:54

标签: python image discord.py python-imaging-library

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

1 个答案:

答案 0 :(得分:0)

也许你可以试试这个:

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

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