Skip to main content

Colored Codeblocks - Discord

Colored Codeblocks for Discord Bots using ANSI Escape Sequences.

You can do help(discord_colorize.Colors) to see all the available colors along with a detailed docstring on how to use the package.

Usage -

    import discord_colorize
    colors = discord_colorize.Colors()
    data = f"""
    ```ansi
    {colors.colorize('Hello World!', fg='green', bg='indigo', bold=True, underline=True)}
    ```
    """
    help(discord_colorize.Colors)

Extra Information

Created by TheOnlyWayUp#1231 - https://github.com/TheOnlyWayUp/

class Colors:
    r"""Represents the class used for normal strings to Discord ANSI Codeblocks that support colors.

    Usage
    ----------------
    from discord.colorize import Colors
    colors = Colors()
    message = colors.colorize('Hello World!', fg='green', 'bg'='indigo', 'bold'=True)

    All Colors
    ----------------
    Foreground -
    ・gray - 30
    ・red - 31
    ・green - 32
    ・yellow - 33
    ・blue - 34
    ・pink - 35
    ・cyan - 36
    ・white - 37
    Background -
    ・darkBlue - 40
    ・orange - 41
    ・gray - 46
    ・lightGray - 43
    ・lighterGray - 44
    ・indigo - 45
    ・white - 47
    Formatting -
    ・bold - 1
    ・underline - 4
    ・default - 0

    Both the names of colors and styles (bold, gray, darkBlue, etc), and their integer equivalents (1, 30, 40) are accepted as valid inputs for colorization. Color names are not case-sensitive.
    """

    class unknownColor(Exception):
        """The unknown color class, this exception is raised when a color is not found."""
        ...

    def __init__(self):
        """Initializes the Colors class."""
        ...

    def returnColor(self, color: str, kind: str) -> int:
        """Returns the color code for the given color.

        Args:
            color (str): The color to return the code for.
            kind (str): The kind of color to return.

        Raises:
            self.unknownColor: Raised when the color is not found.

        Returns:
            int: The color code.
        """
        ...

    def colorize(
        self,
        text: str,
        bg: Union[str, int] = 0,
        fg: Union[str, int] = 0,
        bold: bool = 0,
        underline: bool = 0,
    ) -> str:
        """Returns a string with the ANSI color codes for the given parameters.

        Args:
            text (str): The text to colorize.
            bg (Union[str, int], optional): The background color to use. Defaults to no background.
            fg (Union[str, int], optional): The foreground color to use. Defaults to no foreground.
            bold (bool, optional): Whether or not to use bold. Defaults to no bold.
            underline (bool, optional): Whether or not to use underline. Defaults to no underline.

        Returns:
            str: The colorized string.
        """
        ...

Release files for discord-colorize 0.0.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for discord-colorize 0.0.8
File Size Uploaded
discord_colorize-0.0.8.tar.gz 3.6 kB Details

Release files / discord_colorize-0.0.8.tar.gz

Download URL discord_colorize-0.0.8.tar.gz
Size 3.6 kB
Tags Source
SHA-256 checksum
How to use checksums
2ee2a9a7e09fb663da5a0b88fc4419faceaddb260b7a51e31e0d25b6a839eae9
BLAKE2b-256 checksum
How to use checksums
0f481031fefba1037d737f8874a8a773cc449850d29d9fd606b1b4b3b04b1a9c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.7.0 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

Release history Release notifications | RSS feed

This release

0.0.8 This release

1 release file

0.0.7

1 release file

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page