Skip to content

utils

Utility functions for the help command system.

This module contains utility functions for formatting, categorizing, and navigating help command content.

Functions:

Functions

format_multiline_description

Python
format_multiline_description(text: str | None) -> str

Format a multiline description with quote formatting for each line.

Parameters:

  • text (str | None) –

    The text to format.

Returns:

  • str

    The formatted text with > prepended to each line.

truncate_description

Python
truncate_description(text: str, max_length: int = 100) -> str

Truncate a description to a maximum length.

Parameters:

  • text (str) –

    The text to truncate.

  • max_length (int, default: 100 ) –

    Maximum length before truncation, by default 100.

Returns:

  • str

    The truncated text with ellipsis if needed.

paginate_items

Python
paginate_items(items: list[Any], page_size: int) -> list[list[Any]]

Split items into pages of specified size.

Parameters:

  • items (list[Any]) –

    The items to paginate.

  • page_size (int) –

    Maximum number of items per page.

Returns:

  • list[list[Any]]

    A list of pages, each containing up to page_size items.

create_cog_category_mapping

Python
create_cog_category_mapping(
    mapping: Mapping[Cog | None, list[Command[Any, Any, Any]]],
) -> tuple[dict[str, dict[str, str]], dict[str, dict[str, Command[Any, Any, Any]]]]

Create a mapping of command categories and commands.

Parameters:

Returns:

extract_cog_group

Python
extract_cog_group(cog: Cog) -> str | None

Extract the cog group from a cog's module path.

Parameters:

  • cog (Cog) –

    The cog to extract the group from.

Returns:

  • str | None

    The group name or None if no group found.

get_cog_groups

Python
get_cog_groups() -> list[str]

Retrieve a list of module groups from the 'modules' folder.

Returns:

  • A list of module group names.

is_large_command_group

Python
is_large_command_group(command: Group[Any, Any, Any]) -> bool

Check if a command group is large and needs special handling.

Parameters:

Returns:

  • bool

    True if the command group is large, False otherwise.