D
D
Denis QSTER2020-05-04 22:08:28
Python
Denis QSTER, 2020-05-04 22:08:28

Module 'io' has no attribute 'BytesID' how to fix?

Hello, I wanted to create a new command for the bot, but an error occurred module 'io' has no attribute 'BytesID' and I don't know how to fix it, please tell me the

code:
@client.command(aliases = ['me', 'my card', 'card'], description = "In development...")
async def LightCard(ctx):
await ctx.channel.purge(limit = 1)
img = Image.new('RGBA', (400, 200), ' #232529')
url = str(ctx.author.avatar_url)[:-10]

response = requests.get(url,stream = True)
response = Image.open(io.BytesID(response.content))
response = response. convert('RGBA')
response = response.sesize((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'ID: {ctx.author.id} ', font = undertext)

img.save('LightCard.png')

await ctx.send(file = discord.File(fp = 'LightCard.png'))

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey Gornostaev, 2020-05-04
@n__o_b_o_d_y

response = Image.open(io.BytesIO(response.content))

A
Alexander, 2020-05-05
@sanya84

This BytesID attribute is not in the io module , there is BytesIO
5eb08b6a10376058598708.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question