Ошибка при добавлении кнопок в слеш команде

Пишу своего бота на discord.py Столкнулся с проблемой - если функция это слеш команда то кнопки не могут добавиться.

вот функция:

    @cog_ext.cog_slash(
        name = "cash-lb",
        description = "cash leaderboard",
    )
    async def __leaderboard(self, ctx):
        count = 0
        responce = None
        msg = await ctx.send(embed = discord.Embed(
            description = "Please wait...", 
            colour = discord.Color.blurple()
        ))
        while True:
            try:

                emb = discord.Embed(
                    title = "-----------------\nCash leaderboard\n-----------------",
                    colour = discord.Color.blurple()
                )

                cursor.execute(f"SELECT id, cash FROM user ORDER BY cash DESC LIMIT {count * 5}, 5")
                num = count * 5 + 1
                for row in cursor.fetchall():
                    user = self.client.get_user(row[0])
                    emb.add_field(
                        name = f"#{num}: {user.name}",
                        value = f"cash: **{row[1]}** :coin:\n-----------------",
                        inline = False
                    )
                    num += 1

                await msg.edit(
                    embed = emb,
                    components = [
                        [
                            Button(style = ButtonStyle.blue, label = "Prev", emoji = "⬅️"),
                            Button(style = ButtonStyle.blue, label = "Next", emoji = "➡️")
                        ]
                    ]
                )
                if responce is not None:
                    await responce.edit_origin()

                responce = await self.client.wait_for('button_click', timeout = 10)
                
                if msg != responce.message:
                    pass
                elif responce.component.label == "Prev":
                    if count != 0:
                        count -= 1
                elif responce.component.label == "Next":
                    cursor.execute("SELECT COUNT(1) FROM user")
                    if (count*5)+5 < cursor.fetchone()[0]:
                        count += 1

            except asyncio.TimeoutError:
                pass

ошибка:

An exception has occurred while executing command `cash-lb`:
Traceback (most recent call last):
  File "D:\forWork\compiler\python\lib\site-packages\discord_slash\client.py", line 1353, in invoke_command
    await func.invoke(ctx, **args)
  File "D:\forWork\compiler\python\lib\site-packages\discord_slash\model.py", line 209, in invoke
    return await self.func(self.cog, *args, **kwargs)
  File "D:\forWork\MoonInc\MoonDiscoBot\cogs\cash.py", line 229, in __leaderboard
    await msg.edit(
  File "D:\forWork\compiler\python\lib\site-packages\discord_slash\model.py", line 595, in edit
    await super().edit(**fields)
  File "D:\forWork\compiler\python\lib\site-packages\discord\message.py", line 1111, in edit
    data = await self._state.http.edit_message(self.channel.id, self.id, **fields)
  File "D:\forWork\compiler\python\lib\site-packages\discord\http.py", line 156, in request
    kwargs['data'] = utils.to_json(kwargs.pop('json'))
  File "D:\forWork\compiler\python\lib\site-packages\discord\utils.py", line 328, in to_json
    return json.dumps(obj, separators=(',', ':'), ensure_ascii=True)
  File "D:\forWork\compiler\python\lib\json\__init__.py", line 234, in dumps
    return cls(
  File "D:\forWork\compiler\python\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "D:\forWork\compiler\python\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
  File "D:\forWork\compiler\python\lib\json\encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type Button is not JSON serializable

Ответы (0 шт):