From 3fadab97da89e6733e2f5ee41fadd7be4cd0c77c Mon Sep 17 00:00:00 2001 From: ChrisLovering Date: Sat, 30 Mar 2024 10:40:40 +0000 Subject: Deploying to docs from @ python-discord/bot-core@88c2eb6a2f065ee6055db0cf4533065cc95c87c4 🚀 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- v11.1.0/output/pydis_core.async_stats.html | 510 +++++++++ v11.1.0/output/pydis_core.exts.html | 452 ++++++++ v11.1.0/output/pydis_core.html | 1081 ++++++++++++++++++++ v11.1.0/output/pydis_core.site_api.html | 648 ++++++++++++ v11.1.0/output/pydis_core.utils.caching.html | 524 ++++++++++ v11.1.0/output/pydis_core.utils.channel.html | 520 ++++++++++ v11.1.0/output/pydis_core.utils.checks.html | 592 +++++++++++ v11.1.0/output/pydis_core.utils.commands.html | 493 +++++++++ v11.1.0/output/pydis_core.utils.cooldown.html | 543 ++++++++++ ...dis_core.utils.error_handling.commands.abc.html | 515 ++++++++++ .../pydis_core.utils.error_handling.commands.html | 583 +++++++++++ ...core.utils.error_handling.commands.manager.html | 511 +++++++++ .../output/pydis_core.utils.error_handling.html | 521 ++++++++++ v11.1.0/output/pydis_core.utils.function.html | 604 +++++++++++ v11.1.0/output/pydis_core.utils.html | 695 +++++++++++++ v11.1.0/output/pydis_core.utils.interactions.html | 593 +++++++++++ v11.1.0/output/pydis_core.utils.lock.html | 597 +++++++++++ v11.1.0/output/pydis_core.utils.logging.html | 530 ++++++++++ v11.1.0/output/pydis_core.utils.members.html | 506 +++++++++ v11.1.0/output/pydis_core.utils.messages.html | 483 +++++++++ v11.1.0/output/pydis_core.utils.pagination.html | 612 +++++++++++ v11.1.0/output/pydis_core.utils.paste_service.html | 613 +++++++++++ v11.1.0/output/pydis_core.utils.regex.html | 503 +++++++++ v11.1.0/output/pydis_core.utils.scheduling.html | 636 ++++++++++++ 24 files changed, 13865 insertions(+) create mode 100644 v11.1.0/output/pydis_core.async_stats.html create mode 100644 v11.1.0/output/pydis_core.exts.html create mode 100644 v11.1.0/output/pydis_core.html create mode 100644 v11.1.0/output/pydis_core.site_api.html create mode 100644 v11.1.0/output/pydis_core.utils.caching.html create mode 100644 v11.1.0/output/pydis_core.utils.channel.html create mode 100644 v11.1.0/output/pydis_core.utils.checks.html create mode 100644 v11.1.0/output/pydis_core.utils.commands.html create mode 100644 v11.1.0/output/pydis_core.utils.cooldown.html create mode 100644 v11.1.0/output/pydis_core.utils.error_handling.commands.abc.html create mode 100644 v11.1.0/output/pydis_core.utils.error_handling.commands.html create mode 100644 v11.1.0/output/pydis_core.utils.error_handling.commands.manager.html create mode 100644 v11.1.0/output/pydis_core.utils.error_handling.html create mode 100644 v11.1.0/output/pydis_core.utils.function.html create mode 100644 v11.1.0/output/pydis_core.utils.html create mode 100644 v11.1.0/output/pydis_core.utils.interactions.html create mode 100644 v11.1.0/output/pydis_core.utils.lock.html create mode 100644 v11.1.0/output/pydis_core.utils.logging.html create mode 100644 v11.1.0/output/pydis_core.utils.members.html create mode 100644 v11.1.0/output/pydis_core.utils.messages.html create mode 100644 v11.1.0/output/pydis_core.utils.pagination.html create mode 100644 v11.1.0/output/pydis_core.utils.paste_service.html create mode 100644 v11.1.0/output/pydis_core.utils.regex.html create mode 100644 v11.1.0/output/pydis_core.utils.scheduling.html (limited to 'v11.1.0/output') diff --git a/v11.1.0/output/pydis_core.async_stats.html b/v11.1.0/output/pydis_core.async_stats.html new file mode 100644 index 00000000..8ec660d4 --- /dev/null +++ b/v11.1.0/output/pydis_core.async_stats.html @@ -0,0 +1,510 @@ + + + + + + + + + async_stats - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

async_stats#

+

An async transport method for statsd communication.

+
+
+class AsyncStatsClient(loop, host='localhost', port=8125, prefix=None)[source]#
+

Bases: StatsClientBase

+

An async implementation of statsd.client.base.StatsClientBase that supports async stat communication.

+
+
+__init__(loop, host='localhost', port=8125, prefix=None)[source]#
+

Create a new AsyncStatsClient.

+
+
Parameters:
+
+
+
+
+ +
+
+async create_socket()[source]#
+

Use asyncio.loop.create_datagram_endpoint from the loop given on init to create a socket.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.exts.html b/v11.1.0/output/pydis_core.exts.html new file mode 100644 index 00000000..9c719265 --- /dev/null +++ b/v11.1.0/output/pydis_core.exts.html @@ -0,0 +1,452 @@ + + + + + + + + + Exts - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

Exts#

+

Reusable Discord cogs.

+
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.html b/v11.1.0/output/pydis_core.html new file mode 100644 index 00000000..1cebe03c --- /dev/null +++ b/v11.1.0/output/pydis_core.html @@ -0,0 +1,1081 @@ + + + + + + + + + Pydis Core - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

Pydis Core#

+

Useful utilities and tools for Discord bot development.

+
+
+class BotBase(*args, guild_id, allowed_roles, http_session, redis_session=None, api_client=None, statsd_url=None, **kwargs)[source]#
+

Bases: Bot

+

A sub-class that implements many common features that Python Discord bots use.

+
+
+guild_id[source]#
+

ID of the guild that the bot belongs to.

+
+
Type:
+

int

+
+
+
+ +
+
+http_session[source]#
+

The http session used for sending out HTTP requests.

+
+
Type:
+

aiohttp.ClientSession

+
+
+
+ +
+
+api_client[source]#
+

The API client used for communications with the site service.

+
+
Type:
+

pydis_core.site_api.APIClient

+
+
+
+ +
+
+statsd_url[source]#
+

The url that statsd sends metrics to.

+
+
Type:
+

str

+
+
+
+ +
+
+redis_session[source]#
+

The redis session used to communicate with the Redis instance.

+
+
Type:
+

async_rediscache.RedisSession

+
+
+
+ +
+
+stats[source]#
+

The statsd client that sends metrics.

+
+
Type:
+

pydis_core.async_stats.AsyncStatsClient

+
+
+
+ +
+
+all_extensions[source]#
+

All extensions that were found within the module passed to +self.load_extensions. Use self.extensions to get the loaded extensions.

+
+
Type:
+

frozenset[str]

+
+
+
+ +
+
+__init__(*args, guild_id, allowed_roles, http_session, redis_session=None, api_client=None, statsd_url=None, **kwargs)[source]#
+

Initialise the base bot instance.

+
+
Parameters:
+
+
+
+
+ +
+
+async add_cog(cog)[source]#
+

Add the given cog to the bot and log the operation.

+
+
Return type:
+

None

