@NeW_CodeR
Аферюга

Опять проблема с PIL, что же тут не так?

# -*- coding: utf-8 -*-
import discord
from PIL import Image, ImageFilter, ImageDraw, ImageFont
from discord.ext import commands
import io

client = discord.ext.commands.Bot( command_prefix = '%', case_insensitive=True, intents = discord.Intents.all())
client.remove_command('help')
@client.event
async def on_ready():
    print(" Фото-карточный бот пашет вновь")
    await client.change_presence(activity=discord.Activity(type=discord.ActivityType.watching, name="%карточка"))

@client.command(aliases=['карточка', 'карта', 'фото'])
async def __card(ctx):
    img = Image.new('RGBA', (400, 200), '#9ad4f5')
    url = str(ctx.author.avatar_url)[:-10]
    response = requests.get(url, stream = True)
    response = Image.open(io.BytesIO(response.content))
    response = response.convert('RGBA')
    response = response.resize((100, 100), Image.ANTIALIAS)
    img.paste(response, (15, 15, 115, 115))
    idraw = ImageDraw.Draw(img)
    name = ctx.author.name
    tag = ctx.author.discriminator
    headline = ImageFont.truetype('arial.ttf', size = 20)
    undertext = ImageFont.truetype('arial.ttf', size = 12)
    idraw.text((145, 15), f'**{name}#{tag}**', font = headline)
    idraw.text((145, 50), f'{ctx.author.id}', font = undertext)
    img.save('D:/не_трогать/card.png')
    await ctx.send(file = discord.File(fp = 'D:/не_трогать/card.png'))

А ОШИБКА ТУТ:
File "C:\Users\admin\AppData\Local\Programs\Python\Python37\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: NameError: name 'requests' is not defined
  • Вопрос задан
  • 83 просмотра
Решения вопроса 1
GavriKos
@GavriKos
Ну вот откуда скопипастили код - там посмотрите импорты. У вас их нехватает.
Ответ написан
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы