bot.utils.helpers#

Helper utils.

Module Contents#

Classes#

CogABCMeta

Metaclass for ABCs meant to be implemented as Cogs.

Functions#

find_nth_occurrence(→ int | None)

Return index of n`th occurrence of `substring in string, or None if not found.

has_lines(→ bool)

Return True if string has at least count lines.

pad_base64(→ str)

Return base64 data with padding characters to ensure its length is a multiple of 4.

remove_subdomain_from_url(→ str)

Remove subdomains from a URL whilst preserving the original URL composition.

suppress_links(→ str)

Accept a message that may contain links, suppresses them, and returns them.

class bot.utils.helpers.CogABCMeta(*args: Any, **kwargs: Any)[source]#

Bases: discord.ext.commands.CogMeta, abc.ABCMeta

Metaclass for ABCs meant to be implemented as Cogs.

bot.utils.helpers.find_nth_occurrence(string: str, substring: str, n: int) int | None[source]#

Return index of n`th occurrence of `substring in string, or None if not found.

bot.utils.helpers.has_lines(string: str, count: int) bool[source]#

Return True if string has at least count lines.

bot.utils.helpers.pad_base64(data: str) str[source]#

Return base64 data with padding characters to ensure its length is a multiple of 4.

bot.utils.helpers.remove_subdomain_from_url(url: str) str[source]#

Remove subdomains from a URL whilst preserving the original URL composition.

Accept a message that may contain links, suppresses them, and returns them.