Код:
@bot.command() #22
async def change_banner(ctx):
file = discord.File('my_image.png')
await ctx.send(file = file)
await ctx.guild.edit(banner = file) # При помощи метода read() читаем изображение, и ставим его как баннер на сервере
os.remove(file) # Удаляем скачанное изображение
Ошибка:
Ignoring exception in command change_banner:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/container/bot.py", line 1923, in change_banner
await ctx.guild.edit(banner = file) # При помощи метода read() читаем изображение, и ставим его как баннер на сервере
File "/home/container/.local/lib/python3.9/site-packages/discord/guild.py", line 1186, in edit
banner = utils._bytes_to_base64_data(banner_bytes)
File "/home/container/.local/lib/python3.9/site-packages/discord/utils.py", line 323, in _bytes_to_base64_data
mime = _get_mime_type_for_image(data)
File "/home/container/.local/lib/python3.9/site-packages/discord/utils.py", line 310, in _get_mime_type_for_image
if data.startswith(b'\x89\x50\x4E\x47\x0D\x0A\x1A\x0A'):
AttributeError: 'File' object has no attribute 'startswith'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/home/container/.local/lib/python3.9/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/home/container/.local/lib/python3.9/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: AttributeError: 'File' object has no attribute 'startswith'
Ошибка в
await ctx.guild.edit(banner = file)
Смысл команды в том что должен ставится баннер на сервер (30 бустов есть)