Home > database >  Center number of pages Discord Bot
Center number of pages Discord Bot

Time:11-05

I'm currently having a problem to center the number of pages between the navigation buttons

he ends up being like this

But whenever I change pages, It goes to the direction I click the navigation button

I use the pycord lib for the navigation buttons, the code looks like this:

    @commands.slash_command()
    async def help(self, ctx):
      """
      Mostrar a página de ajuda.
      """
      paginator = pages.Paginator(
          pages=self.pages, show_disabled=False)
      await paginator.respond(ctx.interaction, ephemeral=False)
      await Session.delete_message(self, ctx, 60)

I can't imagine how to use it without creating the navigation buttons myself, so the question is, is it possible to do this using the pycord lib?

CodePudding user response:

I arrived at the solution, instantiating the buttons directly in the function

@commands.slash_command()
async def help(self, ctx: discord.ApplicationContext):
    """
    Mostrar a página de ajuda.
    """
    paginator = pages.Paginator(
        pages=self.pages,
        use_default_buttons=False,
        loop_pages=False,
        show_disabled=False,
    )
    paginator.add_button(
        pages.PaginatorButton(
            "prev", label="<", style=discord.ButtonStyle.green, loop_label="lst"
        )
    )
    paginator.add_button(
        pages.PaginatorButton(
            "page_indicator", style=discord.ButtonStyle.gray, disabled=True
        )
    )
    paginator.add_button(
        pages.PaginatorButton(
            "next", style=discord.ButtonStyle.green, loop_label="fst"
            )
        )
        await paginator.respond(ctx.interaction, ephemeral=False)

API about

  • Related