ILLEST Developers

illest.py 2.3.1

Utilities

Read from the library itself: every signature and every word here is its own docstring.

utils

module

illest.utils

Small things a bot author reaches for: logging set up the usual way, and the time an id or a timestamp names.

setup_logging

setup_logging(*, handler: 'logging.Handler | None' = None, level: 'int' = 20, root: 'bool' = True) -> 'None'

Send the library's log (and, with root, the program's) to the terminal, timestamped, at level.

Does nothing when the program has already given the root logger a handler: its own configuration wins. Client.run calls this unless told log_handler=None.

utcfromtimestamp

utcfromtimestamp(seconds: 'float') -> '_dt.datetime'

A server timestamp (whole seconds since the epoch) as an aware UTC datetime.

find

find(predicate: '_Callable[[_T], _Any]', iterable: '_Iterable[_T]') -> '_T | None'

The first element predicate is true for, or None.

get

get(iterable: '_Iterable[_T]', /, **attrs: '_Any') -> '_T | None'

The first element whose attributes match every keyword; __ reaches into one (get(members, top_role__name="Mod")).

aget

async
async aget(iterable: '_AsyncIterable[_T]', /, **attrs: '_Any') -> '_T | None'

oauth_url

oauth_url(client_id: 'int | str', *, permissions: '_Any' = ..., guild: '_Any' = ..., redirect_uri: 'str' = ..., scopes: '_Iterable[str]' = ..., disable_guild_select: 'bool' = False, state: 'str' = ...) -> 'str'

The link that adds a bot to a server: the person opens it, picks a server they manage, and the bot joins it with a role holding permissions. client_id is the bot's user id (the portal shows it as the application id).

utcnow

utcnow() -> '_dt.datetime'

format_dt

format_dt(dt: '_dt.datetime', /, style: 'str | None' = None) -> 'str'

A time as the app shows it in each reader's own zone: <t:seconds:style> (styles t T d D f F R).

sleep_until

async
async sleep_until(when: '_dt.datetime', result: '_T | None' = None) -> '_T | None'

compute_timedelta

compute_timedelta(dt: '_dt.datetime') -> 'float'

escape_markdown

escape_markdown(text: 'str', *, as_needed: 'bool' = False, ignore_links: 'bool' = True) -> 'str'

remove_markdown

remove_markdown(text: 'str', *, ignore_links: 'bool' = True) -> 'str'

escape_mentions

escape_mentions(text: 'str') -> 'str'

as_chunks

as_chunks(iterator: '_Iterable[_T]', max_size: 'int') -> '_Iterable[list[_T]]'

maybe_coroutine

async
async maybe_coroutine(f: '_Callable[..., _Any]', *args: '_Any', **kwargs: '_Any') -> '_Any'

raw_mentions

raw_mentions(text: 'str') -> 'list[int]'

raw_role_mentions

raw_role_mentions(text: 'str') -> 'list[int]'

raw_channel_mentions

raw_channel_mentions(text: 'str') -> 'list[int]'

resolve_invite

resolve_invite(invite: '_Any') -> 'str'