Скриншот фрагмента кода удалён модератором.
@tasks.loop(minutes = 10)
async def check_vc(self):
base = sqlite3.connect('cogs/base.db')
cur = base.cursor()
im = Image.open('bane.gif')
frames = []
ImageDraw.Draw(im)
guild = self.bot.get_guild(1084432275921453126)
vcusrs = sum(len(vc.members) for vc in guild.voice_channels)
vcount = ImageFont.truetype("chiller.ttf", 80)
guildount = ImageFont.truetype("chiller.ttf", 35)
nametext = ImageFont.truetype("chiller.ttf", 70)
for frame in ImageSequence.Iterator(im):
frame = frame.convert("RGBA")
d = ImageDraw.Draw(frame)
tp = cur.execute(f'SELECT userid FROM vchour ORDER BY time DESC LIMIT 1').fetchone()
if tp != None:
memb = await guild.fetch_member(tp[0])
name = memb.display_name
if len(name) > 7:
name = name[:7] + "..."
d.text((155, 215), name, (255, 255, 255), font=nametext)
avatar_image = Image.open(BytesIO(requests.get(memb.display_avatar).content)).resize((90, 90))
avatar_mask = Image.new('L', avatar_image.size, 0)
draw = ImageDraw.Draw(avatar_mask)
draw.ellipse((0, 0) + avatar_image.size, fill=225)
avatar_image.putalpha(avatar_mask)
for i in range(4):
frame.alpha_composite(avatar_image, (47, 209))
d.text((675, 250), str(vcusrs), (255, 255, 255), font=vcount)
d.text((340, 190), str(guild.member_count), (255, 255, 255), font=guildount)
b = io.BytesIO()
frame.save(b, format="GIF")
frame = Image.open(b)
frames.append(frame)
frames[0].save('out.gif', save_all=True, append_images=frames[1:])
with open("out.gif", 'rb') as f:
contents = f.read()
await guild.edit(banner = contents)
Task exception was never retrieved
future: <Task finished name='Task-26' coro=<Loop._loop() done, defined at C:\Program Files\Python311\Lib\site-packages\disnake\ext\tasks\__init__.py:146> exception=ValueError('images do not match')>
Traceback (most recent call last):
File "C:\Program Files\Python311\Lib\site-packages\disnake\ext\tasks\__init__.py", line 192, in _loop
raise exc
File "C:\Program Files\Python311\Lib\site-packages\disnake\ext\tasks\__init__.py", line 163, in _loop
await self.coro(*args, **kwargs)
File "E:\work\love\moder\cogs\banner.py", line 66, in check_vc
frame.alpha_composite(avatar_image, (47, 209))
File "C:\Program Files\Python311\Lib\site-packages\PIL\Image.py", line 1784, in alpha_composite
result = alpha_composite(background, overlay)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Program Files\Python311\Lib\site-packages\PIL\Image.py", line 3317, in alpha_composite
return im1._new(core.alpha_composite(im1.im, im2.im))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: images do not match