+
+
+
+ +
+
+add_command(command)[source]#
+

Add command as normal and then add its root aliases to the bot.

+
+
Return type:
+

None

+
+
+
+ +
+
+clear()[source]#
+

Not implemented! Re-instantiate the bot instead of attempting to re-use a closed one.

+
+
Return type:
+

None

+
+
+
+ +
+
+async close()[source]#
+

Close the Discord connection, and the aiohttp session, connector, statsd client, and resolver.

+
+
Return type:
+

None

+
+
+
+ +
+
+async load_extensions(module, *, sync_app_commands=True)[source]#
+

Load all the extensions within the given module and save them to self.all_extensions.

+
+
Parameters:
+

sync_app_commands (bool) – Whether to sync app commands after all extensions are loaded.

+
+
Return type:
+

None

+
+
+
+ +
+
+async log_to_dev_log(message)[source]#
+

Log the given message to #dev-log.

+
+
Return type:
+

None

+
+
+
+ +
+
+async on_guild_available(guild)[source]#
+

Set the internal guild available event when self.guild_id becomes available.

+

If the cache appears to still be empty (no members, no channels, or no roles), the event +will not be set and guild_available_but_cache_empty event will be emitted.

+
+
Return type:
+

None

+
+
+
+ +
+
+async on_guild_unavailable(guild)[source]#
+

Clear the internal guild available event when self.guild_id becomes unavailable.

+
+
Return type:
+

None

+
+
+
+ +
+
+async ping_services()[source]#
+

Ping all required services on setup to ensure they are up before starting.

+
+
Return type:
+

None

+
+
+
+ +
+
+async process_commands(message)[source]#
+

Overwrite default Discord.py behaviour to process commands only after ensuring extensions are loaded.

+

This extension check is only relevant for clients that make use of pydis_core.BotBase.load_extensions.

+
+
Return type:
+

None

+
+
+
+ +
+
+register_command_error_manager(manager)[source]#
+

Bind an instance of the command error manager to both the bot and the command tree.

+

The reason this doesn’t happen in the constructor is because error handlers might need an instance of the bot. +So registration needs to happen once the bot instance has been created.

+
+
Return type:
+

None

+
+
+
+ +
+
+remove_command(name)[source]#
+

Remove a command/alias as normal and then remove its root aliases from the bot.

+

Individual root aliases cannot be removed by this function. +To remove them, either remove the entire command or manually edit bot.all_commands.

+
+
Return type:
+

Command | None

+
+
+
+ +
+
+async setup_hook()[source]#
+

An async init to startup generic services.

+

Connects to statsd, and calls +AsyncStatsClient.create_socket +and ping_services().

+
+
Return type:
+

None

+
+
+
+ +
+
+async wait_until_guild_available()[source]#
+

Wait until the guild that matches the guild_id given at init is available (and the cache is ready).

+

The on_ready event is inadequate because it only waits 2 seconds for a GUILD_CREATE +gateway event before giving up and thus not populating the cache for unavailable guilds.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+exception EmptyPaginatorEmbedError[source]#
+

Bases: Exception

+

Raised when attempting to paginate with empty contents.

+
+ +
+
+class LinePaginator(prefix='```', suffix='```', max_size=4000, scale_to_size=4000, max_lines=None, linesep='\\n')[source]#
+

Bases: Paginator

+

A class that aids in paginating code blocks for Discord messages.

+
+
Parameters:
+
    +
  • pagination_emojis (PaginationEmojis) – The emojis used to navigate pages.

  • +
  • prefix (str) – The prefix inserted to every page. e.g. three backticks.

  • +
  • suffix (str) – The suffix appended at the end of every page. e.g. three backticks.

  • +
  • max_size (int) – The maximum amount of codepoints allowed in a page.

  • +
  • scale_to_size (int) – The maximum amount of characters a single line can scale up to.

  • +
  • max_lines (int) – The maximum amount of lines allowed in a page.

  • +
+
+
+
+
+__init__(prefix='```', suffix='```', max_size=4000, scale_to_size=4000, max_lines=None, linesep='\\n')[source]#
+

This function overrides the Paginator.__init__ from inside discord.ext.commands.

+

It overrides in order to allow us to configure the maximum number of lines per page.

+
+ +
+
+add_line(line='', *, empty=False)[source]#
+

Adds a line to the current page.

+

If a line on a page exceeds max_size characters, then max_size will go up to +scale_to_size for a single line before creating a new page for the overflow words. If it +is still exceeded, the excess characters are stored and placed on the next pages unti +there are none remaining (by word boundary). The line is truncated if scale_to_size is +still exceeded after attempting to continue onto the next page.

+

In the case that the page already contains one or more lines and the new lines would cause +max_size to be exceeded, a new page is created. This is done in order to make a best +effort to avoid breaking up single lines across pages, while keeping the total length of the +page at a reasonable size.

+

This function overrides the Paginator.add_line from inside discord.ext.commands.

+

It overrides in order to allow us to configure the maximum number of lines per page.

+
+
Parameters:
+
    +
  • line (str) – The line to add to the paginated content.

  • +
  • empty (bool) – Indicates whether an empty line should be added at the end.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+
+async classmethod paginate(pagination_emojis, lines, ctx, embed, *, prefix='', suffix='', max_lines=None, max_size=500, scale_to_size=4000, empty=True, restrict_to_user=None, timeout=300, footer_text=None, url=None, exception_on_empty_embed=False, reply=False, allowed_roles=None)[source]#
+

Use a paginator and set of reactions to provide pagination over a set of lines.

+

The reactions are used to switch page, or to finish with pagination.

+

When used, this will send a message using ctx.send() and apply a set of reactions to it. These reactions may +be used to change page, or to remove pagination from the message.

+

Pagination will also be removed automatically if no reaction is added for five minutes (300 seconds).

+

The interaction will be limited to restrict_to_user (ctx.author by default) or +to any user with a moderation role.

+
+
Parameters:
+
    +
  • pagination_emojis (PaginationEmojis) – The emojis used to navigate pages.

  • +
  • lines (list[str]) – A list of lines to be added to the paginated content.

  • +
  • ctx (discord.ext.commands.Context) – The context in which the pagination is needed.

  • +
  • embed (discord.Embed) – The embed that holds the content, it serves as the page.

  • +
  • prefix (str) – The prefix inserted to every page. e.g. three backticks.

  • +
  • suffix (str) – The suffix appended at the end of every page. e.g. three backticks.

  • +
  • max_lines (int) – The maximum amount of lines allowed in a page.

  • +
  • max_size (int) – The maximum amount of codepoints allowed in a page.

  • +
  • scale_to_size (int) – The maximum amount of characters a single line can scale up to.

  • +
  • empty (bool) – Indicates whether an empty line should be added to each provided line.

  • +
  • restrict_to_user (discord.User) – The user to whom interaction with the pages should be restricted.

  • +
  • timeout (int) – The timeout after which users cannot change pages anymore.

  • +
  • footer_text (str) – Text to be added as a footer for each page.

  • +
  • url (str) – The url to be set for the pagination embed.

  • +
  • exception_on_empty_embed (bool) – Indicates whether to raise an exception when no lines are provided.

  • +
  • reply (bool) – Indicates whether to send the page as a reply to the context’s message.

  • +
  • allowed_roles (Sequence[int]) – A list of role ids that are allowed to change pages.

  • +
+
+
Return type:
+

Message | None

+
+
+

