core.utils¶
Module Contents¶
Classes¶
Text manipulation functions |
|
Time manipulation functions |
|
Helper functions for (mostly) guilded API actions. |
Attributes¶
- core.utils.tr¶
- core.utils.config¶
- class core.utils.Text¶
Text manipulation functions
- static sanitise(string: str, *, limit: int = 2000, escape: bool = True) str¶
Sanitise string.
- Parameters
string – A text string to sanitise.
limit – How many characters should be processed.
escape – Whether to escape characters (to prevent unwanted markdown).
- Returns
Sanitised string.
- static split(string: str, limit: int = 1990) List[str]¶
Split text into multiple smaller ones.
- Parameters
string – A text string to split.
limit – How long the output strings should be.
- Returns
A string split into a list of smaller lines with maximal length of
limit.
- static split_lines(lines: List[str], limit: int = 1990) List[str]¶
Split list of lines to bigger blocks.
- Parameters
lines – List of lines to split.
limit – How long the output strings should be.
- Returns
A list of strings constructed from
lines.
This works just as
split()does; the only difference is that this guarantees that the line won’t be split at half, instead of calling thesplit()onlinesjoined with newline character.
- class core.utils.Time¶
Time manipulation functions
- static id_to_datetime(snowflake_id: int) datetime.datetime¶
Convert snowflake ID to timestamp.
- static date(timestamp: datetime.datetime) str¶
Convert timestamp to date.
- static datetime(timestamp: datetime.datetime) str¶
Convert timestamp to date and time.
- class core.utils.Guilded¶
Helper functions for (mostly) guilded API actions.
- async static get_message(bot: guilded.ext.commands.Bot, guild_id: int, channel_id: int, message_id: int) Optional[guilded.Message]¶
Get message.
If the message is contained in bot cache, it is returned from it, to save API calls. Otherwise it is fetched.
- Parameters
bot – The
Botobject.guild_id – Guild ID.
channel_id – Channel ID.
message_id – Message ID.
- Returns
Found message or
None.
- static create_embed(error: bool = False, author: Union[guilded.Member, guilded.User] = None, **kwargs) guilded.Embed¶
Create guilded embed.
- Parameters
error – Whether the embed reports an error.
author – Event author.
kwargs – Additional parameters.
- Returns
The created embed.
If you supply
title,description,colororfooter, they will be included in the embed.
- async static send_help(ctx: guilded.ext.commands.Context) bool¶
Send help if no subcommand has been invoked.
- Parameters
ctx – The command context.
- Returns
Trueif the help was sent,Falseotherwise.
- async static delete_message(message: guilded.Message, delay: float = 0.0) bool¶
Try to remove message.
- Parameters
message – The message to be deleted.
delay – How long to wait, in seconds.
- Returns
Trueif the action was successful,Falseotherwise.
- async static remove_reaction(message: guilded.Message, emoji, member: guilded.Member) bool¶
Try to remove reaction.
- Parameters
message – The message of the reaction.
emoji – Emoji, Reaction, PartialEmoji or string.
member – The author of the reaction.
- Returns
Trueif the action was successful,Falseotherwise.