String Utilities API Reference

toolbox.strings.format_dt(time: datetime.datetime, style: Optional[str] = None) str[source]

Convert a datetime into a Discord timestamp. For styling see this link: https://discord.com/developers/docs/reference#message-formatting-timestamp-styles

Parameters
  • time (datetime.datetime) – The datetime to convert.

  • style (str, optional) – The style to use for the timestamp, by default None.

Returns

The formatted timestamp.

Return type

str

toolbox.strings.is_invite(string: str, *, fullmatch: bool = True) bool[source]

Returns True if the provided string is a Discord invite, otherwise False.

Parameters
  • string (str) – The string to check.

  • fullmatch (bool) – Whether to check if the string is a full match, by default True.

Returns

Whether the string is a Discord invite.

Return type

bool

toolbox.strings.is_url(string: str, *, fullmatch: bool = True) bool[source]

Returns True if the provided string is a valid http URL, otherwise False.

Parameters
  • string (str) – The string to check.

  • fullmatch (bool) – Whether to check if the string is a full match, by default True.

Returns

Whether the string is an URL.

Return type

bool

toolbox.strings.utcnow() datetime.datetime[source]

A short-hand function to return a timezone-aware utc datetime.

Returns

The current timezone-aware utc datetime.

Return type

datetime.datetime