From fe5a98ecd9735dc395a7dff01adf7c024a364042 Mon Sep 17 00:00:00 2001
From: wookie184 An async transport method for statsd communication. Bases: An async implementation of Create a new Use Useful utilities and tools for Discord bot development. Bases: A sub-class that implements many common features that Python Discord bots use. ID of the guild that the bot belongs to. The http session used for sending out HTTP requests. The API client used for communications with the site service. The url that statsd sends metrics to. The redis session used to communicate with the Redis instance. The statsd client that sends metrics. All extensions that were found within the Initialise the base bot instance.
StatsClientBase
statsd.client.base.StatsClientBase
that supports async stat communication.
AsyncStatsClient
.
asyncio.loop.create_datagram_endpoint
from the loop given on init to create a socket.
Bot
module
passed to
self.load_extensions
. Use self.extensions
to get the loaded extensions.
@@ -477,7 +477,7 @@
Add the given cog
to the bot and log the operation.
Add command
as normal and then add its root aliases to the bot.
Not implemented! Re-instantiate the bot instead of attempting to re-use a closed one.
Close the Discord connection, and the aiohttp session, connector, statsd client, and resolver.
Load all the extensions within the given module
and save them to self.all_extensions
.
Log the given message to #dev-log.
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.
@@ -578,7 +578,7 @@ will not be set and guild_available_but_cache_empty event will be eClear the internal guild available event when self.guild_id becomes unavailable.
Ping all required services on setup to ensure they are up before starting.
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
.
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.
@@ -625,7 +625,7 @@ So registration needs to happen once the bot instance has been created.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.
@@ -638,7 +638,7 @@ To remove them, either remove the entire command or manually edit bot.all_An async init to startup generic services.
Connects to statsd, and calls
AsyncStatsClient.create_socket
@@ -652,7 +652,7 @@ and
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.
@@ -667,14 +667,14 @@ gateway event before giving up and thus not populating the cache for unavailableBases: Exception
Raised when attempting to paginate with empty contents.
Bases: Paginator
A class that aids in paginating code blocks for Discord messages.
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.
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 @@ -726,7 +726,7 @@ page at a reasonable size.
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 @@ -770,7 +770,7 @@ to any user with a moderation role.
Bases: BaseModel
The emojis that will be used for pagination.
Bases: Exception
Exception class for startup errors.
An API wrapper around the Site API.
Bases: object
A wrapper for the Django Site API.
Initialize a new APIClient
instance.
Close the aiohttp session.
Equivalent to APIClient.request()
with DELETE passed as the method.
Equivalent to APIClient.request()
with GET passed as the method.
Raise ResponseCodeError
for non-OK response if an exception should be raised.
Equivalent to APIClient.request()
with PATCH passed as the method.
Equivalent to APIClient.request()
with POST passed as the method.
Equivalent to APIClient.request()
with PUT passed as the method.
Send an HTTP request to the site API and return the JSON response.
Bases: ValueError
Raised in APIClient.request()
when a non-OK HTTP response is received.
Initialize a new ResponseCodeError
instance.
Return a string representation of the error.
Utilities related to custom caches.
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.
Decorator for async cache.
Initialise a new AsyncCache
instance.
Clear cache instance.
Useful helper functions for interacting with various discord channel objects.
Attempt to get or fetch the given channel_id
from the bots cache, and return it.
Return whether the given channel
in the the category with the id category_id
.
Bases: CheckFailure
Raised when a context-specific check fails.
Bases: ContextCheckFailure
Raised when the in_whitelist check fails.
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.
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.
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.
Check if a command was issued in a context that is whitelisted by channel, category, or roles.
Cleans a text argument or replied message’s content.
Helpers for setting a cooldown on commands.
Bases: CommandError
, Generic
[P
, R
]
Raised when a command is invoked while on cooldown.
Run the command this cooldown blocked.
The command’s signature.
The command’s return value.
alias of TypeVar(‘R’)
Prevent duplicate invocations of a command with the same arguments in a channel for cooldown_duration
seconds.
Bases: ABC
An abstract command error handler.
Handle error raised in the context of app commands.
Handle error raised in the context of text commands.
A predicate that determines whether the error should be handled.
Bases: ABC
An abstract command error handler.
Handle error raised in the context of app commands.
Handle error raised in the context of text commands.
A predicate that determines whether the error should be handled.
Bases: object
A class that registers error handlers and handles all command related errors.
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.
@@ -456,7 +456,7 @@ the error as determined by should_handle_error; there is no prioritRegister a command error handler.
Bases: object
A class that registers error handlers and handles all command related errors.
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.
@@ -416,7 +416,7 @@ the error as determined by should_handle_error; there is no prioritRegister a command error handler.
Handles discord.Forbidden
90001 errors, or re-raises if error
isn’t a 90001 error.
Utils for manipulating functions.
Bases: Exception
Raised on a conflict between the globals used to resolve annotations of a wrapped function and its wrapper.
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.
Return a value from arguments based on a name or position.
Call decorator_func with the value of the arg at the given name/position.
Bind args and kwargs to func and return a mapping of parameter names to argument values.
Default parameter values are also set.
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
diff --git a/main/output/pydis_core.utils.html b/main/output/pydis_core.utils.html
index bfccc513..f08f93ec 100644
--- a/main/output/pydis_core.utils.html
+++ b/main/output/pydis_core.utils.html
@@ -394,7 +394,7 @@
Useful utilities and tools for Discord bot development.
Applies all common monkey patches for our bots.
Return an unqualified name given a qualified module/package name
.
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.
@@ -408,12 +408,12 @@Delete the original message on button click.
Bases: View
A view that allows the original invoker and moderators to interact with it.
None
-
-__init__(*, allowed_users, allowed_roles, timeout=180.0, message=None)[source]¶
+__init__(*, allowed_users, allowed_roles, timeout=180.0, message=None)[source]¶
-
-async interaction_check(interaction)[source]¶
+async interaction_check(interaction)[source]¶
Ensure the user clicking the button is the view invoker, or a moderator.
- Parameters:
@@ -462,7 +462,7 @@ If None
-
-async on_timeout()[source]¶
+async on_timeout()[source]¶
Remove the view from self.message
if set.
- Return type:
@@ -473,7 +473,7 @@ If None
-
-stop()[source]¶
+stop()[source]¶
Stop listening for interactions, and remove the view from self.message
if set.
- Return type:
@@ -486,7 +486,7 @@ If None
-
-user_has_access(user, *, allowed_users=(), allowed_roles=())[source]¶
+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:
diff --git a/main/output/pydis_core.utils.lock.html b/main/output/pydis_core.utils.lock.html
index a80fe041..6478c848 100644
--- a/main/output/pydis_core.utils.lock.html
+++ b/main/output/pydis_core.utils.lock.html
@@ -393,12 +393,12 @@
lock¶
-
-exception LockedResourceError(resource_type, resource_id)[source]¶
+exception LockedResourceError(resource_type, resource_id)[source]¶
Bases: RuntimeError
Exception raised when an operation is attempted on a locked resource.
-
-type[source]¶
+type[source]¶
Name of the locked resource’s type
- Type:
@@ -409,7 +409,7 @@
-
-id[source]¶
+id[source]¶
ID of the locked resource
- Type:
@@ -420,38 +420,38 @@
-
-__init__(resource_type, resource_id)[source]¶
+__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:
@@ -464,7 +464,7 @@ when all of the holders finish the event will be set.
-
-lock(namespace, resource_id, *, raise_error=False, wait=False)[source]¶
+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.
@@ -491,7 +491,7 @@ and return None.
-
-lock_arg(namespace, name_or_pos, func=None, *, raise_error=False, wait=False)[source]¶
+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.
diff --git a/main/output/pydis_core.utils.logging.html b/main/output/pydis_core.utils.logging.html
index e04f9027..f9ea3846 100644
--- a/main/output/pydis_core.utils.logging.html
+++ b/main/output/pydis_core.utils.logging.html
@@ -394,12 +394,12 @@
Common logging related functions.
-
-class CustomLogger(name, level=0)[source]¶
+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]¶
+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)
@@ -423,7 +423,7 @@
-
-get_logger(name=None)[source]¶
+get_logger(name=None)[source]¶
Utility to make mypy recognise that logger is of type CustomLogger
.
- Parameters:
@@ -440,7 +440,7 @@
-
-log_format[source]¶
+log_format[source]¶
A logging.Formatter
that can be used to standardise logging across all projects using pydis_core.
diff --git a/main/output/pydis_core.utils.members.html b/main/output/pydis_core.utils.members.html
index 9431e285..25d08d9e 100644
--- a/main/output/pydis_core.utils.members.html
+++ b/main/output/pydis_core.utils.members.html
@@ -394,7 +394,7 @@
Useful helper functions for interactin with discord.Member
objects.
-
-async get_or_fetch_member(guild, member_id)[source]¶
+async get_or_fetch_member(guild, member_id)[source]¶
Attempt to get a member from cache; on failure fetch from the API.
- Return type:
@@ -408,7 +408,7 @@
-
-async handle_role_change(member, coro, role)[source]¶
+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
.
diff --git a/main/output/pydis_core.utils.messages.html b/main/output/pydis_core.utils.messages.html
index ecd4f084..e0de7153 100644
--- a/main/output/pydis_core.utils.messages.html
+++ b/main/output/pydis_core.utils.messages.html
@@ -393,7 +393,7 @@
messages¶
-
-reaction_check(reaction, user, *, message_id, allowed_emoji, allowed_users, allowed_roles=None)[source]¶
+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.
diff --git a/main/output/pydis_core.utils.pagination.html b/main/output/pydis_core.utils.pagination.html
index 9823d736..b23a7f1d 100644
--- a/main/output/pydis_core.utils.pagination.html
+++ b/main/output/pydis_core.utils.pagination.html
@@ -393,14 +393,14 @@
pagination¶
-
-exception EmptyPaginatorEmbedError[source]¶
+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]¶
+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.
@@ -417,14 +417,14 @@
-
-__init__(prefix='```', suffix='```', max_size=4000, scale_to_size=4000, max_lines=None, linesep='\\n')[source]¶
+__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]¶
+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
@@ -452,7 +452,7 @@ page at a reasonable size.
-
-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]¶
+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
@@ -496,7 +496,7 @@ to any user with a moderation role.
-
-class PaginationEmojis(**data)[source]¶
+class PaginationEmojis(**data)[source]¶
Bases: BaseModel
The emojis that will be used for pagination.
diff --git a/main/output/pydis_core.utils.paste_service.html b/main/output/pydis_core.utils.paste_service.html
index e6c2a30a..f0786020 100644
--- a/main/output/pydis_core.utils.paste_service.html
+++ b/main/output/pydis_core.utils.paste_service.html
@@ -393,13 +393,13 @@
paste_service¶
-
-MAX_PASTE_SIZE = 524288[source]¶
+MAX_PASTE_SIZE = 524288[source]¶
The maximum allows size of a paste, in bytes.
-
-class PasteFile(**data)[source]¶
+class PasteFile(**data)[source]¶
Bases: BaseModel
A file to be pasted to the paste service.
@@ -435,7 +435,7 @@ mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
-
-class PasteResponse(**data)[source]¶
+class PasteResponse(**data)[source]¶
Bases: BaseModel
A successful response from the paste service.
@@ -470,28 +470,28 @@ mapping of field names to [FieldInfo][pydantic.fields.FieldInfo].
-
-exception PasteTooLongError[source]¶
+exception PasteTooLongError[source]¶
Bases: Exception
Raised when content is too large to upload to the paste service.
-
-exception PasteUnsupportedLexerError[source]¶
+exception PasteUnsupportedLexerError[source]¶
Bases: Exception
Raised when an unsupported lexer is used.
-
-exception PasteUploadError[source]¶
+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]¶
+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:
diff --git a/main/output/pydis_core.utils.regex.html b/main/output/pydis_core.utils.regex.html
index 8321f52d..48c079a4 100644
--- a/main/output/pydis_core.utils.regex.html
+++ b/main/output/pydis_core.utils.regex.html
@@ -394,7 +394,7 @@
Common regular expressions.
-
-DISCORD_INVITE[source]¶
+DISCORD_INVITE[source]¶
Regex for Discord server invites.
Warning
@@ -408,7 +408,7 @@ such as
-
-FORMATTED_CODE_REGEX
+
+