Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bootstrap LinePaginator with trash emoji #261

Open
shtlrs opened this issue Jul 28, 2024 · 0 comments · May be fixed by #262
Open

Bootstrap LinePaginator with trash emoji #261

shtlrs opened this issue Jul 28, 2024 · 0 comments · May be fixed by #262

Comments

@shtlrs
Copy link
Member

shtlrs commented Jul 28, 2024

Currently, if we want to use bot core's paginator, and override the emojis, we need to add the following boiler plate module in the upstream client code.

from collections.abc import Sequence

import discord
from discord.ext.commands import Context
from pydis_core.utils.pagination import LinePaginator as _LinePaginator, PaginationEmojis

from src.settings import EMOJI


class LinePaginator(_LinePaginator):
    """
    A class that aids in paginating code blocks for Discord messages.

    See the super class's docs for more info.
    """

    @classmethod
    async def paginate(  # noqa: PLR0913
        cls,
        *,
        lines: list[str],
        ctx: Context | discord.Interaction,
        embed: discord.Embed,
        prefix: str = "",
        suffix: str = "",
        max_lines: int | None = None,
        max_size: int = 500,
        scale_to_size: int = 4000,
        empty: bool = True,
        restrict_to_user: discord.User | None = None,
        timeout: int = 300,  # noqa: ASYNC109
        footer_text: str | None = None,
        url: str | None = None,
        exception_on_empty_embed: bool = False,
        reply: bool = False,
        allowed_roles: Sequence[int] | None = None,
        **kwargs,  # noqa: ARG003
    ) -> discord.Message | None:
        """
        Use a paginator and set of reactions to provide pagination over a set of lines.

        Acts as a wrapper for the super class' `paginate` method to provide the pagination emojis by default.

        Consult the super class's `paginate` method for detailed information.
        """
        return await super().paginate(
            pagination_emojis=PaginationEmojis(delete=EMOJI.trashcan),
            lines=lines,
            ctx=ctx,
            embed=embed,
            prefix=prefix,
            suffix=suffix,
            max_lines=max_lines,
            max_size=max_size,
            scale_to_size=scale_to_size,
            empty=empty,
            restrict_to_user=restrict_to_user,
            timeout=timeout,
            footer_text=footer_text,
            url=url,
            exception_on_empty_embed=exception_on_empty_embed,
            reply=reply,
            allowed_roles=allowed_roles,
        )

It would be nice to bootstrap the paginaator with some preset emojis, since that's the think we mostly do.

@shtlrs shtlrs linked a pull request Jul 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant