Команда должна просто отправлять изображние по команде в канал, но почему-то выдаёт ошибку.
@bot.command()
async def img(ctx):
base = Image.open('one.png').convert('RGBA')
font = ImageFont.truetype('UniSans-Trial-Bold.otf',13)
text = '999'
draw = ImageDraw.Draw(text)
draw.text((10, 10), text, font=font)
base.paste(base)
with io.BytesIO() as a:
base.save(a, 'PNG')
a.seek(0)
await ctx.send(file=discord.File(a,'Test.png'))
Ошибка:
Traceback (most recent call last):
File "C:\Users\Ноумем\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 788, in Draw
return im.getdraw(mode)
AttributeError: 'str' object has no attribute 'getdraw'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\Ноумем\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Ноумем\Desktop\Netzach\bot.py", line 41, in img
draw = ImageDraw.Draw(text)
File "C:\Users\Ноумем\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 790, in Draw
return ImageDraw(im, mode)
File "C:\Users\Ноумем\AppData\Local\Programs\Python\Python310\lib\site-packages\PIL\ImageDraw.py", line 58, in __init__
im.load()
AttributeError: 'str' object has no attribute 'load'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Ноумем\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Ноумем\AppData\Local\Programs\Python\Python310\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Ноумем\AppData\Local\Programs\Python\Python310\lib\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: AttributeError: 'str' object has no attribute 'load'