Я пытаюсь изменить аватарку сервера
@bot.command()
async def del_avatar_name(ctx):
await ctx.guild.edit(name="NONAME SERVER")
with open(r'C:\Users\akkso\PycharmProjects\Crasher\image.png', 'rb') as f:
icon = f.read()
await ctx.guild.edit(icon=icon)
await ctx.message.delete()
Но почему-то выдаётся ошибка:
TracebackIgnoring exception in command del_avatar_name:
Traceback (most recent call last):
File "C:\Users\akkso\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\akkso\PycharmProjects\Crasher\main.py", line 98, in del_avatar_name
await ctx.guild.edit(icon=icon)
File "C:\Users\akkso\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\guild.py", line 1176, in edit
icon = utils._bytes_to_base64_data(icon_bytes)
File "C:\Users\akkso\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\utils.py", line 323, in _bytes_to_base64_data
mime = _get_mime_type_for_image(data)
File "C:\Users\akkso\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\utils.py", line 319, in _get_mime_type_for_image
raise InvalidArgument('Unsupported image type given')
discord.errors.InvalidArgument: Unsupported image type given
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\akkso\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\akkso\AppData\Local\Programs\Python\Python39\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\akkso\AppData\Local\Programs\Python\Python39\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: InvalidArgument: Unsupported image type given
Изображение рабочее, когда я вручную меняю аватарку сервера, всё работает, в чём проблема?