bot.utils
#
Internal utilites.
Submodules#
Package Contents#
Classes#
Metaclass for ABCs meant to be implemented as Cogs. |
Functions#
|
Return index of n`th occurrence of `substring in string, or None if not found. |
|
Return True if string has at least count lines. |
|
Return base64 data with padding characters to ensure its length is a multiple of 4. |
|
Upload contents to the paste service. |
- class bot.utils.CogABCMeta(*args: Any, **kwargs: Any)[source]#
Bases:
discord.ext.commands.CogMeta
,abc.ABCMeta
Metaclass for ABCs meant to be implemented as Cogs.
- bot.utils.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.has_lines(string: str, count: int) bool [source]#
Return True if string has at least count lines.
- bot.utils.pad_base64(data: str) str [source]#
Return base64 data with padding characters to ensure its length is a multiple of 4.
- exception bot.utils.PasteTooLongError[source]#
Bases:
Exception
Raised when content is too large to upload to the paste service.
- exception bot.utils.PasteUploadError[source]#
Bases:
Exception
Raised when an error is encountered uploading to the paste service.
- async bot.utils.send_to_paste_service(http_session: aiohttp.ClientSession, contents: str, *, extension: str = '', max_length: int = MAX_PASTE_LENGTH) str [source]#
Upload contents to the paste service.
Add extension to the output URL. Use max_length to limit the allowed contents length to lower than the maximum allowed by the paste service.
Raise ValueError if max_length is greater than the maximum allowed by the paste service. Raise PasteTooLongError if contents is too long to upload, and PasteUploadError if uploading fails.
Return the generated URL with the extension.