При использование components = Button.from_json выдает ошибку
Я, пытался реализовать вывод сообщения: контента, ембеда, и кнопок из библиотеки discord_components, от бота когда прикрепляют json файл к команде, но получил ошибку связанной, о ненайденного ключа "style"
Часть тестируемого кода:
import discord
import json
import os
from discord.ext import commands
from discord_components import DiscordComponents, Button, ButtonStyle
@client.command()
async def test(ctx):
with open(f"./test.json",'r') as f:
json_embed = json.load(f)
await ctx.channel.send(
content = json_embed["content"],
embed = discord.Embed.from_dict(json_embed),
components = Button.from_json(json_embed)
)
Содержимое json файла:
{
"content": "TEST",
"embeds": [
{
"description": "TEST",
"color": null
}
],
"components": [
{
"type": 1,
"components": [
{
"type": 2,
"label": "Test",
"style": 1
}
]
}
]
}
И сама ошибка:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "c:\Users\Admin\Desktop\test\test.py", line 27, in test
components = Button.from_json(json_embed)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord_components\button.py", line 162, in from_json
style=data["style"],
KeyError: 'style'
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\ext\commands\core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python38-32\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: KeyError: 'style'