A Paginator class for managing embeds with pagination. It allows users to navigate through a list of embeds using buttons.
timeout
(int): How long the Paginator should timeout in, after the last interaction. (In seconds) (Overrides default of 60)previous_button
(disnake.ui.Button, optional): Overrides default previous button.next_button
(disnake.ui.Button, optional): Overrides default next button.trash_button
(disnake.ui.Button, optional): Overrides default trash button.page_counter_separator
(str, optional): The custom separator between the pages numbers in the page_counter button.page_counter_style
(disnake.ButtonStyle, optional): Overrides default page counter style.initial_page
(int, optional): Page to start the pagination on.on_timeout_message
(Optional[str], optional): Overrides defaulton_timeout
string set as embed footer. IfNone
, no message will appearon_timeout
.interaction_check
(bool, optional): Check whether the users interacting with the paginator are the owner of the command or not. Default set toTrue
.interaction_check_message
(Union[disnake.Embed, str], optional): The message to send when aninteraction_check
fails, e.g., a user who is not the command owner attempted to interact with the paginator. This feature can be disabled by settinginteraction_check
toFalse
.ephemeral
(bool, optional): Whether the paginator should only be visible to the command invocator or to anyone else.persistent
(bool, optional): Whether the paginator should persist across multiple sessions.
python setup.py build
python setup.py install
To use the Paginator
class, follow these steps:
- Create a list of embeds that you want to paginate.
- Instantiate the
Paginator
class, passing the list of embeds as theembeds
parameter. - Use await Paginator().start method.
from discord import ApplicationContext, SlashCommandGroup, Embed
from discord.ext import commands
from core.paginator import Paginator
class Page(commands.Cog):
def __init__(self, bot) -> None:
self.bot = bot
super().__init__()
page = SlashCommandGroup("page", "pages")
@page.command(name="test")
async def test(self, ctx:ApplicationContext):
embeds = [
Embed(
title="First embed"
),
Embed(
title="Second embed"
),
Embed(
title="Third embed"
),
]
await Paginator().start(ctx, pages=embeds)
def setup(bot):
bot.add_cog(Page(bot))