Example: +>>> embed = discord.Embed() +>>> embed.set_author(name=”Some Operation”, url=url, icon_url=icon) +>>> await LinePaginator.paginate(pagination_emojis, [line for line in lines], ctx, embed)

+
+ +
+ +
+
+class PaginationEmojis(**data)[source]#
+

Bases: BaseModel

+

The emojis that will be used for pagination.

+
+
+model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
+

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

+
+ +
+
+model_config: ClassVar[ConfigDict] = {}#
+

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

+
+ +
+
+model_fields: ClassVar[dict[str, FieldInfo]] = {'delete': FieldInfo(annotation=str, required=False, default='<:trashcan:637136429717389331>'), 'first': FieldInfo(annotation=str, required=False, default='⏮'), 'last': FieldInfo(annotation=str, required=False, default='⏭'), 'left': FieldInfo(annotation=str, required=False, default='⬅'), 'right': FieldInfo(annotation=str, required=False, default='➡')}#
+

Metadata about the fields defined on the model, +mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

+

This replaces Model.__fields__ from Pydantic V1.

+
+ +
+ +
+
+exception StartupError(base)[source]#
+

Bases: Exception

+

Exception class for startup errors.

+
+
+__init__(base)[source]#
+
+ +
+ +
+

Subpackages#

+ +
+
+

Submodules#

+ +
+
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.site_api.html b/v11.1.0/output/pydis_core.site_api.html new file mode 100644 index 00000000..b2279e7b --- /dev/null +++ b/v11.1.0/output/pydis_core.site_api.html @@ -0,0 +1,648 @@ + + + + + + + + + site_api - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

site_api#

+

An API wrapper around the Site API.

+
+
+class APIClient(site_api_url, site_api_token, **session_kwargs)[source]#
+

Bases: object

+

A wrapper for the Django Site API.

+
+
+__init__(site_api_url, site_api_token, **session_kwargs)[source]#
+

Initialize a new APIClient instance.

+
+
Parameters:
+
    +
  • site_api_url (str) – The URL of the site API.

  • +
  • site_api_token (str) – The token to use for authentication.

  • +
  • session_kwargs – Keyword arguments to pass to the aiohttp.ClientSession constructor.

  • +
+
+
+
+ +
+
+async close()[source]#
+

Close the aiohttp session.

+
+
Return type:
+

None

