Здраствуйте! Я хочу перейти на
discord_slash. До перехода у меня работала библиотека
discord_components. Но после того как я перешёл на слеши всё компоненты не хотят отображается. И у меня выдаёт вот такую ошибку (Основная библиотека: discord.py):
An exception has occurred while executing command `help`:
Traceback (most recent call last):
File "C:\Users\Administrator\PycharmProjects\bot\venv\lib\site-packages\discord_slash\client.py", line 1353, in invoke_command
await func.invoke(ctx, **args)
File "C:\Users\Administrator\PycharmProjects\bot\venv\lib\site-packages\discord_slash\model.py", line 210, in invoke
return await self.func(*args, **kwargs)
File "C:\Users\Administrator\PycharmProjects\bot\main.py", line 1246, in help
await cx.send(embed=embed,
File "C:\Users\Administrator\PycharmProjects\bot\venv\lib\site-packages\discord_slash\dpy_overrides.py", line 323, in send_override
return await send(channel, *args, **kwargs)
File "C:\Users\Administrator\PycharmProjects\bot\venv\lib\site-packages\discord_slash\dpy_overrides.py", line 300, in send
data = await state.http.send_message(
File "C:\Users\Administrator\PycharmProjects\bot\venv\lib\site-packages\discord\http.py", line 156, in request
kwargs['data'] = utils.to_json(kwargs.pop('json'))
File "C:\Users\Administrator\PycharmProjects\bot\venv\lib\site-packages\discord\utils.py", line 328, in to_json
return json.dumps(obj, separators=(',', ':'), ensure_ascii=True)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\__init__.py", line 238, in dumps
**kw).encode(obj)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 199, in encode
chunks = self.iterencode(o, _one_shot=True)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 257, in iterencode
return _iterencode(o, 0)
File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\json\encoder.py", line 179, in default
raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Select is not JSON serializable
Помогите пожалуйста! Весь интернет переискал и все варианты перепробовал. Сам код:
@slash.slash(
name="help",
description="просмотр списка команд"
)
async def help(ctx: SlashContext):
# await ctx.defer(hidden=False)
cx = ctx.channel
embed=discord.Embed(
title=f"Test",
description=f"Test",
color=0xA700FF
)
await ctx.send("Test")
await cx.send(embed=embed,
components=[
Select(
placeholder='Test',
options=[
SelectOption(label="Test", emoji="️", value=1),
SelectOption(label="Test", emoji="", value=2)
]
)
]
)
@bot.command()
async def on_select_option(interaction):
if interaction.values[0] == 1:
embed1=discord.Embed(
title="скоро..."
)
await interaction.send(embed=embed1)
elif interaction.values[0] == 2:
embed2=discord.Embed(
title="скоро..."
)
await interaction.send(embed=embed2)
else:
pass