Почему так происходит, и как это исправить?
Мне в консоли пишет
File "bot.py", line 136
img = Image.new('RGBA', (400, 200), '#f00')
^
TabError: inconsistent use of tabs and spaces in indentation
Но вроде в коде всё нормально, и я не могу понять почему недостаёт пробелов, и где?
@bot.command(aliases = ["card"])
async def card_user(ctx):
await ctx.channel.purge(limit = 1)
img = Image.new('RGBA', (400, 200), '#f00')
url = str(ctx.author.avatar_url)[:-10]
r = requests.get(url, stream = True)
r = Image.open(io.BytesIO(r.content))
r = r.convert("RGBA")
r = r.resize((100, 100), Image.ANTIALIAS)
img.paste(r, (15, 15, 115, 115))
idraw = ImageDraw.Draw(img)
name = ctx.author.name
tag = ctx.author.discriminator
headline = ImageFont.truetype("arial.ttf", size = 20)
undertxt = 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 = undertxt)
img.save("user_card.png")
await ctx.send(file = discord.File(fp = "user_card.png"))
Ответы (1 шт):
Автор решения: FoGTeR
→ Ссылка
img = Image.new('RGBA', (400, 200), '#f00')
Удали перед ним все пробелы, аж до await ctx.channel.purge(limit = 1) что бы было img = Image.new('RGBA', (400, 200), '#f00')await ctx.channel.purge(limit = 1)
а потом поставь TAB перед img = Image.new('RGBA', (400, 200), '#f00')