+
+
+
+ +
+
+async delete(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with DELETE passed as the method.

+
+
Return type:
+

dict | None

+
+
+
+ +
+
+async get(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with GET passed as the method.

+
+
Return type:
+

dict | None

+
+
+
+ +
+
+async static maybe_raise_for_status(response, *, should_raise)[source]#
+

Raise ResponseCodeError for non-OK response if an exception should be raised.

+
+
Parameters:
+
+
+
Raises:
+

ResponseCodeError – If the response is not OK and should_raise is True.

+
+
Return type:
+

None

+
+
+
+ +
+
+async patch(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with PATCH passed as the method.

+
+
Return type:
+

dict | None

+
+
+
+ +
+
+async post(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with POST passed as the method.

+
+
Return type:
+

dict | None

+
+
+
+ +
+
+async put(endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Equivalent to APIClient.request() with PUT passed as the method.

+
+
Return type:
+

dict | None

+
+
+
+ +
+
+async request(method, endpoint, *, raise_for_status=True, **kwargs)[source]#
+

Send an HTTP request to the site API and return the JSON response.

+
+
Parameters:
+
    +
  • method (str) – The HTTP method to use.

  • +
  • endpoint (str) – The endpoint to send the request to.

  • +
  • raise_for_status (bool) – Whether or not to raise an exception if the response is not OK.

  • +
  • **kwargs – Any extra keyword arguments to pass to aiohttp.request().

  • +
+
+
Return type:
+

dict | None

+
+
Returns:
+

The JSON response the API returns, or None if the response code is 204.

+
+
Raises:
+

ResponseCodeError – If the response is not OK and raise_for_status is True.

+
+
+
+ +
+ +
+
+exception ResponseCodeError(response, response_json=None, response_text=None)[source]#
+

Bases: ValueError

+

Raised in APIClient.request() when a non-OK HTTP response is received.

+
+
+__init__(response, response_json=None, response_text=None)[source]#
+

Initialize a new ResponseCodeError instance.

+
+
Parameters:
+
    +
  • response (aiohttp.ClientResponse) – The response object from the request.

  • +
  • response_json (dict | None) – The JSON response returned from the request, if any.

  • +
  • response_text (str | None) – The text of the request, if any.

  • +
+
+
+
+ +
+
+__str__()[source]#
+

Return a string representation of the error.

+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.caching.html b/v11.1.0/output/pydis_core.utils.caching.html new file mode 100644 index 00000000..ab8f1c0b --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.caching.html @@ -0,0 +1,524 @@ + + + + + + + + + caching - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

caching#

+

Utilities related to custom caches.

+
+
+class AsyncCache(max_size=128)[source]#
+

Bases: object

+

LRU cache implementation for coroutines.

+

Once the cache exceeds the maximum size, keys are deleted in FIFO order.

+

An offset may be optionally provided to be applied to the coroutine’s arguments when creating the cache key.

+
+
+__call__(arg_offset=0)[source]#
+

Decorator for async cache.

+
+
Parameters:
+

arg_offset (int) – The offset for the position of the key argument.

+
+
Return type:
+

Callable

+
+
Returns:
+

A decorator to wrap the target function.

+
+
+
+ +
+
+__init__(max_size=128)[source]#
+

Initialise a new AsyncCache instance.

+
+
Parameters:
+

max_size (int) – How many items to store in the cache.

+
+
+
+ +
+
+clear()[source]#
+

Clear cache instance.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.channel.html b/v11.1.0/output/pydis_core.utils.channel.html new file mode 100644 index 00000000..75a726c0 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.channel.html @@ -0,0 +1,520 @@ + + + + + + + + + channel - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

channel#

+

Useful helper functions for interacting with various discord channel objects.

+
+
+async get_or_fetch_channel(bot, channel_id)[source]#
+

Attempt to get or fetch the given channel_id from the bots cache, and return it.

+
+
Parameters:
+
+
+
Raises:
+
+
+
Return type:
+

GuildChannel | PrivateChannel | Thread

+
+
Returns:
+

The channel from the ID.

+
+
+
+ +
+
+is_in_category(channel, category_id)[source]#
+

Return whether the given channel in the the category with the id category_id.

+
+
Parameters:
+
    +
  • channel (TextChannel) – The channel to check.

  • +
  • category_id (int) – The category to check for.

  • +
+
+
Return type:
+

bool

+
+
Returns:
+

A bool depending on whether the channel is in the category.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.checks.html b/v11.1.0/output/pydis_core.utils.checks.html new file mode 100644 index 00000000..6bc13ce6 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.checks.html @@ -0,0 +1,592 @@ + + + + + + + + + checks - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

checks#

+
+
+exception ContextCheckFailure(redirect_channel)[source]#
+

Bases: CheckFailure

+

Raised when a context-specific check fails.

+
+
+__init__(redirect_channel)[source]#
+
+ +
+ +
+
+exception InWhitelistCheckFailure(redirect_channel)[source]#
+

Bases: ContextCheckFailure

+

Raised when the in_whitelist check fails.

+
+ +
+
+cooldown_with_role_bypass(rate, per, type_=('default', 0), *, bypass_roles)[source]#
+

Decorate a command to have a cooldown, which can be bypassed by users with specified roles.

+

Note: This replaces the Command.before_invoke callback, which might introduce problems in the future.

+
+
Parameters:
+
    +
  • rate (int) – Number of times a command can be used before triggering a cooldown.

  • +
  • per (float) – The duration (in seconds) for how long the cooldown lasts.

  • +
  • type (discord.ext.commands.BucketType) – The type of cooldown (per user, per channel, per guild, etc.).

  • +
  • bypass_roles (Iterable[int]) – An iterable of role IDs that bypass the cooldown.

  • +
+
+
Returns:
+

A decorator that adds the described cooldown behavior to the command.

+
+
Return type:
+

Callable

+
+
Raises:
+

TypeError – If the decorator is not applied to an instance of Command.

+
+
+
+ +
+
+async has_any_role_check(ctx, *roles)[source]#
+

Verify if the context’s author has any of the specified roles.

+

This check will always fail if the context is a DM, since DMs don’t have roles.

+
+
Parameters:
+
+
+
Returns:
+

True if the context’s author has at least one of the specified roles; False otherwise.

+
+
Return type:
+

bool

+
+
+
+ +
+
+async has_no_roles_check(ctx, *roles)[source]#
+

Verify if the context’s author doesn’t have any of the specified roles.

+

This check will always fail if the context is a DM, since DMs don’t have roles.

+
+
Parameters:
+
+
+
Returns:
+

True if the context’s author doesn’t have any of the specified roles; False otherwise.

+
+
Return type:
+

bool

+
+
+
+ +
+
+in_whitelist_check(ctx, redirect, channels=(), categories=(), roles=(), *, fail_silently=False)[source]#
+

Check if a command was issued in a context that is whitelisted by channel, category, or roles.

+
+
Parameters:
+
    +
  • ctx (discord.ext.commands.Context) – The context in which the command is being invoked.

  • +
  • redirect (int | None) – The channel ID to redirect the user to, if any.

  • +
  • channels (Container[int]) – Whitelisted channel IDs. Defaults to ().

  • +
  • categories (Container[int]) – Whitelisted category IDs. Defaults to ().

  • +
  • roles (Container[int]) – Whitelisted role IDs. Defaults to ().

  • +
  • fail_silently (bool) – Whether to fail silently without raising an exception. Defaults to False.

  • +
+
+
Returns:
+

True if the command is used in a whitelisted context; False otherwise.

+
+
Return type:
+

bool

+
+
Raises:
+

InWhitelistCheckFailure – If the context is not whitelisted and fail_silently is False.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.commands.html b/v11.1.0/output/pydis_core.utils.commands.html new file mode 100644 index 00000000..fff9113f --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.commands.html @@ -0,0 +1,493 @@ + + + + + + + + + commands - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

commands#

+
+
+async clean_text_or_reply(ctx, text=None)[source]#
+

Cleans a text argument or replied message’s content.

+
+
Parameters:
+
    +
  • ctx (Context) – The command’s context

  • +
  • text (str | None) – The provided text argument of the command (if given)

  • +
+
+
Raises:
+

discord.ext.commands.BadArgumenttext wasn’t provided and there’s no reply message / reply message content.

+
+
Return type:
+

str

+
+
Returns:
+

The cleaned version of text, if given, else replied message.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.cooldown.html b/v11.1.0/output/pydis_core.utils.cooldown.html new file mode 100644 index 00000000..96b3ecb2 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.cooldown.html @@ -0,0 +1,543 @@ + + + + + + + + + cooldown - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

cooldown#

+

Helpers for setting a cooldown on commands.

+
+
+exception CommandOnCooldown(message, function, /, *args, **kwargs)[source]#
+

Bases: CommandError, Generic[P, R]

+

Raised when a command is invoked while on cooldown.

+
+
+__init__(message, function, /, *args, **kwargs)[source]#
+
+ +
+
+async call_without_cooldown()[source]#
+

Run the command this cooldown blocked.

+
+
Return type:
+

TypeVar(R)

+
+
Returns:
+

The command’s return value.

+
+
+
+ +
+ +
+
+P = ~P[source]#
+

The command’s signature.

+
+ +
+
+class R[source]#
+

The command’s return value.

+

alias of TypeVar(‘R’)

+
+ +
+
+block_duplicate_invocations(*, cooldown_duration=5, send_notice=False, args_preprocessor=None)[source]#
+

Prevent duplicate invocations of a command with the same arguments in a channel for cooldown_duration seconds.

+
+
Parameters:
+
    +
  • cooldown_duration (float) – Length of the cooldown in seconds.

  • +
  • send_notice (bool) – If True, notify the user about the cooldown with a reply.

  • +
  • args_preprocessor (Callable[[ParamSpec(P)], Iterable[object]] | None) – If specified, this function is called with the args and kwargs the function is called with, +its return value is then used to check for the cooldown instead of the raw arguments.

  • +
+
+
Return type:
+

Callable[[Callable[[ParamSpec(P)], Awaitable[TypeVar(R)]]], Callable[[ParamSpec(P)], Awaitable[TypeVar(R)]]]

+
+
Returns:
+

A decorator that adds a wrapper which applies the cooldowns.

+
+
+
+

Warning

+

The created wrapper raises CommandOnCooldown when the command is on cooldown.

+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.error_handling.commands.abc.html b/v11.1.0/output/pydis_core.utils.error_handling.commands.abc.html new file mode 100644 index 00000000..3bb72230 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.error_handling.commands.abc.html @@ -0,0 +1,515 @@ + + + + + + + + + abc - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

abc#

+
+
+class AbstractCommandErrorHandler[source]#
+

Bases: ABC

+

An abstract command error handler.

+
+
+abstract async handle_app_command_error(interaction, error)[source]#
+

Handle error raised in the context of app commands.

+
+
Return type:
+

NoReturn

+
+
+
+ +
+
+abstract async handle_text_command_error(context, error)[source]#
+

Handle error raised in the context of text commands.

+
+
Return type:
+

NoReturn

+
+
+
+ +
+
+abstract async should_handle_error(error)[source]#
+

A predicate that determines whether the error should be handled.

+
+
Return type:
+

bool

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.error_handling.commands.html b/v11.1.0/output/pydis_core.utils.error_handling.commands.html new file mode 100644 index 00000000..08552161 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.error_handling.commands.html @@ -0,0 +1,583 @@ + + + + + + + + + commands package - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

commands package#

+
+
+class AbstractCommandErrorHandler[source]#
+

Bases: ABC

+

An abstract command error handler.

+
+
+abstract async handle_app_command_error(interaction, error)[source]#
+

Handle error raised in the context of app commands.

+
+
Return type:
+

NoReturn

+
+
+
+ +
+
+abstract async handle_text_command_error(context, error)[source]#
+

Handle error raised in the context of text commands.

+
+
Return type:
+

NoReturn

+
+
+
+ +
+
+abstract async should_handle_error(error)[source]#
+

A predicate that determines whether the error should be handled.

+
+
Return type:
+

bool

+
+
+
+ +
+ +
+
+class CommandErrorManager(default)[source]#
+

Bases: object

+

A class that registers error handlers and handles all command related errors.

+
+
+__init__(default)[source]#
+
+ +
+
+async handle_error(error, context_or_interaction)[source]#
+

Handle a Discord exception.

+

Iterate through available handlers by registration order, and choose the first one capable of handling +the error as determined by should_handle_error; there is no priority system.

+
+
Return type:
+

None

+
+
+
+ +
+
+register_handler(handler)[source]#
+

Register a command error handler.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+

Submodules#

+ +
+
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.error_handling.commands.manager.html b/v11.1.0/output/pydis_core.utils.error_handling.commands.manager.html new file mode 100644 index 00000000..2fe42490 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.error_handling.commands.manager.html @@ -0,0 +1,511 @@ + + + + + + + + + manager - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

manager#

+
+
+class CommandErrorManager(default)[source]#
+

Bases: object

+

A class that registers error handlers and handles all command related errors.

+
+
+__init__(default)[source]#
+
+ +
+
+async handle_error(error, context_or_interaction)[source]#
+

Handle a Discord exception.

+

Iterate through available handlers by registration order, and choose the first one capable of handling +the error as determined by should_handle_error; there is no priority system.

+
+
Return type:
+

None

+
+
+
+ +
+
+register_handler(handler)[source]#
+

Register a command error handler.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.error_handling.html b/v11.1.0/output/pydis_core.utils.error_handling.html new file mode 100644 index 00000000..e738e622 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.error_handling.html @@ -0,0 +1,521 @@ + + + + + + + + + error_handling package - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

error_handling package#

+
+
+async handle_forbidden_from_block(error, message=None)[source]#
+

Handles discord.Forbidden 90001 errors, or re-raises if error isn’t a 90001 error.

+
+
Parameters:
+
    +
  • error (Forbidden) – The raised discord.Forbidden to check.

  • +
  • message (Message | None) – The message to reply to and include in logs, if error is 90001 and message is provided.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+

Subpackages#

+ +
+
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.function.html b/v11.1.0/output/pydis_core.utils.function.html new file mode 100644 index 00000000..9c260ffb --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.function.html @@ -0,0 +1,604 @@ + + + + + + + + + function - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

function#

+

Utils for manipulating functions.

+
+
+exception GlobalNameConflictError[source]#
+

Bases: Exception

+

Raised on a conflict between the globals used to resolve annotations of a wrapped function and its wrapper.

+
+ +
+
+command_wraps(wrapped, assigned=('__module__', '__name__', '__qualname__', '__doc__', '__annotations__'), updated=('__dict__',), *, ignored_conflict_names=frozenset({}))[source]#
+

Update the decorated function to look like wrapped, and update globals for discord.py forwardref evaluation.

+

See update_wrapper_globals() for more details on how the globals are updated.

+
+
Parameters:
+
    +
  • wrapped (Callable[[ParamSpec(_P)], TypeVar(_R)]) – The function to wrap with.

  • +
  • assigned (Sequence[str]) – Sequence of attribute names that are directly assigned from wrapped to wrapper.

  • +
  • updated (Sequence[str]) – Sequence of attribute names that are .update``d on ``wrapper from the attributes on wrapped.

  • +
  • ignored_conflict_names (Set[str]) – A set of names to ignore if a conflict between them is found.

  • +
+
+
Return type:
+

Callable[[Callable[[ParamSpec(_P)], TypeVar(_R)]], Callable[[ParamSpec(_P)], TypeVar(_R)]]

+
+
Returns:
+

A decorator that behaves like functools.wraps(), +with the wrapper replaced with the function update_wrapper_globals() returned.

+
+
+
+ +
+
+get_arg_value(name_or_pos, arguments)[source]#
+

Return a value from arguments based on a name or position.

+
+
Parameters:
+

arguments (OrderedDict[str, Any]) – An ordered mapping of parameter names to argument values.

+
+
Return type:
+

Any

+
+
Returns:
+

Value from arguments based on a name or position.

+
+
Raises:
+
    +
  • TypeErrorname_or_pos isn’t a str or int.

  • +
  • ValueErrorname_or_pos does not match any argument.

  • +
+
+
+
+ +
+
+get_arg_value_wrapper(decorator_func, name_or_pos, func=None)[source]#
+

Call decorator_func with the value of the arg at the given name/position.

+
+
Parameters:
+
    +
  • decorator_func (Callable[[Callable[[OrderedDict[str, Any]], Any]], Callable[[Callable], Callable]]) – A function that must accept a callable as a parameter to which it will pass a mapping of +parameter names to argument values of the function it’s decorating.

  • +
  • name_or_pos (int | str) – The name/position of the arg to get the value from.

  • +
  • func (Optional[Callable[[Any], Any]]) – An optional callable which will return a new value given the argument’s value.

  • +
+
+
Return type:
+

Callable[[Callable], Callable]

+
+
Returns:
+

The decorator returned by decorator_func.

+
+
+
+ +
+
+get_bound_args(func, args, kwargs)[source]#
+

Bind args and kwargs to func and return a mapping of parameter names to argument values.

+

Default parameter values are also set.

+
+
Parameters:
+
    +
  • args (tuple) – The arguments to bind to func

  • +
  • kwargs (dict[str, Any]) – The keyword arguments to bind to func

  • +
  • func (Callable) – The function to bind args and kwargs to

  • +
+
+
Return type:
+

OrderedDict[str, Any]

+
+
Returns:
+

A mapping of parameter names to argument values.

+
+
+
+ +
+
+update_wrapper_globals(wrapper, wrapped, *, ignored_conflict_names=frozenset({}))[source]#
+

Create a copy of wrapper, the copy’s globals are updated with wrapped's globals.

+

For forwardrefs in command annotations, discord.py uses the __global__ attribute of the function +to resolve their values. This breaks for decorators that replace the function because they have +their own globals.

+
+

Warning

+

This function captures the state of wrapped's module’s globals when it’s called; +changes won’t be reflected in the new function’s globals.

+
+
+
Parameters:
+
+
+
Raises:
+

GlobalNameConflictError – If wrapper and wrapped share a global name that’s also used in wrapped's typehints, + and is not in ignored_conflict_names.

+
+
Return type:
+

Callable[[ParamSpec(_P)], TypeVar(_R)]

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.html b/v11.1.0/output/pydis_core.utils.html new file mode 100644 index 00000000..6415f371 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.html @@ -0,0 +1,695 @@ + + + + + + + + + Utils - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

Utils#

+

Useful utilities and tools for Discord bot development.

+
+
+apply_monkey_patches()[source]#
+

Applies all common monkey patches for our bots.

+
+
Return type:
+

None

+
+
+
+
Patches discord.ext.commands.Command and discord.ext.commands.Group to support root aliases.

A root_aliases keyword argument is added to these two objects, which is a sequence of alias names +that will act as top-level groups rather than being aliases of the command’s group.

+

It’s stored as an attribute also named root_aliases

+
+
Patches discord’s internal send_typing method so that it ignores 403 errors from Discord.

When under heavy load Discord has added a CloudFlare worker to this route, which causes 403 errors to be thrown.

+
+
+
+ +
+
+unqualify(name)[source]#
+

Return an unqualified name given a qualified module/package name.

+
+
Parameters:
+

name (str) – The module name to unqualify.

+
+
Return type:
+

str

+
+
Returns:
+

The unqualified module name.

+
+
+
+ +
+

Subpackages#

+ +
+
+

Submodules#

+
+ +
+
+
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.interactions.html b/v11.1.0/output/pydis_core.utils.interactions.html new file mode 100644 index 00000000..d6b5273d --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.interactions.html @@ -0,0 +1,593 @@ + + + + + + + + + interactions - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

interactions#

+
+
+class DeleteMessageButton(*, style=('secondary', 2), label='Delete', **kwargs)[source]#
+

Bases: Button

+

A button that can be added to a view to delete the message containing the view on click.

+

This button itself carries out no interaction checks, these should be done by the parent view.

+

See pydis_core.utils.interactions.ViewWithUserAndRoleCheck for a view that implements basic checks.

+
+
Parameters:
+
    +
  • style (ButtonStyle) – The style of the button, set to ButtonStyle.secondary if not specified.

  • +
  • label (str) – The label of the button, set to “Delete” if not specified.

  • +
+
+
+
+
+__init__(*, style=('secondary', 2), label='Delete', **kwargs)[source]#
+
+ +
+
+async callback(interaction)[source]#
+

Delete the original message on button click.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+class ViewWithUserAndRoleCheck(*, allowed_users, allowed_roles, timeout=180.0, message=None)[source]#
+

Bases: View

+

A view that allows the original invoker and moderators to interact with it.

+
+
Parameters:
+
    +
  • allowed_users (Sequence[int]) – A sequence of user’s ids who are allowed to interact with the view.

  • +
  • allowed_roles (Sequence[int]) – A sequence of role ids that are allowed to interact with the view.

  • +
  • timeout (float | None) – Timeout in seconds from last interaction with the UI before no longer accepting input. +If None then there is no timeout.

  • +
  • message (Message | None) – The message to remove the view from on timeout. This can also be set with +view.message = await ctx.send( ... )` , or similar, after the view is instantiated.

  • +
+
+
+
+
+__init__(*, allowed_users, allowed_roles, timeout=180.0, message=None)[source]#
+
+ +
+
+async interaction_check(interaction)[source]#
+

Ensure the user clicking the button is the view invoker, or a moderator.

+
+
Parameters:
+

interaction (Interaction) – The interaction that occurred.

+
+
Return type:
+

bool

+
+
+
+ +
+
+async on_timeout()[source]#
+

Remove the view from self.message if set.

+
+
Return type:
+

None

+
+
+
+ +
+
+stop()[source]#
+

Stop listening for interactions, and remove the view from self.message if set.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+user_has_access(user, *, allowed_users=(), allowed_roles=())[source]#
+

Return whether the user is in the allowed_users list, or has a role from allowed_roles.

+
+
Parameters:
+
    +
  • user (User | Member) – The user to check

  • +
  • allowed_users (Sequence[int]) – A sequence of user ids that are allowed access

  • +
  • allowed_roles (Sequence[int]) – A sequence of role ids that are allowed access

  • +
+
+
Return type:
+

bool

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.lock.html b/v11.1.0/output/pydis_core.utils.lock.html new file mode 100644 index 00000000..c9f7adfd --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.lock.html @@ -0,0 +1,597 @@ + + + + + + + + + lock - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

lock#

+
+
+exception LockedResourceError(resource_type, resource_id)[source]#
+

Bases: RuntimeError

+

Exception raised when an operation is attempted on a locked resource.

+
+
+type[source]#
+

Name of the locked resource’s type

+
+
Type:
+

str

+
+
+
+ +
+
+id[source]#
+

ID of the locked resource

+
+
Type:
+

Hashable

+
+
+
+ +
+
+__init__(resource_type, resource_id)[source]#
+
+ +
+ +
+
+class SharedEvent[source]#
+

Bases: object

+

Context manager managing an internal event exposed through the wait coro.

+

While any code is executing in this context manager, the underlying event will not be set; +when all of the holders finish the event will be set.

+
+
+__enter__()[source]#
+

Increment the count of the active holders and clear the internal event.

+
+ +
+
+__exit__(_exc_type, _exc_val, _exc_tb)[source]#
+

Decrement the count of the active holders; if 0 is reached set the internal event.

+
+ +
+
+__init__()[source]#
+
+ +
+
+async wait()[source]#
+

Wait for all active holders to exit.

+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+lock(namespace, resource_id, *, raise_error=False, wait=False)[source]#
+

Turn the decorated coroutine function into a mutually exclusive operation on a resource_id.

+

If decorating a command, this decorator must go before (below) the command decorator.

+
+
Parameters:
+
    +
  • namespace (Hashable) – An identifier used to prevent collisions among resource IDs.

  • +
  • resource_id (Hashable | Callable[[OrderedDict[str, Any]], Hashable | Awaitable[Hashable]]) – identifies a resource on which to perform a mutually exclusive operation. +It may also be a callable or awaitable which will return the resource ID given an ordered +mapping of the parameters’ names to arguments’ values.

  • +
  • raise_error (bool) – If True, raise LockedResourceError if the lock cannot be acquired.

  • +
  • wait (bool) – If True, wait until the lock becomes available. Otherwise, if any other mutually +exclusive function currently holds the lock for a resource, do not run the decorated function +and return None.

  • +
+
+
Raises:
+

LockedResourceError – If the lock can’t be acquired and raise_error is set to True.

+
+
Return type:
+

Callable

+
+
+
+ +
+
+lock_arg(namespace, name_or_pos, func=None, *, raise_error=False, wait=False)[source]#
+

Apply the lock decorator using the value of the arg at the given name/position as the ID.

+

See lock docs for more information.

+
+
Parameters:
+

func (Callable[[Any], Hashable | Awaitable[Hashable]] | None) – An optional callable or awaitable which will return the ID given the argument value.

+
+
Return type:
+

Callable

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.logging.html b/v11.1.0/output/pydis_core.utils.logging.html new file mode 100644 index 00000000..aab879f5 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.logging.html @@ -0,0 +1,530 @@ + + + + + + + + + logging - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

logging#

+

Common logging related functions.

+
+
+class CustomLogger(name, level=0)[source]#
+

Bases: Logger

+

Custom implementation of the logging.Logger class with an added trace method.

+
+
+trace(msg, *args, **kwargs)[source]#
+

Log the given message with the severity "TRACE".

+

To pass exception information, use the keyword argument exc_info with a true value:

+
logger.trace("Houston, we have an %s", "interesting problem", exc_info=1)
+
+
+
+
Parameters:
+
    +
  • msg (str) – The message to be logged.

  • +
  • args – Passed to the base log function as is.

  • +
  • kwargs – Passed to the base log function as is.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+get_logger(name=None)[source]#
+

Utility to make mypy recognise that logger is of type CustomLogger.

+
+
Parameters:
+

name (str | None) – The name given to the logger.

+
+
Return type:
+

CustomLogger

+
+
Returns:
+

An instance of the CustomLogger class.

+
+
+
+ +
+
+log_format[source]#
+

A logging.Formatter that can be used to standardise logging across all projects using pydis_core.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.members.html b/v11.1.0/output/pydis_core.utils.members.html new file mode 100644 index 00000000..89567cba --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.members.html @@ -0,0 +1,506 @@ + + + + + + + + + members - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

members#

+

Useful helper functions for interactin with discord.Member objects.

+
+
+async get_or_fetch_member(guild, member_id)[source]#
+

Attempt to get a member from cache; on failure fetch from the API.

+
+
Return type:
+

Member | None

+
+
Returns:
+

The discord.Member or None to indicate the member could not be found.

+
+
+
+ +
+
+async handle_role_change(member, coro, role)[source]#
+

Await the given coro with role as the sole argument.

+

Handle errors that we expect to be raised from +discord.Member.add_roles and discord.Member.remove_roles.

+
+
Parameters:
+
+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.messages.html b/v11.1.0/output/pydis_core.utils.messages.html new file mode 100644 index 00000000..25d9167f --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.messages.html @@ -0,0 +1,483 @@ + + + + + + + + + messages - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

messages#

+
+
+reaction_check(reaction, user, *, message_id, allowed_emoji, allowed_users, allowed_roles=None)[source]#
+

Check if a reaction’s emoji and author are allowed and the message is message_id.

+

If the user is not allowed, remove the reaction. Ignore reactions made by the bot. +If allow_mods is True, allow users with moderator roles even if they’re not in allowed_users.

+
+
Return type:
+

bool

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.pagination.html b/v11.1.0/output/pydis_core.utils.pagination.html new file mode 100644 index 00000000..1b43992a --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.pagination.html @@ -0,0 +1,612 @@ + + + + + + + + + pagination - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

pagination#

+
+
+exception EmptyPaginatorEmbedError[source]#
+

Bases: Exception

+

Raised when attempting to paginate with empty contents.

+
+ +
+
+class LinePaginator(prefix='```', suffix='```', max_size=4000, scale_to_size=4000, max_lines=None, linesep='\\n')[source]#
+

Bases: Paginator

+

A class that aids in paginating code blocks for Discord messages.

+
+
Parameters:
+
    +
  • pagination_emojis (PaginationEmojis) – The emojis used to navigate pages.

  • +
  • prefix (str) – The prefix inserted to every page. e.g. three backticks.

  • +
  • suffix (str) – The suffix appended at the end of every page. e.g. three backticks.

  • +
  • max_size (int) – The maximum amount of codepoints allowed in a page.

  • +
  • scale_to_size (int) – The maximum amount of characters a single line can scale up to.

  • +
  • max_lines (int) – The maximum amount of lines allowed in a page.

  • +
+
+
+
+
+__init__(prefix='```', suffix='```', max_size=4000, scale_to_size=4000, max_lines=None, linesep='\\n')[source]#
+

This function overrides the Paginator.__init__ from inside discord.ext.commands.

+

It overrides in order to allow us to configure the maximum number of lines per page.

+
+ +
+
+add_line(line='', *, empty=False)[source]#
+

Adds a line to the current page.

+

If a line on a page exceeds max_size characters, then max_size will go up to +scale_to_size for a single line before creating a new page for the overflow words. If it +is still exceeded, the excess characters are stored and placed on the next pages unti +there are none remaining (by word boundary). The line is truncated if scale_to_size is +still exceeded after attempting to continue onto the next page.

+

In the case that the page already contains one or more lines and the new lines would cause +max_size to be exceeded, a new page is created. This is done in order to make a best +effort to avoid breaking up single lines across pages, while keeping the total length of the +page at a reasonable size.

+

This function overrides the Paginator.add_line from inside discord.ext.commands.

+

It overrides in order to allow us to configure the maximum number of lines per page.

+
+
Parameters:
+
    +
  • line (str) – The line to add to the paginated content.

  • +
  • empty (bool) – Indicates whether an empty line should be added at the end.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+
+async classmethod paginate(pagination_emojis, lines, ctx, embed, *, prefix='', suffix='', max_lines=None, max_size=500, scale_to_size=4000, empty=True, restrict_to_user=None, timeout=300, footer_text=None, url=None, exception_on_empty_embed=False, reply=False, allowed_roles=None)[source]#
+

Use a paginator and set of reactions to provide pagination over a set of lines.

+

The reactions are used to switch page, or to finish with pagination.

+

When used, this will send a message using ctx.send() and apply a set of reactions to it. These reactions may +be used to change page, or to remove pagination from the message.

+

Pagination will also be removed automatically if no reaction is added for five minutes (300 seconds).

+

The interaction will be limited to restrict_to_user (ctx.author by default) or +to any user with a moderation role.

+
+
Parameters:
+
    +
  • pagination_emojis (PaginationEmojis) – The emojis used to navigate pages.

  • +
  • lines (list[str]) – A list of lines to be added to the paginated content.

  • +
  • ctx (discord.ext.commands.Context) – The context in which the pagination is needed.

  • +
  • embed (discord.Embed) – The embed that holds the content, it serves as the page.

  • +
  • prefix (str) – The prefix inserted to every page. e.g. three backticks.

  • +
  • suffix (str) – The suffix appended at the end of every page. e.g. three backticks.

  • +
  • max_lines (int) – The maximum amount of lines allowed in a page.

  • +
  • max_size (int) – The maximum amount of codepoints allowed in a page.

  • +
  • scale_to_size (int) – The maximum amount of characters a single line can scale up to.

  • +
  • empty (bool) – Indicates whether an empty line should be added to each provided line.

  • +
  • restrict_to_user (discord.User) – The user to whom interaction with the pages should be restricted.

  • +
  • timeout (int) – The timeout after which users cannot change pages anymore.

  • +
  • footer_text (str) – Text to be added as a footer for each page.

  • +
  • url (str) – The url to be set for the pagination embed.

  • +
  • exception_on_empty_embed (bool) – Indicates whether to raise an exception when no lines are provided.

  • +
  • reply (bool) – Indicates whether to send the page as a reply to the context’s message.

  • +
  • allowed_roles (Sequence[int]) – A list of role ids that are allowed to change pages.

  • +
+
+
Return type:
+

Message | None

+
+
+

Example: +>>> embed = discord.Embed() +>>> embed.set_author(name=”Some Operation”, url=url, icon_url=icon) +>>> await LinePaginator.paginate(pagination_emojis, [line for line in lines], ctx, embed)

+
+ +
+ +
+
+class PaginationEmojis(**data)[source]#
+

Bases: BaseModel

+

The emojis that will be used for pagination.

+
+
+model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
+

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

+
+ +
+
+model_config: ClassVar[ConfigDict] = {}#
+

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

+
+ +
+
+model_fields: ClassVar[dict[str, FieldInfo]] = {'delete': FieldInfo(annotation=str, required=False, default='<:trashcan:637136429717389331>'), 'first': FieldInfo(annotation=str, required=False, default='⏮'), 'last': FieldInfo(annotation=str, required=False, default='⏭'), 'left': FieldInfo(annotation=str, required=False, default='⬅'), 'right': FieldInfo(annotation=str, required=False, default='➡')}#
+

Metadata about the fields defined on the model, +mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

+

This replaces Model.__fields__ from Pydantic V1.

+
+ +
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.paste_service.html b/v11.1.0/output/pydis_core.utils.paste_service.html new file mode 100644 index 00000000..675ccf78 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.paste_service.html @@ -0,0 +1,613 @@ + + + + + + + + + paste_service - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

paste_service#

+
+
+MAX_PASTE_SIZE = 524288[source]#
+

The maximum allows size of a paste, in bytes.

+
+ +
+
+class PasteFile(**data)[source]#
+

Bases: BaseModel

+

A file to be pasted to the paste service.

+
+
Parameters:
+
    +
  • content (str) – The content of the file.

  • +
  • name (str) – The name of the file to upload. Defaults to ""

  • +
  • lexer (str) – The lexer to use when applying text formatting. Defaults to "python"

  • +
+
+
+
+
+model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
+

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

+
+ +
+
+model_config: ClassVar[ConfigDict] = {}#
+

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

+
+ +
+
+model_fields: ClassVar[dict[str, FieldInfo]] = {'content': FieldInfo(annotation=str, required=True), 'lexer': FieldInfo(annotation=str, required=False, default='python'), 'name': FieldInfo(annotation=str, required=False, default='')}#
+

Metadata about the fields defined on the model, +mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

+

This replaces Model.__fields__ from Pydantic V1.

+
+ +
+ +
+
+class PasteResponse(**data)[source]#
+

Bases: BaseModel

+

A successful response from the paste service.

+
+
Parameters:
+
    +
  • link (str) – The URL to the saved paste.

  • +
  • removal (str) – The URL to delete the saved paste.

  • +
+
+
+
+
+model_computed_fields: ClassVar[dict[str, ComputedFieldInfo]] = {}#
+

A dictionary of computed field names and their corresponding ComputedFieldInfo objects.

+
+ +
+
+model_config: ClassVar[ConfigDict] = {}#
+

Configuration for the model, should be a dictionary conforming to [ConfigDict][pydantic.config.ConfigDict].

+
+ +
+
+model_fields: ClassVar[dict[str, FieldInfo]] = {'link': FieldInfo(annotation=str, required=True), 'removal': FieldInfo(annotation=str, required=True)}#
+

Metadata about the fields defined on the model, +mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].

+

This replaces Model.__fields__ from Pydantic V1.

+
+ +
+ +
+
+exception PasteTooLongError[source]#
+

Bases: Exception

+

Raised when content is too large to upload to the paste service.

+
+ +
+
+exception PasteUnsupportedLexerError[source]#
+

Bases: Exception

+

Raised when an unsupported lexer is used.

+
+ +
+
+exception PasteUploadError[source]#
+

Bases: Exception

+

Raised when an error is encountered uploading to the paste service.

+
+ +
+
+async send_to_paste_service(*, files, http_session, paste_url='https://paste.pythondiscord.com', max_size=524288)[source]#
+

Upload some contents to the paste service.

+
+
Parameters:
+
    +
  • files (list[PasteFile]) – The files to be uploaded to the paste service.

  • +
  • http_session (aiohttp.ClientSession) – The session to use when POSTing the content to the paste service.

  • +
  • paste_url (str) – The base url to the paste service.

  • +
  • max_size (int) – The max number of bytes to be allowed. Anything larger than MAX_PASTE_SIZE will be rejected.

  • +
+
+
Raises:
+
+
+
Return type:
+

PasteResponse

+
+
Returns:
+

A pydantic model containing both the URL of the paste, and a URL to remove the paste.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.regex.html b/v11.1.0/output/pydis_core.utils.regex.html new file mode 100644 index 00000000..ddea88d4 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.regex.html @@ -0,0 +1,503 @@ + + + + + + + + + regex - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

regex#

+

Common regular expressions.

+
+
+DISCORD_INVITE[source]#
+

Regex for Discord server invites.

+
+

Warning

+

This regex pattern will capture until a whitespace, if you are to use the ‘invite’ capture group in +any HTTP requests or similar. Please ensure you sanitise the output using something +such as urllib.parse.quote().

+
+
+
+
+ +
+
+FORMATTED_CODE_REGEX[source]#
+

Regex for formatted code, using Discord’s code blocks.

+
+
+
+ +
+
+RAW_CODE_REGEX[source]#
+

Regex for raw code, not using Discord’s code blocks.

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file diff --git a/v11.1.0/output/pydis_core.utils.scheduling.html b/v11.1.0/output/pydis_core.utils.scheduling.html new file mode 100644 index 00000000..083433e9 --- /dev/null +++ b/v11.1.0/output/pydis_core.utils.scheduling.html @@ -0,0 +1,636 @@ + + + + + + + + + scheduling - Pydis Core v11.1.0 + + + + + + + + + + + + + + + + + + + Contents + + + + + + Menu + + + + + + + + Expand + + + + + + Light mode + + + + + + + + + + + + + + Dark mode + + + + + + + Auto light/dark mode + + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +
+
+ +
+ +
+
+ +
+
+
+ + + + + Back to top + +
+ +
+ +
+ +
+
+
+

scheduling#

+

Generic python scheduler.

+
+
+class Scheduler(name)[source]#
+

Bases: object

+

Schedule the execution of coroutines and keep track of them.

+

When instantiating a Scheduler, a name must be provided. This name is used to distinguish the +instance’s log messages from other instances. Using the name of the class or module containing +the instance is suggested.

+

Coroutines can be scheduled immediately with schedule or in the future with schedule_at +or schedule_later. A unique ID is required to be given in order to keep track of the +resulting Tasks. Any scheduled task can be cancelled prematurely using cancel by providing +the same ID used to schedule it.

+

The in operator is supported for checking if a task with a given ID is currently scheduled.

+

Any exception raised in a scheduled task is logged when the task is done.

+
+
+__contains__(task_id)[source]#
+

Return True if a task with the given task_id is currently scheduled.

+
+
Parameters:
+

task_id (Hashable) – The task to look for.

+
+
Return type:
+

bool

+
+
Returns:
+

True if the task was found.

+
+
+
+ +
+
+__init__(name)[source]#
+

Initialize a new Scheduler instance.

+
+
Parameters:
+

name (str) – The name of the Scheduler. Used in logging, and namespacing.

+
+
+
+ +
+
+cancel(task_id)[source]#
+

Unschedule the task identified by task_id. Log a warning if the task doesn’t exist.

+
+
Parameters:
+

task_id (Hashable) – The task’s unique ID.

+
+
Return type:
+

None

+
+
+
+ +
+
+cancel_all()[source]#
+

Unschedule all known tasks.

+
+
Return type:
+

None

+
+
+
+ +
+
+schedule(task_id, coroutine)[source]#
+

Schedule the execution of a coroutine.

+

If a task with task_id already exists, close coroutine instead of scheduling it. This +prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

+
+
Parameters:
+
    +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+
+schedule_at(time, task_id, coroutine)[source]#
+

Schedule coroutine to be executed at the given time.

+

If time is timezone aware, then use that timezone to calculate now() when subtracting. +If time is naïve, then use UTC.

+

If time is in the past, schedule coroutine immediately.

+

If a task with task_id already exists, close coroutine instead of scheduling it. This +prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

+
+
Parameters:
+
    +
  • time (datetime) – The time to start the task.

  • +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+
+schedule_later(delay, task_id, coroutine)[source]#
+

Schedule coroutine to be executed after delay seconds.

+

If a task with task_id already exists, close coroutine instead of scheduling it. This +prevents unawaited coroutine warnings. Don’t pass a coroutine that’ll be re-used elsewhere.

+
+
Parameters:
+
    +
  • delay (float) – How long to wait before starting the task.

  • +
  • task_id (Hashable) – A unique ID to create the task with.

  • +
  • coroutine (Coroutine) – The function to be called.

  • +
+
+
Return type:
+

None

+
+
+
+ +
+ +
+
+create_task(coro, *, suppressed_exceptions=(), event_loop=None, **kwargs)[source]#
+

Wrapper for creating an asyncio.Task which logs exceptions raised in the task.

+

If the event_loop kwarg is provided, the task is created from that event loop, +otherwise the running loop is used.

+
+
Parameters:
+
+
+
Returns:
+

The wrapped task.

+
+
Return type:
+

asyncio.Task

+
+
+
+ +
+ +
+
+ +
+ +
+
+ + + + + + \ No newline at end of file -- cgit v1.2.3