Skip to content

khk4912/EZPaginator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

66 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

EZPaginator

Python version discord.py version Monthly donwload count

Easy-to-use pagination library for discord.py

Install

pip3 install EZPaginator

Usage

Parameters

Parameter Type Description
context Context | Interaction Context or Interaction object.
embeds list[Embed] List of embed contents, by default [].
contents list[str] List of message contents, by default [].
If both embeds and contents are given, Paginator will paginate only embeds.
timeout int Timeout of the paginator, by default 30
start_index int Start index of embeds/contents, by default 0.
auto_clear_emoji bool Whether to clear the emoji when the pagination is stopped by function stop() or timeout. by default True.
This might need 'manage message' permission.
auto_delete_message bool Whether to delete the message when the pagination is stopped by function stop() or by timeout. by default False.
use_extend bool Whether to use the extended emoji set(First, Previous, Next, Last). by default False.
emojis list[str | Emoji] List of emojis to use for pagination. by default ["⬅️", "➡️"]
extended_emojis list[str | Emoji] List of extended emojis to use for pagination. by default ["⏪", "⬅️", "➡️", "⏩"] only : User | None, optional
only discord.abc.User | None Restrict only the user to use the pagination. by default None.
auto_fill_index bool Enable auto-fill index mode, by default False.

Example

Click to expand example

Basic Emebd Pagination

## Commands
@bot.command()
async def test(ctx: commands.Context) -> None:
    embeds = [
        discord.Embed(title="TEST 1", description="Page 1", color=discord.Color.red()),
        discord.Embed(title="TEST 2", description="Page 2", color=discord.Color.blue()),
        discord.Embed(title="TEST 3", description="Page 3", color=discord.Color.gold()),
    ]

    page = Paginator(ctx, embeds=embeds)
    await page.start()


## Slash Commands
@bot.tree.command()
async def slash_embed(interaction: discord.Interaction):
    embeds = [
        discord.Embed(title="TEST 1", description="Page 1", color=discord.Color.red()),
        discord.Embed(title="TEST 2", description="Page 2", color=discord.Color.blue()),
        discord.Embed(title="TEST 3", description="Page 3", color=discord.Color.gold()),
    ]

    page = Paginator(interaction, embeds=embeds)
    await page.start()
Commands Slash Command

Text Pagination W/ Extended Emojis

## Commands
@bot.command()
async def test(ctx: commands.Context) -> None:
    contents = ["This is Page 1", "This is Page 2", "This is Page 3"]

    page = Paginator(ctx, contents=contents, use_extend=True)
    await page.start()


## Slash Commands
@bot.tree.command()
async def slash_content(interaction: discord.Interaction) -> None:
    contents = ["This is Page 1", "This is Page 2", "This is Page 3"]

    page = Paginator(interaction, contents=contents, use_extend=True)
    await page.start()
Commands Slash Command

Use Custom Emoji

## Commands
@bot.command()
async def test(ctx: commands.Context) -> None:
    embeds = [
        discord.Embed(title="TEST 1", description="Page 1", color=discord.Color.red()),
        discord.Embed(title="TEST 2", description="Page 2", color=discord.Color.blue()),
        discord.Embed(title="TEST 3", description="Page 3", color=discord.Color.gold()),
    ]

    page = Paginator(ctx, embeds=embeds, emojis=["⬇️", "⬆️"])
    await page.start()


## Slash Commands
@bot.tree.command()
async def slash_content(interaction: discord.Interaction) -> None:
    contents = ["This is Page 1", "This is Page 2", "This is Page 3"]

    page = Paginator(
        interaction,
        contents=contents,
        use_extend=True,
        extended_emojis=["⏬", "⬇️", "⬆️", "⏫"],
    )
    await page.start()
Commands w/ custom emojis Slash Command w/ extended custom emojis

Auto-fill Index mode

If auto_fill_index is True, {current_page} and {total_pages} will be automatically filled with the current page and total pages.

@bot.command()
async def test(ctx: commands.Context) -> None:
    embeds = [
        discord.Embed(
            title="Hello ({current_page} / {total_pages})",
            description="World",
        ),
        discord.Embed(
            title="Wow ({current_page} / {total_pages})",
            description="Current page is {current_page}",
        ),
    ]

    for i in embeds:
        i.set_footer(text="Page {current_page} of {total_pages}")

    page = Paginator(
        ctx,
        embeds=embeds,
        auto_fill_index=True,
    )
    await page.start()

Contacts

BGM#0970

License

MIT License

About

Easy-to-use pagination library for discord.py

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages