tanjun.abc#
Interfaces of the objects and clients used within Tanjun.
AnyCheckSig module-attribute
#
AnyCheckSig = CheckSig['Context']
Type hint of a check callback for any command type.
AutocompleteCallbackSig module-attribute
#
AutocompleteCallbackSig = AutocompleteSig[_AutocompleteValueT]
Deprecated alias of AutocompleteSig.
AutocompleteSig module-attribute
#
AutocompleteSig = Callable[Concatenate['AutocompleteContext', _AutocompleteValueT, ...], _CoroT[None]]
Type hint of the signature an autocomplete callback should have.
This represents the signature async def (AutocompleteContext, int | str | float) -> None
where dependency injection is supported.
CheckSig module-attribute
#
CheckSig = Callable[Concatenate[_ContextT_contra, ...], _MaybeAwaitable[bool]]
Type hint of a generic context check used with Tanjun commands.
This may be registered with a command, client or component to add a rule which decides whether it should execute for each context passed to it.
This represents the signatures def (Context, ...) -> bool | None
and async def (Context, ...) -> bool | None
where dependency injection is supported.
Check callbacks may either return False to indicate that the current command(s) don't match the context (without stopping execution) or raise tanjun.FailedCheck to indicate that command execution should be halted early and marked as not found.
CommandCallbackSig module-attribute
#
CommandCallbackSig = Callable[..., _CoroT[None]]
Deprecated type hint used to represent any command callback.
ErrorHookSig module-attribute
#
ErrorHookSig = Callable[Concatenate[_ContextT_contra, Exception, ...], _MaybeAwaitable[bool | None]]
Type hint of the callback used as a unexpected command error hook.
This will be called whenever an unexpected Exception is raised during the execution stage of a command (ignoring tanjun.ParserError and expected tanjun.TanjunError subclasses).
This represents the signatures def (Context, Exception, ...) -> bool | None
and async def (Context, Exception, ...) -> bool | None
where dependency injection is supported.
True is returned to indicate that the exception should be suppressed and False is returned to indicate that the exception should be re-raised.
HookSig module-attribute
#
HookSig = Callable[Concatenate[_ContextT_contra, ...], _MaybeAwaitable[None]]
Type hint of the callback used as a general command hook.
This represents the signatures def (Context, ...) -> None
and async def (Context, ...) -> None
where dependency injection is supported.
ListenerCallbackSig module-attribute
#
ListenerCallbackSig = Callable[Concatenate[_EventT, ...], _CoroT[None]]
Type hint of a hikari event manager callback.
This represents the signature async def (hikari.Event, ...) -> None
where dependency injection is supported.
MenuCallbackSig module-attribute
#
MenuCallbackSig = Callable[Concatenate['MenuContext', _MenuValueT, ...], _CoroT[None]]
Type hint of a context menu command callback.
This represents the signature async def (MenuContext, hikari.Message, ...) -> None
or async def (MenuContext, hikari.InteractionMember, ...) -> None
where dependency injection is supported.
MenuCommandCallbackSig module-attribute
#
MenuCommandCallbackSig = MenuCallbackSig[_MenuValueT]
Deprecated alias of MenuCallbackSig.
MessageCallbackSig module-attribute
#
MessageCallbackSig = _CommandCallbackSig['MessageContext']
Type hint of a message command callback.
This represents the signature async def (MessageContext, ...) -> None
where dependency injection is supported.
MessageHooks module-attribute
#
MessageHooks = Hooks[MessageContext]
Execution hooks for messages commands.
MetaEventSig module-attribute
#
MetaEventSig = Callable[..., _CoroT[None] | None]
Type hint of a client callback.
The positional arguments this is guaranteed depend on the event name its being subscribed to (more information the standard client callbacks can be found at ClientCallbackNames) and may be either synchronous or asynchronous but must return None.
NO_DEFAULT module-attribute
#
NO_DEFAULT = NO_DEFAULT
Singleton used to mark an argument as having no default.
NO_PASS module-attribute
#
NO_PASS = NO_PASS
Singleton used to mark an argument as being not passed when it isn't provided.
ParserHookSig module-attribute
#
ParserHookSig = Callable[Concatenate[_ContextT_contra, 'errors.ParserError', ...], _MaybeAwaitable[bool | None]]
Type hint of the callback used as a command parser error hook.
This will be called whenever an parser ParserError is raised during the execution stage of a command.
This represents the signatures def (Context, tanjun.ParserError, ...) -> None
and async def (Context, tanjun.ParserError, ...) -> None
where dependency injection is supported.
Parser errors are always suppressed (unlike general errors).
SlashCallbackSig module-attribute
#
SlashCallbackSig = _CommandCallbackSig['SlashContext']
Type hint of a slash command callback.
This represents the signature async def (SlashContext, ...) -> None
where dependency injection is supported.
AppCommand #
Bases: ExecutableCommand[_AppCommandContextT]
Base class for all application command classes.
checks abstractmethod
property
#
checks
Collection of checks that must be met before the command can be executed.
default_member_permissions abstractmethod
property
#
default_member_permissions
The default guild member permissions required to use this command.
Warning
This can be overridden by guild staff and does not apply to admins.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
defaults_to_ephemeral abstractmethod
property
#
defaults_to_ephemeral
Whether contexts executed by this command should default to ephemeral responses.
This effects calls to AppCommandContext.create_followup, AppCommandContext.create_initial_response, AppCommandContext.defer and AppCommandContext.respond unless the flags
field is provided for the methods which support it.
Note
If this is None then the default from the parent command(s), component or client is used.
is_dm_enabled abstractmethod
property
#
is_dm_enabled
Whether this command is enabled in DM contexts.
Note
If this is None then the default from the parent component or client is used.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
is_global abstractmethod
property
#
is_global
Whether the command should be declared globally or not.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
metadata abstractmethod
property
#
metadata
Mutable mapping of metadata set for this command.
Note
Any modifications made to this mutable mapping will be preserved by the command.
tracked_command abstractmethod
property
#
tracked_command
Object of the actual command this object tracks if set.
tracked_command_id abstractmethod
property
#
tracked_command_id
ID of the actual command this object tracks if set.
add_check abstractmethod
#
add_check(*checks)
build abstractmethod
#
build(*, component=None)
Get a builder object for this command.
Parameters:
-
component
(Component | None
, default:None
) –The component to inherit config like
default_member_permissions
andis_dm_enabled
from if not explicitly set on the command.This defaults to the command's linked component.
Returns:
-
CommandBuilder
–A builder object for this command. Use to declare this command on globally or for a specific guild.
remove_check abstractmethod
#
remove_check(check)
Remove a check from the command.
Parameters:
-
check
(CheckSig[_ContextT_co]
) –The check to remove.
Raises:
-
ValueError
–If the provided check isn't found.
Returns:
-
Self
–This command to enable chained calls
set_hooks abstractmethod
#
set_hooks(hooks)
set_metadata abstractmethod
#
set_metadata(key, value)
set_tracked_command abstractmethod
#
set_tracked_command(command)
Set the global command this tracks.
Parameters:
-
command
(PartialCommand
) –Object of the global command this tracks.
Returns:
-
Self
–The command instance to enable chained calls.
AppCommandContext #
Base class for application command contexts.
cache abstractmethod
property
#
cache
Hikari cache instance this context's command client was initialised with.
command abstractmethod
property
#
command
Object of the command this context is bound to.
Note
This will only be None before this has been bound to a specific command but never during command execution.
component abstractmethod
property
#
component
defaults_to_ephemeral abstractmethod
property
#
defaults_to_ephemeral
Whether the context is marked as defaulting to ephemeral response.
This effects calls to AppCommandContext.create_followup, AppCommandContext.create_initial_response, AppCommandContext.defer and AppCommandContext.respond unless the flags
field is provided for the methods which support it.
events abstractmethod
property
#
events
Object of the event manager this context's client was initialised with.
expires_at abstractmethod
property
#
expires_at
When this application command context expires.
After this time is reached, the message/response methods on this context will always raise hikari.NotFoundError.
guild_id abstractmethod
property
#
guild_id
ID of the guild this command was executed in.
Will be None for all DM command executions.
has_been_deferred abstractmethod
property
#
has_been_deferred
Whether the initial response for this context has been deferred.
Warning
If this is True when AppCommandContext.has_responded is False then AppCommandContext.edit_initial_response will need to be used to create the initial response rather than AppCommandContext.create_initial_response.
has_responded abstractmethod
property
#
has_responded
Whether an initial response has been made for this context.
is_human abstractmethod
property
#
is_human
Whether this command execution was triggered by a human.
Will be False for bot and webhook triggered commands.
member abstractmethod
property
#
member
Object of the member that triggered this command if this is in a guild.
rest abstractmethod
property
#
rest
Object of the Hikari REST client this context's client was initialised with.
server abstractmethod
property
#
server
Object of the Hikari interaction server provided for this context's client.
shard abstractmethod
property
#
shard
Shard that triggered the context.
Note
This will be None if Context.shards is also None.
shards abstractmethod
property
#
shards
Object of the Hikari shard manager this context's client was initialised with.
triggering_name abstractmethod
property
#
triggering_name
Command name this execution was triggered with.
voice abstractmethod
property
#
voice
Object of the Hikari voice component this context's client was initialised with.
create_followup abstractmethod
async
#
create_followup(content=hikari.UNDEFINED, *, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, tts=hikari.UNDEFINED, flags=hikari.UNDEFINED)
Create a followup response for this context.
Warning
Calling this on a context which hasn't had an initial response yet will lead to a hikari.NotFoundError being raised.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to send.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
ephemeral
(bool | None
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. -
attachment
(UndefinedOr[Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
-
attachments
(UndefinedOr[Sequence[Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
-
embed
(UndefinedOr[Embed]
, default:UNDEFINED
) –If provided, the message embed.
-
embeds
(UndefinedOr[Sequence[Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
-
tts
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be sent as a TTS message.
-
flags
(UndefinedType | int | MessageFlag
, default:UNDEFINED
) –The flags to set for this response.
As of writing this can only flag which can be provided is EPHEMERAL, other flags are just ignored.
Returns:
-
Message
–The created message object.
Raises:
-
NotFoundError
–If the current interaction is not found or it hasn't had an initial response yet.
-
BadRequestError
–This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than
2000
characters; if neither content, file or embeds are specified. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. -
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
or `user_mentions.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed.
create_initial_response abstractmethod
async
#
create_initial_response(content=hikari.UNDEFINED, *, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, flags=hikari.UNDEFINED, tts=hikari.UNDEFINED)
Create the initial response for this context.
Warning
Calling this on a context which already has an initial response will result in this raising a hikari.NotFoundError. This includes if the REST interaction server has already responded to the request and deferrals.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
ephemeral
(bool | None
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. -
attachment
(UndefinedOr[Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
-
attachments
(UndefinedOr[Sequence[Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
-
embed
(UndefinedOr[Embed]
, default:UNDEFINED
) –If provided, the message embed.
-
embeds
(UndefinedOr[Sequence[Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
-
flags
(int | MessageFlag | UndefinedType
, default:UNDEFINED
) –If provided, the message flags this response should have.
As of writing the only message flag which can be set here is MessageFlag.EPHEMERAL.
-
tts
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
NotFoundError
–If the interaction is not found or if the interaction's initial response has already been created.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
create_modal_response abstractmethod
async
#
create_modal_response(title, custom_id, /, *, component=hikari.UNDEFINED, components=hikari.UNDEFINED)
Send a modal as the initial response for this context.
Warning
This must be called as the first response to a context before any deferring.
Parameters:
-
title
(str
) –The title that will show up in the modal.
-
custom_id
(str
) –Developer set custom ID used for identifying interactions with this modal.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –A component builder to send in this modal.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –A sequence of component builders to send in this modal.
Raises:
-
ValueError
–If both
component
andcomponents
are specified or if none are specified. -
BadRequestError
–When the requests' data is outside Discord's accept ranges/validation.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
NotFoundError
–If the interaction is not found or if the interaction's initial response has already been created or deferred.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
defer abstractmethod
async
#
defer(*, ephemeral=None, flags=hikari.UNDEFINED)
Defer the initial response for this context.
Note
The ephemeral state of the first response is decided by whether the deferral is ephemeral.
Parameters:
-
ephemeral
(bool | None
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. -
flags
(UndefinedType | int | MessageFlag
, default:UNDEFINED
) –The flags to use for the initial response.
delete_initial_response abstractmethod
async
#
delete_initial_response()
Delete the initial response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no initial response.
delete_last_response abstractmethod
async
#
delete_last_response()
Delete the last response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no responses.
edit_initial_response abstractmethod
async
#
edit_initial_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the initial response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to edit the initial response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the initial response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the initial response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the initial response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the initial response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
edit_last_response abstractmethod
async
#
edit_last_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the last response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the content to edit the last response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the last response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the last response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the last response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the last response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_channel abstractmethod
async
#
fetch_channel()
Fetch the channel the context was invoked in.
Note
This performs an API call. Consider using Context.get_channelif you have the CacheComponents.GUILD_CHANNELS cache component enabled.
Returns:
-
TextableChannel
–The textable DM or guild channel the context was invoked in.
Raises:
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
READ_MESSAGES
permission in the channel. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_guild abstractmethod
async
#
fetch_guild()
Fetch the guild the context was invoked in.
Note
This performs an API call. Consider using Context.get_guild if you have the CacheComponents.GUILDS cache component enabled.
Returns:
-
Guild | None
–An optional guild the context was invoked in. None will be returned if the context was invoked in a DM channel.
Raises:
-
ForbiddenError
–If you are not part of the guild.
-
NotFoundError
–If the guild is not found.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_initial_response abstractmethod
async
#
fetch_initial_response()
Fetch the initial response for this context.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
fetch_last_response abstractmethod
async
#
fetch_last_response()
Fetch the last response for this context.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
get_channel abstractmethod
#
get_channel()
Retrieve the channel the context was invoked in from the cache.
Note
This method requires the CacheComponents.GUILD_CHANNELS cache component.
Returns:
-
TextableGuildChannel | None
–An optional guild channel the context was invoked in. None will be returned if the channel was not found or if it is DM channel.
get_guild abstractmethod
#
get_guild()
Fetch the guild that the context was invoked in.
Note
This method requires the CacheComponents.GUILDS cache component.
Returns:
mark_not_found abstractmethod
async
#
mark_not_found()
Mark this context as not found.
Dependent on how the client is configured this may lead to a not found response message being sent.
respond abstractmethod
async
#
respond(content: hikari.UndefinedOr[typing.Any] = hikari.UNDEFINED, *, ensure_result: typing.Literal[True], delete_after: datetime.timedelta | float | int | None = None, attachment: hikari.UndefinedOr[hikari.Resourceish] = hikari.UNDEFINED, attachments: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] = hikari.UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = hikari.UNDEFINED, components: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] = hikari.UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = hikari.UNDEFINED, embeds: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] = hikari.UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = hikari.UNDEFINED, user_mentions: hikari.SnowflakeishSequence[hikari.PartialUser] | bool | hikari.UndefinedType = hikari.UNDEFINED, role_mentions: hikari.SnowflakeishSequence[hikari.PartialRole] | bool | hikari.UndefinedType = hikari.UNDEFINED) -> hikari.Message
respond(content: hikari.UndefinedOr[typing.Any] = hikari.UNDEFINED, *, ensure_result: bool = False, delete_after: datetime.timedelta | float | int | None = None, attachment: hikari.UndefinedOr[hikari.Resourceish] = hikari.UNDEFINED, attachments: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] = hikari.UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = hikari.UNDEFINED, components: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] = hikari.UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = hikari.UNDEFINED, embeds: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] = hikari.UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = hikari.UNDEFINED, user_mentions: hikari.SnowflakeishSequence[hikari.PartialUser] | bool | hikari.UndefinedType = hikari.UNDEFINED, role_mentions: hikari.SnowflakeishSequence[hikari.PartialRole] | bool | hikari.UndefinedType = hikari.UNDEFINED) -> hikari.Message | None
respond(content=hikari.UNDEFINED, *, ensure_result=False, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Respond to this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
ensure_result
(bool
, default:False
) –Ensure that this call will always return a message object.
If True then this will always return hikari.Message, otherwise this will return
hikari.Message | None
.It's worth noting that, under certain scenarios within the slash command flow, this may lead to an extre request being made.
-
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedOr[Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
-
attachments
(UndefinedOr[Sequence[Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this response.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this response.
-
embed
(UndefinedOr[Embed]
, default:UNDEFINED
) –An embed to respond with.
-
embeds
(UndefinedOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to respond with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message | None
–
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
AutocompleteContext #
Bases: Context
Interface of an autocomplete context.
cache abstractmethod
property
#
cache
Hikari cache instance this context's client was initialised with.
channel_id abstractmethod
property
#
channel_id
ID of the channel this autocomplete was triggered in.
created_at abstractmethod
property
#
created_at
When this context was created.
Note
This will either refer to a message or integration's creation date.
events abstractmethod
property
#
events
Object of the event manager this context's client was initialised with.
guild_id abstractmethod
property
#
guild_id
ID of the guild this autocomplete was triggered in.
Will be None for all DM autocomplete executions.
has_responded abstractmethod
property
#
has_responded
Whether the choices have been set for this autocomplete.
member abstractmethod
property
#
member
Guild member object of this autocomplete's author.
Will be None for DM autocomplete executions.
rest abstractmethod
property
#
rest
Object of the Hikari REST client this context's client was initialised with.
server abstractmethod
property
#
server
Object of the Hikari interaction server provided for this context's client.
shard abstractmethod
property
#
shard
Shard that triggered the context.
Note
This will be None if AutocompleteContext.shards is also None.
shards abstractmethod
property
#
shards
Object of the Hikari shard manager this context's client was initialised with.
triggering_name abstractmethod
property
#
triggering_name
Full command name this autocomplete was triggered for.
voice abstractmethod
property
#
voice
Object of the Hikari voice component this context's client was initialised with.
fetch_channel abstractmethod
async
#
fetch_channel()
Fetch the channel the context was invoked in.
Note
This performs an API call. Consider using AutocompleteContext.get_channel if you have the CacheComponents.GUILD_CHANNELS cache component enabled.
Returns:
-
TextableChannel
–The textable DM or guild channel the context was invoked in.
Raises:
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
READ_MESSAGES
permission in the channel. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_guild abstractmethod
async
#
fetch_guild()
Fetch the guild the context was invoked in.
Note
This performs an API call. Consider using AutocompleteContext.get_guild if you have the CacheComponents.GUILDS cache component enabled.
Returns:
-
Guild | None
–An optional guild the context was invoked in. None will be returned if the context was invoked in a DM channel.
Raises:
-
ForbiddenError
–If you are not part of the guild.
-
NotFoundError
–If the guild is not found.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
get_channel abstractmethod
#
get_channel()
Retrieve the channel the context was invoked in from the cache.
Note
This method requires the CacheComponents.GUILD_CHANNELS cache component.
Returns:
-
TextableGuildChannel | None
–An optional guild channel the context was invoked in. None will be returned if the channel was not found or if it is DM channel.
get_guild abstractmethod
#
get_guild()
Fetch the guild that the context was invoked in.
Note
This method requires the CacheComponents.GUILDS cache component.
Returns:
set_choices abstractmethod
async
#
set_choices(choices=..., /, **kwargs)
Set the choices for this autocomplete.
Note
Only up to (and including) 25 choices may be set for an autocomplete.
Parameters:
-
choices
(Mapping[str, str | float | int]
, default:...
) –Mapping of string option names to their values.
The values should match the focused option's relevant type.
-
**kwargs
(str | float | int
, default:{}
) –Keyword arguments mapping string option names to their values.
The value should match the focused option's relevant type.
Raises:
-
RuntimeError
–If the context has already had the choices set for it.
-
ValueError
–If more than 25 choices are passed.
BaseSlashCommand #
Bases: AppCommand[SlashContext]
, ABC
Base class for all slash command classes.
checks abstractmethod
property
#
checks
Collection of checks that must be met before the command can be executed.
default_member_permissions abstractmethod
property
#
default_member_permissions
The default guild member permissions required to use this command.
Warning
This can be overridden by guild staff and does not apply to admins.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
defaults_to_ephemeral abstractmethod
property
#
defaults_to_ephemeral
Whether contexts executed by this command should default to ephemeral responses.
This effects calls to AppCommandContext.create_followup, AppCommandContext.create_initial_response, AppCommandContext.defer and AppCommandContext.respond unless the flags
field is provided for the methods which support it.
Note
If this is None then the default from the parent command(s), component or client is used.
is_dm_enabled abstractmethod
property
#
is_dm_enabled
Whether this command is enabled in DM contexts.
Note
If this is None then the default from the parent component or client is used.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
is_global abstractmethod
property
#
is_global
Whether the command should be declared globally or not.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
metadata abstractmethod
property
#
metadata
Mutable mapping of metadata set for this command.
Note
Any modifications made to this mutable mapping will be preserved by the command.
tracked_command abstractmethod
property
#
tracked_command
Object of the actual command this object tracks if set.
tracked_command_id abstractmethod
property
#
tracked_command_id
ID of the actual command this object tracks if set.
add_check abstractmethod
#
add_check(*checks)
build abstractmethod
#
build(*, component=None)
Get a builder object for this command.
Parameters:
-
component
(Component | None
, default:None
) –The component to inherit config like
default_member_permissions
andis_dm_enabled
from if not explicitly set on the command.This defaults to the command's linked component.
Returns:
-
SlashCommandBuilder
–A builder object for this command. Use to declare this command on globally or for a specific guild.
copy abstractmethod
#
copy(*, parent=None)
Create a copy of this command.
Parameters:
-
parent
(SlashCommandGroup | None
, default:None
) –The parent of the copy.
Returns:
-
Self
–The copy.
remove_check abstractmethod
#
remove_check(check)
Remove a check from the command.
Parameters:
-
check
(CheckSig[_ContextT_co]
) –The check to remove.
Raises:
-
ValueError
–If the provided check isn't found.
Returns:
-
Self
–This command to enable chained calls
set_hooks abstractmethod
#
set_hooks(hooks)
set_metadata abstractmethod
#
set_metadata(key, value)
set_tracked_command abstractmethod
#
set_tracked_command(command)
Set the global command this tracks.
Parameters:
-
command
(PartialCommand
) –Object of the global command this tracks.
Returns:
-
Self
–The command instance to enable chained calls.
Client #
Bases: ABC
Abstract interface of a Tanjun client.
This should manage both message and slash command execution based on the provided hikari clients.
cache abstractmethod
property
#
cache
Hikari cache instance this command client was initialised with.
components abstractmethod
property
#
components
Collection of the components this command client is using.
default_app_cmd_permissions abstractmethod
property
#
default_app_cmd_permissions
Default required guild member permissions for the commands in this client.
This may be overridden by Component.default_app_cmd_permissions and AppCommand.default_member_permissions; this defaults to no required permissions.
Warning
This may be overridden by guild staff and does not apply to admins.
defaults_to_ephemeral abstractmethod
property
#
defaults_to_ephemeral
Whether slash contexts spawned by this client should default to ephemeral responses.
This effects calls to AppCommandContext.create_followup, AppCommandContext.create_initial_response, AppCommandContext.defer and AppCommandContext.respond unless the flags
field is provided for the methods which support it.
This defaults to False.
Note
This may be overridden by AppCommand.defaults_to_ephemeral and Component.defaults_to_ephemeral and only effects slash command execution.
dms_enabled_for_app_cmds abstractmethod
property
#
dms_enabled_for_app_cmds
Whether application commands in this client should be enabled in DMs by default.
This defaults to True.
Note
This may be overridden by AppCommand.is_dm_enabled and Component.dms_enabled_for_app_cmds.
events abstractmethod
property
#
events
Object of the event manager this client was initialised with.
This is used for executing message commands if set.
is_case_sensitive abstractmethod
property
#
is_case_sensitive
Whether this client should treat message command names case sensitive in search.
listeners abstractmethod
property
#
listeners
Mapping of event types to the listeners registered in this client.
metadata abstractmethod
property
#
metadata
Mutable mapping of the metadata set for this client.
Note
Any modifications made to this mutable mapping will be preserved by the client.
prefixes abstractmethod
property
#
prefixes
Collection of the prefixes set for this client.
These are only use during message command execution to match commands to this command client.
rest abstractmethod
property
#
rest
Object of the Hikari REST client this client was initialised with.
server abstractmethod
property
#
server
Object of the Hikari interaction server provided for this client.
This is used for executing application commands if set.
shards abstractmethod
property
#
shards
Object of the Hikari shard manager this client was initialised with.
voice abstractmethod
property
#
voice
Object of the Hikari voice component this client was initialised with.
add_client_callback abstractmethod
#
add_client_callback(name, /, *callbacks)
Add a client callback.
Parameters:
-
name
(str | ClientCallbackNames
) –The name this callback is being registered to.
This is case-insensitive.
-
*callbacks
(MetaEventSig
, default:()
) –The callbacks to register.
These may be sync or async and must return None. The positional and keyword arguments a callback should expect depend on implementation detail around the
name
being subscribed to.
Returns:
-
Self
–The client instance to enable chained calls.
add_component abstractmethod
#
add_component(component)
add_listener abstractmethod
#
add_listener(event_type, /, *callbacks)
Add a listener to the client.
Parameters:
-
event_type
(type[Event]
) –The event type to add a listener for.
-
*callbacks
(ListenerCallbackSig[_EventT]
, default:()
) –The callbacks to register as a listener.
These callbacks must be coroutine functions which returns None and always takes one positional arg of the event type passed for
event_type
regardless of client implementation detail.
Returns:
-
Self
–The client instance to enable chained calls.
check_message_name abstractmethod
#
check_message_name(name, /, *, case_sensitive=True)
Check whether a message command name is present in the current client.
Note
Dependent on implementation this may partial check name against the message command's name based on command_name.startswith(name).
Parameters:
-
name
(str
) –The name to match commands against.
-
case_sensitive
(bool
, default:True
) –Whether to match case sensitively.
Returns:
-
Iterator[tuple[str, MessageCommand]]
–Iterator of the matched command names to the matched message command objects.
check_slash_name abstractmethod
#
check_slash_name(name)
Check whether a slash command name is present in the current client.
Note
This won't check the commands within command groups.
Parameters:
-
name
(str
) –Name to check against.
Returns:
-
Iterator[BaseSlashCommand]
–Iterator of the matched slash command objects.
clear_application_commands abstractmethod
async
#
clear_application_commands(*, application=None, guild=hikari.UNDEFINED)
Clear the commands declared either globally or for a specific guild.
Note
The endpoint this uses has a strict ratelimit which, as of writing, only allows for 2 requests per minute (with that ratelimit either being per-guild if targeting a specific guild otherwise globally).
Parameters:
-
application
(SnowflakeishOr[PartialApplication] | None
, default:None
) –The application to clear commands for.
If left as None then this will be inferred from the authorization being used by Client.rest.
-
guild
(UndefinedOr[SnowflakeishOr[PartialGuild]]
, default:UNDEFINED
) –Object or ID of the guild to clear commands for.
If left as None global commands will be cleared.
declare_application_command abstractmethod
async
#
declare_application_command(command: BaseSlashCommand, /, command_id: hikari.Snowflakeish | None = None, *, application: hikari.SnowflakeishOr[hikari.PartialApplication] | None = None, guild: hikari.UndefinedOr[hikari.SnowflakeishOr[hikari.PartialGuild]] = hikari.UNDEFINED) -> hikari.SlashCommand
declare_application_command(command: MenuCommand[typing.Any, typing.Any], /, command_id: hikari.Snowflakeish | None = None, *, application: hikari.SnowflakeishOr[hikari.PartialApplication] | None = None, guild: hikari.UndefinedOr[hikari.SnowflakeishOr[hikari.PartialGuild]] = hikari.UNDEFINED) -> hikari.ContextMenuCommand
declare_application_command(command: AppCommand[typing.Any], /, command_id: hikari.Snowflakeish | None = None, *, application: hikari.SnowflakeishOr[hikari.PartialApplication] | None = None, guild: hikari.UndefinedOr[hikari.SnowflakeishOr[hikari.PartialGuild]] = hikari.UNDEFINED) -> hikari.PartialCommand
declare_application_command(command, /, command_id=None, *, application=None, guild=hikari.UNDEFINED)
Declare a single slash command for a bot.
Warning
Providing command_id
when updating a command helps avoid any permissions set for the command being lose (e.g. when changing the command's name).
Parameters:
-
command
(AppCommand[Any]
) –The command to register.
-
application
(SnowflakeishOr[PartialApplication] | None
, default:None
) –The application to register the command with.
If left as None then this will be inferred from the authorization being used by Client.rest.
-
command_id
(Snowflakeish | None
, default:None
) –ID of the command to update.
-
guild
(UndefinedOr[SnowflakeishOr[PartialGuild]]
, default:UNDEFINED
) –Object or ID of the guild to register the command with.
If left as None then the command will be registered globally.
Returns:
-
PartialCommand
–API representation of the command that was registered.
declare_application_commands abstractmethod
async
#
declare_application_commands(commands, /, command_ids=None, *, application=None, guild=hikari.UNDEFINED, message_ids=None, user_ids=None, force=False)
Declare a collection of slash commands for a bot.
Note
The endpoint this uses has a strict ratelimit which, as of writing, only allows for 2 requests per minute (with that ratelimit either being per-guild if targeting a specific guild otherwise globally).
Parameters:
-
commands
(Iterable[AppCommand[Any] | CommandBuilder]
) –Iterable of the commands objects or builders to register.
-
command_ids
(Mapping[str, SnowflakeishOr[PartialCommand]] | None
, default:None
) –If provided, a mapping of top level command names to IDs of the existing commands to update.
This will be used for all application commands but in cases where commands have overlapping names,
message_ids
anduser_ids
will take priority over this for their relevant command type.While optional, this can be helpful when updating commands as providing the current IDs will prevent changes such as renames from leading to other state set for commands (e.g. permissions) from being lost.
-
application
(SnowflakeishOr[PartialApplication] | None
, default:None
) –The application to register the commands with.
If left as None then this will be inferred from the authorization being used by Client.rest.
-
guild
(UndefinedOr[SnowflakeishOr[PartialGuild]]
, default:UNDEFINED
) –Object or ID of the guild to register the commands with.
If left as None then the commands will be registered globally.
-
message_ids
(Mapping[str, SnowflakeishOr[PartialCommand]] | None
, default:None
) –If provided, a mapping of message context menu command names to the IDs of existing commands to update.
-
user_ids
(Mapping[str, SnowflakeishOr[PartialCommand]] | None
, default:None
) –If provided, a mapping of user context menu command names to the IDs of existing commands to update.
-
force
(bool
, default:False
) –Force this to declare the commands regardless of whether or not they match the current state of the declared commands.
The default behaviour helps avoid issues with the 2 request per minute (per-guild or globally) ratelimit and the other limit of only 200 application command creates per day (per guild or globally).
Returns:
-
Sequence[PartialCommand]
–API representations of the commands which were registered.
Raises:
-
ValueError
–Raises a value error for any of the following reasons:
- If conflicting command names are found (multiple commanbds have the same top-level name).
- If more than 100 top-level commands are passed.
declare_global_commands abstractmethod
async
#
declare_global_commands(command_ids=None, *, application=None, guild=hikari.UNDEFINED, message_ids=None, user_ids=None, force=False)
Set the global application commands for a bot based on the loaded components.
Warning
This will overwrite any previously set application commands and only targets commands marked as global.
Note
The endpoint this uses has a strict ratelimit which, as of writing, only allows for 2 requests per minute (with that ratelimit either being per-guild if targeting a specific guild otherwise globally).
Parameters:
-
command_ids
(Mapping[str, SnowflakeishOr[PartialCommand]] | None
, default:None
) –If provided, a mapping of top level command names to IDs of the existing commands to update.
This will be used for all application commands but in cases where commands have overlapping names,
message_ids
anduser_ids
will take priority over this for their relevant command type. -
application
(SnowflakeishOr[PartialApplication] | None
, default:None
) –Object or ID of the application to set the global commands for.
If left as None then this will be inferred from the authorization being used by Client.rest.
-
guild
(UndefinedOr[SnowflakeishOr[PartialGuild]]
, default:UNDEFINED
) –Object or ID of the guild to set the global commands to.
If left as None global commands will be set.
-
message_ids
(Mapping[str, SnowflakeishOr[PartialCommand]] | None
, default:None
) –If provided, a mapping of message context menu command names to the IDs of existing commands to update.
-
user_ids
(Mapping[str, SnowflakeishOr[PartialCommand]] | None
, default:None
) –If provided, a mapping of user context menu command names to the IDs of existing commands to update.
-
force
(bool
, default:False
) –Force this to declare the commands regardless of whether or not they match the current state of the declared commands.
The default behaviour helps avoid issues with the 2 request per minute (per-guild or globally) ratelimit and the other limit of only 200 application command creates per day (per guild or globally).
Returns:
-
Sequence[PartialCommand]
–API representations of the set commands.
dispatch_client_callback abstractmethod
async
#
dispatch_client_callback(name, /, *args)
Dispatch a client callback.
Parameters:
-
name
(str | ClientCallbackNames
) –The name of the callback to dispatch.
-
*args
(Any
, default:()
) –Positional arguments to pass to the callback(s).
Raises:
-
KeyError
–If no callbacks are registered for the given name.
get_callback_override abstractmethod
#
get_callback_override(callback)
Get the override for a specific injected callback.
Parameters:
-
callback
(CallbackSig[_T]
) –The injected callback to get the override for.
Returns:
-
CallbackSig | None
–The override if found, else None.
get_client_callbacks abstractmethod
#
get_client_callbacks(name)
Get a collection of the callbacks registered for a specific name.
Parameters:
-
name
(str | ClientCallbackNames
) –The name to get the callbacks registered for.
This is case-insensitive.
Returns:
-
Collection[MetaEventSig]
–Collection of the callbacks for the provided name.
get_component_by_name abstractmethod
#
get_component_by_name(name)
get_type_dependency abstractmethod
#
get_type_dependency(type_: type[_T]) -> _T
get_type_dependency(type_: type[_T], /, *, default: _DefaultT) -> _T | _DefaultT
get_type_dependency(type_, /, *, default=...)
Get the implementation for an injected type.
Parameters:
-
type_
(type[_T]
) –The associated type.
-
default
(_DefaultT
, default:...
) –The default value to return if the type is not implemented.
Returns:
-
_T | _DefaultT
–The resolved type if found.
If the type isn't implemented then the value of
default
will be returned if it is provided.
Raises:
-
KeyError
–If no dependency was found when no default was provided.
iter_commands abstractmethod
#
iter_commands()
Iterate over all the commands (both message and slash) registered to this client.
Returns:
-
Iterator[ExecutableCommand[Context]]
–Iterator of all the commands registered to this client.
iter_menu_commands abstractmethod
#
iter_menu_commands(*, global_only: bool = False, type: typing.Literal[hikari.CommandType.MESSAGE]) -> collections.Iterator[MenuCommand[typing.Any, typing.Literal[hikari.CommandType.MESSAGE]]]
iter_menu_commands(*, global_only: bool = False, type: typing.Literal[hikari.CommandType.USER]) -> collections.Iterator[MenuCommand[typing.Any, typing.Literal[hikari.CommandType.USER]]]
iter_menu_commands(*, global_only: bool = False, type: hikari.CommandType | None = None) -> collections.Iterator[MenuCommand[typing.Any, typing.Any]]
iter_menu_commands(*, global_only=False, type=None)
Iterator over the menu commands registered to this client.
Parameters:
-
global_only
(bool
, default:False
) –Whether to only iterate over global menu commands.
-
type
(CommandType | None
, default:None
) –Menu command type to filter by.
Returns:
-
Iterator[MenuCommand]
–Iterator of the menu commands registered to this client.
iter_message_commands abstractmethod
#
iter_message_commands()
Iterate over all the message commands registered to this client.
Returns:
-
Iterator[MessageCommand]
–Iterator of all the message commands registered to this client.
iter_slash_commands abstractmethod
#
iter_slash_commands(*, global_only=False)
Iterate over all the slash commands registered to this client.
Parameters:
-
global_only
(bool
, default:False
) –Whether to only iterate over global slash commands.
Returns:
-
Iterator[BaseSlashCommand]
–Iterator of the slash commands registered to this client.
load_directory abstractmethod
#
load_directory(directory, /, *, namespace=None)
Load entities into this client from the modules in a directory.
The same loading rules for Client.load_modules mostly apply here but modules with no loaders are quietly ignored.
Parameters:
-
directory
(str | Path
) –Name of the directory to load modules from.
-
namespace
(str | None
, default:None
) –The python namespace this directory's modules should be imported from, if applicable.
This work as
{namespace}.{file.name.removesuffix(".py")}
and will have the same behaviour as when a str is passed to Client.load_modules if passed.If left as None then this will have the same behaviour as when a pathlib.Path is passed to Client.load_modules.
Returns:
-
Self
–This client instance to enable chained calls.
Raises:
-
FailedModuleLoad
–If any of the modules in this directory failed to load.
This includes if it failed to import or if one of its loaders raised. The source error can be found at FailedModuleLoad.__cause__.
Modules with no loaders are ignored.
-
ModuleNotFoundError
–If any of the modules aren't found.
load_directory_async abstractmethod
async
#
load_directory_async(directory, /, *, namespace=None)
Asynchronous variant of Client.load_directory.
Unlike Client.load_directory, this method will run blocking code in a background thread.
For more information on the behaviour of this method see the documentation for Client.load_directory.
load_modules abstractmethod
#
load_modules(*modules)
Load entities into this client from modules based on present loaders.
Note
If an __all__
is present in the target module then it will be used to find loaders.
Examples:
For this to work the target module has to have at least one loader present.
@tanjun.as_loader
def load_module(client: tanjun.Client) -> None:
client.add_component(component.copy())
or
loader = tanjun.Component(name="trans component").load_from_scope().make_loader()
Parameters:
-
*modules
(str | Path
, default:()
) –Path(s) of the modules to load from.
When str this will be treated as a normal import path which is absolute (
"foo.bar.baz"
). It's worth noting that absolute module paths may be imported from the current location if the top level module is a valid module file or module directory in the current working directory.When pathlib.Path the module will be imported directly from the given path. In this mode any relative imports in the target module will fail to resolve.
Returns:
-
Self
–This client instance to enable chained calls.
Raises:
-
FailedModuleLoad
–If the new version of a module failed to load.
This includes if it failed to import or if one of its loaders raised. The source error can be found at FailedModuleLoad.__cause__.
-
ModuleStateConflict
–If the module is already loaded.
-
ModuleMissingLoaders
–If no loaders are found in the module.
-
ModuleNotFoundError
–If the module is not found.
load_modules_async abstractmethod
async
#
load_modules_async(*modules)
Asynchronous variant of Client.load_modules.
Unlike Client.load_modules, this method will run blocking code in a background thread.
For more information on the behaviour of this method see the documentation for Client.load_modules.
reload_modules abstractmethod
#
reload_modules(*modules)
Reload entities in this client based on the loaders in loaded module(s).
Note
If an __all__
is present in the target module then it will be used to find loaders and unloaders.
Examples:
For this to work the module has to have at least one ClientLoader which handles loading and one which handles unloading present.
Parameters:
-
*modules
(str | Path
, default:()
) –Paths of one or more module to unload.
These should be the same paths which were passed to Client.load_modules.
Returns:
-
Self
–This client instance to enable chained calls.
Raises:
-
FailedModuleLoad
–If the new version of a module failed to load.
This includes if it failed to import or if one of its loaders raised. The source error can be found at FailedModuleLoad.__cause__.
-
FailedModuleUnload
–If the old version of a module failed to unload.
This indicates that one of its unloaders raised. The source error can be found at FailedModuleUnload.__cause__.
-
ModuleStateConflict
–If the module hasn't been loaded.
-
ModuleMissingLoaders
–If no loaders are found in the new state of the module.
-
ModuleMissingUnloaders
–If no unloaders are found in the current state of the module.
-
ModuleNotFoundError
–If the module can no-longer be found at the provided path.
reload_modules_async abstractmethod
async
#
reload_modules_async(*modules)
Asynchronous variant of Client.reload_modules.
Unlike Client.reload_modules, this method will run blocking code in a background thread.
For more information on the behaviour of this method see the documentation for Client.reload_modules.
remove_callback_override abstractmethod
#
remove_callback_override(callback)
Remove a callback override.
Parameters:
-
callback
(CallbackSig[_T]
) –The injected callback to remove the override for.
Returns:
-
Self
–The client instance to allow chaining.
Raises:
-
KeyError
–If no override is found for the callback.
remove_client_callback abstractmethod
#
remove_client_callback(name, callback)
Remove a client callback.
Parameters:
-
name
(str | ClientCallbackNames
) –The name this callback is being registered to.
This is case-insensitive.
-
callback
(MetaEventSig
) –The callback to remove from the client's callbacks.
Raises:
-
KeyError
–If the provided name isn't found.
-
ValueError
–If the provided callback isn't found.
Returns:
-
Self
–The client instance to enable chained calls.
remove_component abstractmethod
#
remove_component(component)
Remove a component from this client.
This will unsubscribe any client callbacks, commands and listeners registered in the provided component.
Parameters:
-
component
(Component
) –The component to remove from this client.
Raises:
-
ValueError
–If the provided component isn't found.
Returns:
-
Self
–The client instance to allow chained calls.
remove_component_by_name abstractmethod
#
remove_component_by_name(name)
remove_listener abstractmethod
#
remove_listener(event_type, callback)
Remove a listener from the client.
Parameters:
-
event_type
(type[Event]
) –The event type to remove a listener for.
-
callback
(ListenerCallbackSig[_EventT]
) –The callback to remove.
Raises:
-
KeyError
–If the provided event type isn't found.
-
ValueError
–If the provided callback isn't found.
Returns:
-
Self
–The client instance to enable chained calls.
remove_type_dependency abstractmethod
#
remove_type_dependency(type_)
set_callback_override abstractmethod
#
set_callback_override(callback, override)
Override a specific injected callback.
Parameters:
-
callback
(CallbackSig[_T]
) –The injected callback to override.
-
override
(CallbackSig[_T]
) –The callback to use instead.
Returns:
-
Self
–The client instance to allow chaining.
set_metadata abstractmethod
#
set_metadata(key, value)
set_type_dependency abstractmethod
#
set_type_dependency(type_, value)
unload_modules abstractmethod
#
unload_modules(*modules)
Unload entities from this client based on unloaders in one or more modules.
Note
If an __all__
is present in the target module then it will be used to find unloaders.
Examples:
For this to work the module has to have at least one unloading enabled ClientLoader present.
@tanjun.as_unloader
def unload_component(client: tanjun.Client) -> None:
client.remove_component_by_name(component.name)
or
# make_loader's returned ClientLoader handles both loading and unloading.
loader = tanjun.Component(name="trans component").load_from_scope().make_loader()
Parameters:
-
*modules
(str | Path
, default:()
) –Path of one or more modules to unload.
These should be the same path(s) which were passed to Client.load_modules.
Returns:
-
Self
–This client instance to enable chained calls.
Raises:
-
ModuleStateConflict
–If the module hasn't been loaded.
-
ModuleMissingUnloaders
–If no unloaders are found in the module.
-
FailedModuleUnload
–If the old version of a module failed to unload.
This indicates that one of its unloaders raised. The source error can be found at FailedModuleUnload.__cause__.
with_client_callback abstractmethod
#
with_client_callback(name)
Add a client callback through a decorator call.
Examples:
client = tanjun.Client.from_rest_bot(bot)
@client.with_client_callback("closed")
async def on_close() -> None:
raise NotImplementedError
Parameters:
-
name
(str | ClientCallbackNames
) –The name this callback is being registered to.
This is case-insensitive.
Returns:
-
Callable[[MetaEventSig], MetaEventSig]
–Decorator callback used to register the client callback.
This may be sync or async and must return None. The positional and keyword arguments a callback should expect depend on implementation detail around the
name
being subscribed to.
with_listener abstractmethod
#
with_listener(*event_types)
Add an event listener to this client through a decorator call.
Examples:
client = tanjun.Client.from_gateway_bot(bot)
@client.with_listener(hikari.MessageCreateEvent)
async def on_message_create(event: hikari.MessageCreateEvent) -> None:
raise NotImplementedError
Parameters:
-
*event_types
(type[Event]
, default:()
) –One or more event types to listen for.
If none are provided then the event type(s) will be inferred from the callback's type-hints.
Returns:
-
Callable[[ListenerCallbackSig], ListenerCallbackSig]
–Decorator callback used to register the event callback.
The callback must be a coroutine function which returns None and always takes at least one positional arg of type hikari.Event regardless of client implementation detail.
Raises:
-
ValueError
–If nothing was passed for
event_types
and no subclasses of hikari.Event are found in the type-hint for the callback's first argument.
ClientCallbackNames #
Enum of the standard client callback names.
These should be dispatched by all Client implementations.
CLOSED class-attribute
instance-attribute
#
CLOSED = 'closed'
Called when the client has finished closing.
No positional arguments are provided for this event.
CLOSING class-attribute
instance-attribute
#
CLOSING = 'closing'
Called when the client is initially instructed to close.
No positional arguments are provided for this event.
COMPONENT_ADDED class-attribute
instance-attribute
#
COMPONENT_ADDED = 'component_added'
Called when a component is added to an active client.
Warning
This event isn't dispatched for components which were registered while the client is inactive.
The first positional argument is the Component being added.
COMPONENT_REMOVED class-attribute
instance-attribute
#
COMPONENT_REMOVED = 'component_removed'
Called when a component is added to an active client.
Warning
This event isn't dispatched for components which were removed while the client is inactive.
The first positional argument is the Component being removed.
MENU_COMMAND_NOT_FOUND class-attribute
instance-attribute
#
MENU_COMMAND_NOT_FOUND = 'menu_command_not_found'
Called when a menu command is not found.
MenuContext is provided as the first positional argument.
MESSAGE_COMMAND_NOT_FOUND class-attribute
instance-attribute
#
MESSAGE_COMMAND_NOT_FOUND = 'message_command_not_found'
Called when a message command is not found.
MessageContext is provided as the first positional argument.
SLASH_COMMAND_NOT_FOUND class-attribute
instance-attribute
#
SLASH_COMMAND_NOT_FOUND = 'slash_command_not_found'
Called when a slash command is not found.
SlashContext is provided as the first positional argument.
STARTED class-attribute
instance-attribute
#
STARTED = 'started'
Called when the client has finished starting.
No positional arguments are provided for this event.
STARTING class-attribute
instance-attribute
#
STARTING = 'starting'
Called when the client is initially instructed to start.
No positional arguments are provided for this event.
ClientLoader #
Component #
Bases: ABC
Standard interface of a Tanjun component.
This is a collection of message and application commands, and listeners with logic for command search + execution and loading the listeners into a tanjun client.
default_app_cmd_permissions abstractmethod
property
#
default_app_cmd_permissions
Default required guild member permissions for the commands in this component.
This may be overridden by AppCommand.default_member_permissions and if this is None then the default from the parent client is used.
Warning
This may be overridden by guild staff and does not apply to admins.
defaults_to_ephemeral abstractmethod
property
#
defaults_to_ephemeral
Whether slash contexts executed in this component should default to ephemeral responses.
This effects calls to AppCommandContext.create_followup, AppCommandContext.create_initial_response, AppCommandContext.defer and AppCommandContext.respond unless the flags
field is provided for the methods which support it.
Note
This may be overridden by AppCommand.defaults_to_ephemeral and only effects slash command execution; if this is None then the default from the parent client is used.
dms_enabled_for_app_cmds abstractmethod
property
#
dms_enabled_for_app_cmds
Whether application commands in this component should be enabled in DMs.
Note
This may be overridden by AppCommand.is_dm_enabled and if both that and this are None then the default from the parent client is used.
is_case_sensitive abstractmethod
property
#
is_case_sensitive
Whether this component should treat message command names case sensitive in search.
If this is None
then the client's case sensitivity will be used.
listeners abstractmethod
property
#
listeners
Mapping of event types to the listeners registered for them in this component.
menu_commands abstractmethod
property
#
menu_commands
Collection of the menu commands in this component.
message_commands abstractmethod
property
#
message_commands
Collection of the message commands in this component.
metadata abstractmethod
property
#
metadata
Mutable mapping of the metadata set for this component.
Note
Any modifications made to this mutable mapping will be preserved by the component.
name abstractmethod
property
#
name
Component's unique identifier.
Note
This will be preserved between copies of a component.
slash_commands abstractmethod
property
#
slash_commands
Collection of the slash commands in this component.
add_listener abstractmethod
#
add_listener(event, /, *callbacks)
Add a listener to this component.
Parameters:
-
event
(type[Event]
) –The event to listen for.
-
*callbacks
(ListenerCallbackSig[_EventT]
, default:()
) –The callbacks to add.
Returns:
-
Self
–The component to enable chained calls.
add_menu_command abstractmethod
#
add_menu_command(command)
Add a menu command to this component.
Parameters:
-
command
(MenuCommand[Any, Any]
) –The command to add.
Returns:
-
Self
–The component to enable chained calls.
add_message_command abstractmethod
#
add_message_command(command)
Add a message command to this component.
Parameters:
-
command
(MessageCommand[Any]
) –The command to add.
Returns:
-
Self
–The component to enable chained calls.
add_slash_command abstractmethod
#
add_slash_command(command)
Add a slash command to this component.
Parameters:
-
command
(BaseSlashCommand
) –The command to add.
Returns:
-
Self
–The component to enable chained calls.
check_message_name abstractmethod
#
check_message_name(name, /, *, case_sensitive=True)
Check whether a name matches any of this component's registered message commands.
Note
This only checks for name matches against the top level command and will not account for sub-commands.
Note
Dependent on implementation detail this may partial check name against command names using name.startswith(command_name), hence why it also returns the name a command was matched by.
Parameters:
-
name
(str
) –The name to check for command matches.
-
case_sensitive
(bool
, default:True
) –Whether to perform a case-sensitive match.
Returns:
-
Iterator[tuple[str, MessageCommand[Any]]]
–Iterator of tuples of command name matches to the relevant message command objects.
check_slash_name abstractmethod
#
check_slash_name(name)
Check whether a name matches any of this component's registered slash commands.
Note
This won't check for sub-commands and will expect name
to simply be the top level command name.
Parameters:
-
name
(str
) –The name to check for command matches.
Returns:
-
Iterator[BaseSlashCommand]
–An iterator of the matching slash commands.
close abstractmethod
async
#
close(*, unbind=False)
Close the component.
Parameters:
-
unbind
(bool
, default:False
) –Whether to unbind from the client after this is closed.
Raises:
-
RuntimeError
–If the component isn't running.
execute_autocomplete abstractmethod
#
execute_autocomplete(ctx)
Execute an autocomplete context.
Note
Unlike the other execute methods, this shouldn't be expected to raise tanjun.HaltExecution nor tanjun.CommandError.
Parameters:
-
ctx
(AutocompleteContext
) –The context to execute.
Returns:
execute_menu abstractmethod
async
#
execute_menu(ctx, /, *, hooks=None)
Execute a menu context.
Parameters:
-
ctx
(MenuContext
) –The context to execute.
-
hooks
(MutableSet[MenuHooks] | None
, default:None
) –Set of hooks to include in this command execution.
Returns:
-
Coroutine[Any, Any, None] | None
–Coroutine used to wait for the command execution to finish.
This may be awaited or left to run as a background task.
If this is None then the client should carry on its search for a component with a matching command.
Raises:
-
CommandError
–To end the command's execution with an error response message.
-
HaltExecution
–To indicate that the client should stop searching for commands to execute with the current context.
execute_message abstractmethod
async
#
execute_message(ctx, /, *, hooks=None)
Execute a message context.
Parameters:
-
ctx
(MessageContext
) –The context to execute.
-
hooks
(MutableSet[MessageHooks] | None
, default:None
) –Set of hooks to include in this command execution.
Returns:
-
bool
–Whether a message command was executed in this component with the provided context.
If False then the client should carry on its search for a component with a matching command.
Raises:
-
CommandError
–To end the command's execution with an error response message.
-
HaltExecution
–To indicate that the client should stop searching for commands to execute with the current context.
execute_slash abstractmethod
async
#
execute_slash(ctx, /, *, hooks=None)
Execute a slash context.
Parameters:
-
ctx
(SlashContext
) –The context to execute.
-
hooks
(MutableSet[SlashHooks] | None
, default:None
) –Set of hooks to include in this command execution.
Returns:
-
Coroutine[Any, Any, None] | None
–Coroutine used to wait for the command execution to finish.
This may be awaited or left to run as a background task.
If this is None then the client should carry on its search for a component with a matching command.
Raises:
-
CommandError
–To end the command's execution with an error response message.
-
HaltExecution
–To indicate that the client should stop searching for commands to execute with the current context.
open abstractmethod
async
#
open()
Start the component.
Raises:
-
RuntimeError
–If the component is already open. If the component isn't bound to a client.
remove_listener abstractmethod
#
remove_listener(event, listener)
Remove a listener from this component.
Parameters:
-
event
(type[Event]
) –The event to listen for.
-
listener
(ListenerCallbackSig[_EventT]
) –The listener to remove.
Raises:
-
ValueError
–If the listener is not registered for the provided event.
Returns:
-
Self
–The component to enable chained calls.
remove_menu_command abstractmethod
#
remove_menu_command(command)
Remove a menu command from this component.
Parameters:
-
command
(MenuCommand[Any, Any]
) –Object of the menu command to remove.
Returns:
-
Self
–The component to enable chained calls.
remove_message_command abstractmethod
#
remove_message_command(command)
Remove a message command from this component.
Parameters:
-
command
(MessageCommand[Any]
) –The command to remove.
Raises:
-
ValueError
–If the provided command isn't found.
Returns:
-
Self
–The component to enable chained calls.
remove_slash_command abstractmethod
#
remove_slash_command(command)
Remove a slash command from this component.
Parameters:
-
command
(BaseSlashCommand
) –The command to remove.
Raises:
-
ValueError
–If the provided command isn't found.
Returns:
-
Self
–The component to enable chained calls.
set_metadata abstractmethod
#
set_metadata(key, value)
with_listener abstractmethod
#
with_listener(*event_types)
Add a listener to this component through a decorator call.
Parameters:
-
*event_types
(type[Event]
, default:()
) –One or more event types to listen for.
If none are provided then the event type(s) will be inferred from the callback's type-hints.
Returns:
-
Callable[[ListenerCallbackSig], ListenerCallbackSig]
–Decorator callback which takes listener to add.
Raises:
-
ValueError
–If nothing was passed for
event_types
and no subclasses of hikari.Event are found in the type-hint for the callback's first argument.
with_menu_command abstractmethod
#
with_menu_command(command: _MenuCommandT) -> _MenuCommandT
with_menu_command(*, copy: bool = False) -> collections.Callable[[_MenuCommandT], _MenuCommandT]
with_menu_command(command=None, /, *, copy=False)
Add a menu command to this component through a decorator call.
Parameters:
-
command
(MenuCommand
, default:None
) –The command to add.
-
copy
(bool
, default:False
) –Whether to copy the command before adding it.
Returns:
-
MenuCommand
–The added command.
with_message_command abstractmethod
#
with_message_command(command: _MessageCommandT) -> _MessageCommandT
with_message_command(*, copy: bool = False) -> collections.Callable[[_MessageCommandT], _MessageCommandT]
with_message_command(command=None, /, *, copy=False)
Add a message command to this component through a decorator call.
Parameters:
-
command
(MessageCommand
, default:None
) –The command to add.
-
copy
(bool
, default:False
) –Whether to copy the command before adding it.
Returns:
-
MessageCommand
–The added command.
with_slash_command abstractmethod
#
with_slash_command(command: _BaseSlashCommandT) -> _BaseSlashCommandT
with_slash_command(*, copy: bool = False) -> collections.Callable[[_BaseSlashCommandT], _BaseSlashCommandT]
with_slash_command(command=None, /, *, copy=False)
Add a slash command to this component through a decorator call.
Parameters:
-
command
(BaseSlashCommand
, default:None
) –The command to add.
-
copy
(bool
, default:False
) –Whether to copy the command before adding it.
Returns:
-
BaseSlashCommand
–The added command.
Context #
Bases: Context
Interface for the context of a command execution.
cache abstractmethod
property
#
cache
Hikari cache instance this context's command client was initialised with.
command abstractmethod
property
#
command
Object of the command this context is bound to.
Note
This will only be None before this has been bound to a specific command but never during command execution.
component abstractmethod
property
#
component
events abstractmethod
property
#
events
Object of the event manager this context's client was initialised with.
guild_id abstractmethod
property
#
guild_id
ID of the guild this command was executed in.
Will be None for all DM command executions.
has_responded abstractmethod
property
#
has_responded
Whether an initial response has been made for this context.
is_human abstractmethod
property
#
is_human
Whether this command execution was triggered by a human.
Will be False for bot and webhook triggered commands.
member abstractmethod
property
#
member
Guild member object of this command's author.
Will be None for DM command executions.
rest abstractmethod
property
#
rest
Object of the Hikari REST client this context's client was initialised with.
server abstractmethod
property
#
server
Object of the Hikari interaction server provided for this context's client.
shard abstractmethod
property
#
shard
Shard that triggered the context.
Note
This will be None if Context.shards is also None.
shards abstractmethod
property
#
shards
Object of the Hikari shard manager this context's client was initialised with.
triggering_name abstractmethod
property
#
triggering_name
Command name this execution was triggered with.
voice abstractmethod
property
#
voice
Object of the Hikari voice component this context's client was initialised with.
delete_initial_response abstractmethod
async
#
delete_initial_response()
Delete the initial response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no initial response.
delete_last_response abstractmethod
async
#
delete_last_response()
Delete the last response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no responses.
edit_initial_response abstractmethod
async
#
edit_initial_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the initial response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to edit the initial response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the initial response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the initial response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the initial response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the initial response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
edit_last_response abstractmethod
async
#
edit_last_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the last response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the content to edit the last response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the last response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the last response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the last response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the last response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_channel abstractmethod
async
#
fetch_channel()
Fetch the channel the context was invoked in.
Note
This performs an API call. Consider using Context.get_channelif you have the CacheComponents.GUILD_CHANNELS cache component enabled.
Returns:
-
TextableChannel
–The textable DM or guild channel the context was invoked in.
Raises:
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
READ_MESSAGES
permission in the channel. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_guild abstractmethod
async
#
fetch_guild()
Fetch the guild the context was invoked in.
Note
This performs an API call. Consider using Context.get_guild if you have the CacheComponents.GUILDS cache component enabled.
Returns:
-
Guild | None
–An optional guild the context was invoked in. None will be returned if the context was invoked in a DM channel.
Raises:
-
ForbiddenError
–If you are not part of the guild.
-
NotFoundError
–If the guild is not found.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_initial_response abstractmethod
async
#
fetch_initial_response()
Fetch the initial response for this context.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
fetch_last_response abstractmethod
async
#
fetch_last_response()
Fetch the last response for this context.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
get_channel abstractmethod
#
get_channel()
Retrieve the channel the context was invoked in from the cache.
Note
This method requires the CacheComponents.GUILD_CHANNELS cache component.
Returns:
-
TextableGuildChannel | None
–An optional guild channel the context was invoked in. None will be returned if the channel was not found or if it is DM channel.
get_guild abstractmethod
#
get_guild()
Fetch the guild that the context was invoked in.
Note
This method requires the CacheComponents.GUILDS cache component.
Returns:
respond abstractmethod
async
#
respond(content: hikari.UndefinedOr[typing.Any] = hikari.UNDEFINED, *, ensure_result: typing.Literal[True], delete_after: datetime.timedelta | float | int | None = None, attachment: hikari.UndefinedOr[hikari.Resourceish] = hikari.UNDEFINED, attachments: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] = hikari.UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = hikari.UNDEFINED, components: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] = hikari.UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = hikari.UNDEFINED, embeds: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] = hikari.UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = hikari.UNDEFINED, user_mentions: hikari.SnowflakeishSequence[hikari.PartialUser] | bool | hikari.UndefinedType = hikari.UNDEFINED, role_mentions: hikari.SnowflakeishSequence[hikari.PartialRole] | bool | hikari.UndefinedType = hikari.UNDEFINED) -> hikari.Message
respond(content: hikari.UndefinedOr[typing.Any] = hikari.UNDEFINED, *, ensure_result: bool = False, delete_after: datetime.timedelta | float | int | None = None, attachment: hikari.UndefinedOr[hikari.Resourceish] = hikari.UNDEFINED, attachments: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] = hikari.UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = hikari.UNDEFINED, components: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] = hikari.UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = hikari.UNDEFINED, embeds: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] = hikari.UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = hikari.UNDEFINED, user_mentions: hikari.SnowflakeishSequence[hikari.PartialUser] | bool | hikari.UndefinedType = hikari.UNDEFINED, role_mentions: hikari.SnowflakeishSequence[hikari.PartialRole] | bool | hikari.UndefinedType = hikari.UNDEFINED) -> hikari.Message | None
respond(content=hikari.UNDEFINED, *, ensure_result=False, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Respond to this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
ensure_result
(bool
, default:False
) –Ensure that this call will always return a message object.
If True then this will always return hikari.Message, otherwise this will return
hikari.Message | None
.It's worth noting that, under certain scenarios within the slash command flow, this may lead to an extre request being made.
-
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedOr[Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
-
attachments
(UndefinedOr[Sequence[Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this response.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this response.
-
embed
(UndefinedOr[Embed]
, default:UNDEFINED
) –An embed to respond with.
-
embeds
(UndefinedOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to respond with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message | None
–
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
ExecutableCommand #
Bases: ABC
, Generic[_ContextT_co]
Base class for all commands that can be executed.
checks abstractmethod
property
#
checks
Collection of checks that must be met before the command can be executed.
metadata abstractmethod
property
#
metadata
Mutable mapping of metadata set for this command.
Note
Any modifications made to this mutable mapping will be preserved by the command.
add_check abstractmethod
#
add_check(*checks)
remove_check abstractmethod
#
remove_check(check)
Remove a check from the command.
Parameters:
-
check
(CheckSig[_ContextT_co]
) –The check to remove.
Raises:
-
ValueError
–If the provided check isn't found.
Returns:
-
Self
–This command to enable chained calls
set_hooks abstractmethod
#
set_hooks(hooks)
Hooks #
Bases: ABC
, Generic[_ContextT_contra]
Interface of a collection of callbacks called during set stage of command execution.
add_on_error abstractmethod
#
add_on_error(callback)
Add an error callback to this hook object.
Note
This won't be called for expected tanjun.TanjunError derived errors.
Parameters:
-
callback
(ErrorHookSig[_ContextT_contra]
) –The callback to add to this hook.
This callback should take two positional arguments (of type Context and Exception) and may be either synchronous or asynchronous.
Returning True indicates that the error should be suppressed, False that it should be re-raised and None that no decision has been made. This will be accounted for along with the decisions other error hooks make by majority rule.
Returns:
-
Self
–The hook object to enable method chaining.
add_on_parser_error abstractmethod
#
add_on_parser_error(callback)
Add a parser error callback to this hook object.
Parameters:
-
callback
(ParserHookSig[_ContextT_contra]
) –The callback to add to this hook.
This callback should take two positional arguments (of type Context and tanjun.ParserError), return None and may be either synchronous or asynchronous.
It's worth noting that this unlike general error handlers, this will always suppress the error.
Returns:
-
Self
–The hook object to enable method chaining.
add_on_success abstractmethod
#
add_on_success(callback)
add_post_execution abstractmethod
#
add_post_execution(callback)
add_pre_execution abstractmethod
#
add_pre_execution(callback)
with_on_error abstractmethod
#
with_on_error(callback: _AnyErrorHookSigT) -> _AnyErrorHookSigT
with_on_error(callback: _MenuErrorHookSigT) -> _MenuErrorHookSigT
with_on_error(callback: _MessageErrorHookSigT) -> _MessageErrorHookSigT
with_on_error(callback: _SlashErrorHookSigT) -> _SlashErrorHookSigT
with_on_error(callback)
Add an error callback to this hook object through a decorator call.
Note
This won't be called for expected tanjun.TanjunError derived errors.
Examples:
hooks = AnyHooks()
@hooks.with_on_error
async def on_error(ctx: tanjun.abc.Context, error: Exception) -> bool:
if isinstance(error, SomeExpectedType):
await ctx.respond("You dun goofed")
return True # Indicating that it should be suppressed.
await ctx.respond(f"An error occurred: {error}")
return False # Indicating that it should be re-raised
Parameters:
-
callback
(ErrorHookSig
) –The callback to add to this hook.
This callback should take two positional arguments (of type Context and Exception) and may be either synchronous or asynchronous.
Returning True indicates that the error should be suppressed, False that it should be re-raised and None that no decision has been made. This will be accounted for along with the decisions other error hooks make by majority rule.
Returns:
-
ErrorHookSig
–The hook callback which was added.
with_on_parser_error abstractmethod
#
with_on_parser_error(callback: _AnyParserHookSigT) -> _AnyParserHookSigT
with_on_parser_error(callback: _MenuParserHookSigT) -> _MenuParserHookSigT
with_on_parser_error(callback: _MessageParserHookSigT) -> _MessageParserHookSigT
with_on_parser_error(callback: _SlashParserHookSigT) -> _SlashParserHookSigT
with_on_parser_error(callback)
Add a parser error callback to this hook object through a decorator call.
Examples:
hooks = AnyHooks()
@hooks.with_on_parser_error
async def on_parser_error(ctx: tanjun.abc.Context, error: tanjun.ParserError) -> None:
await ctx.respond(f"You gave invalid input: {error}")
Parameters:
-
callback
(ParserHookSig
) –The parser error callback to add to this hook.
This callback should take two positional arguments (of type Context and tanjun.ParserError), return None and may be either synchronous or asynchronous.
Returns:
-
HookSig
–The callback which was added.
with_on_success abstractmethod
#
with_on_success(callback: _AnyHookSigT) -> _AnyHookSigT
with_on_success(callback: _MenuHookSigT) -> _MenuHookSigT
with_on_success(callback: _MessageHookSigT) -> _MessageHookSigT
with_on_success(callback: _SlashHookSigT) -> _SlashHookSigT
with_on_success(callback)
Add a success callback to this hook object through a decorator call.
Examples:
hooks = AnyHooks()
@hooks.with_on_success
async def on_success(ctx: tanjun.abc.Context) -> None:
await ctx.respond("You did something")
Parameters:
-
callback
(HookSig
) –
Returns:
-
HookSig
–The success callback which was added.
with_post_execution abstractmethod
#
with_post_execution(callback: _AnyHookSigT) -> _AnyHookSigT
with_post_execution(callback: _MenuHookSigT) -> _MenuHookSigT
with_post_execution(callback: _MessageHookSigT) -> _MessageHookSigT
with_post_execution(callback: _SlashHookSigT) -> _SlashHookSigT
with_post_execution(callback)
Add a post-execution callback to this hook object through a decorator call.
Examples:
hooks = AnyHooks()
@hooks.with_post_execution
async def post_execution(ctx: tanjun.abc.Context) -> None:
await ctx.respond("You did something")
Parameters:
-
callback
(HookSig
) –
Returns:
-
HookSig
–The post-execution callback which was seaddedt.
with_pre_execution abstractmethod
#
with_pre_execution(callback: _AnyHookSigT) -> _AnyHookSigT
with_pre_execution(callback: _MenuHookSigT) -> _MenuHookSigT
with_pre_execution(callback: _MessageHookSigT) -> _MessageHookSigT
with_pre_execution(callback: _SlashHookSigT) -> _SlashHookSigT
with_pre_execution(callback)
Add a pre-execution callback to this hook object through a decorator call.
Examples:
hooks = AnyHooks()
@hooks.with_pre_execution
async def pre_execution(ctx: tanjun.abc.Context) -> None:
await ctx.respond("You did something")
Parameters:
-
callback
(HookSig
) –
Returns:
-
HookSig
–The pre-execution callback which was added.
MenuCommand #
Bases: AppCommand[MenuContext]
, Generic[_MenuCallbackSigT, _MenuTypeT]
A contextmenu command.
checks abstractmethod
property
#
checks
Collection of checks that must be met before the command can be executed.
default_member_permissions abstractmethod
property
#
default_member_permissions
The default guild member permissions required to use this command.
Warning
This can be overridden by guild staff and does not apply to admins.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
defaults_to_ephemeral abstractmethod
property
#
defaults_to_ephemeral
Whether contexts executed by this command should default to ephemeral responses.
This effects calls to AppCommandContext.create_followup, AppCommandContext.create_initial_response, AppCommandContext.defer and AppCommandContext.respond unless the flags
field is provided for the methods which support it.
Note
If this is None then the default from the parent command(s), component or client is used.
is_dm_enabled abstractmethod
property
#
is_dm_enabled
Whether this command is enabled in DM contexts.
Note
If this is None then the default from the parent component or client is used.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
is_global abstractmethod
property
#
is_global
Whether the command should be declared globally or not.
Warning
For commands within command groups the state of this flag is inherited regardless of what it's set as on the child command.
metadata abstractmethod
property
#
metadata
Mutable mapping of metadata set for this command.
Note
Any modifications made to this mutable mapping will be preserved by the command.
tracked_command abstractmethod
property
#
tracked_command
Object of the actual command this object tracks if set.
tracked_command_id abstractmethod
property
#
tracked_command_id
ID of the actual command this object tracks if set.
add_check abstractmethod
#
add_check(*checks)
build abstractmethod
#
build(*, component=None)
Get a builder object for this command.
Parameters:
-
component
(Component | None
, default:None
) –The component to inherit config like
default_member_permissions
andis_dm_enabled
from if not explicitly set on the command.This defaults to the command's linked component.
Returns:
-
ContextMenuCommandBuilder
–A builder object for this command. Use to declare this command on globally or for a specific guild.
remove_check abstractmethod
#
remove_check(check)
Remove a check from the command.
Parameters:
-
check
(CheckSig[_ContextT_co]
) –The check to remove.
Raises:
-
ValueError
–If the provided check isn't found.
Returns:
-
Self
–This command to enable chained calls
set_hooks abstractmethod
#
set_hooks(hooks)
set_metadata abstractmethod
#
set_metadata(key, value)
set_tracked_command abstractmethod
#
set_tracked_command(command)
Set the global command this tracks.
Parameters:
-
command
(PartialCommand
) –Object of the global command this tracks.
Returns:
-
Self
–The command instance to enable chained calls.
MenuContext #
Bases: AppCommandContext
, ABC
Interface of a menu command context.
cache abstractmethod
property
#
cache
Hikari cache instance this context's command client was initialised with.
command abstractmethod
property
#
command
Command that was invoked.
Note
This should always be set during command check execution and command hook execution but isn't guaranteed for client callbacks nor component/client checks.
component abstractmethod
property
#
component
defaults_to_ephemeral abstractmethod
property
#
defaults_to_ephemeral
Whether the context is marked as defaulting to ephemeral response.
This effects calls to AppCommandContext.create_followup, AppCommandContext.create_initial_response, AppCommandContext.defer and AppCommandContext.respond unless the flags
field is provided for the methods which support it.
events abstractmethod
property
#
events
Object of the event manager this context's client was initialised with.
expires_at abstractmethod
property
#
expires_at
When this application command context expires.
After this time is reached, the message/response methods on this context will always raise hikari.NotFoundError.
guild_id abstractmethod
property
#
guild_id
ID of the guild this command was executed in.
Will be None for all DM command executions.
has_been_deferred abstractmethod
property
#
has_been_deferred
Whether the initial response for this context has been deferred.
Warning
If this is True when AppCommandContext.has_responded is False then AppCommandContext.edit_initial_response will need to be used to create the initial response rather than AppCommandContext.create_initial_response.
has_responded abstractmethod
property
#
has_responded
Whether an initial response has been made for this context.
is_human abstractmethod
property
#
is_human
Whether this command execution was triggered by a human.
Will be False for bot and webhook triggered commands.
member abstractmethod
property
#
member
Object of the member that triggered this command if this is in a guild.
rest abstractmethod
property
#
rest
Object of the Hikari REST client this context's client was initialised with.
server abstractmethod
property
#
server
Object of the Hikari interaction server provided for this context's client.
shard abstractmethod
property
#
shard
Shard that triggered the context.
Note
This will be None if Context.shards is also None.
shards abstractmethod
property
#
shards
Object of the Hikari shard manager this context's client was initialised with.
triggering_name abstractmethod
property
#
triggering_name
Command name this execution was triggered with.
voice abstractmethod
property
#
voice
Object of the Hikari voice component this context's client was initialised with.
create_followup abstractmethod
async
#
create_followup(content=hikari.UNDEFINED, *, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, tts=hikari.UNDEFINED, flags=hikari.UNDEFINED)
Create a followup response for this context.
Warning
Calling this on a context which hasn't had an initial response yet will lead to a hikari.NotFoundError being raised.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to send.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
ephemeral
(bool | None
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. -
attachment
(UndefinedOr[Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
-
attachments
(UndefinedOr[Sequence[Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
-
embed
(UndefinedOr[Embed]
, default:UNDEFINED
) –If provided, the message embed.
-
embeds
(UndefinedOr[Sequence[Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
-
tts
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be sent as a TTS message.
-
flags
(UndefinedType | int | MessageFlag
, default:UNDEFINED
) –The flags to set for this response.
As of writing this can only flag which can be provided is EPHEMERAL, other flags are just ignored.
Returns:
-
Message
–The created message object.
Raises:
-
NotFoundError
–If the current interaction is not found or it hasn't had an initial response yet.
-
BadRequestError
–This can be raised if the file is too large; if the embed exceeds the defined limits; if the message content is specified only and empty or greater than
2000
characters; if neither content, file or embeds are specified. If any invalid snowflake IDs are passed; a snowflake may be invalid due to it being outside of the range of a 64 bit integer. -
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
or `user_mentions.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed.
create_initial_response abstractmethod
async
#
create_initial_response(content=hikari.UNDEFINED, *, delete_after=None, ephemeral=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED, flags=hikari.UNDEFINED, tts=hikari.UNDEFINED)
Create the initial response for this context.
Warning
Calling this on a context which already has an initial response will result in this raising a hikari.NotFoundError. This includes if the REST interaction server has already responded to the request and deferrals.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
ephemeral
(bool | None
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. -
attachment
(UndefinedOr[Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
-
attachments
(UndefinedOr[Sequence[Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this message.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this message.
-
embed
(UndefinedOr[Embed]
, default:UNDEFINED
) –If provided, the message embed.
-
embeds
(UndefinedOr[Sequence[Embed]]
, default:UNDEFINED
) –If provided, the message embeds.
-
flags
(int | MessageFlag | UndefinedType
, default:UNDEFINED
) –If provided, the message flags this response should have.
As of writing the only message flag which can be set here is MessageFlag.EPHEMERAL.
-
tts
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message will be read out by a screen reader using Discord's TTS (text-to-speech) system.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If the interaction will have expired before
delete_after
is reached.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; invalid image URLs in embeds.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
NotFoundError
–If the interaction is not found or if the interaction's initial response has already been created.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
create_modal_response abstractmethod
async
#
create_modal_response(title, custom_id, /, *, component=hikari.UNDEFINED, components=hikari.UNDEFINED)
Send a modal as the initial response for this context.
Warning
This must be called as the first response to a context before any deferring.
Parameters:
-
title
(str
) –The title that will show up in the modal.
-
custom_id
(str
) –Developer set custom ID used for identifying interactions with this modal.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –A component builder to send in this modal.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –A sequence of component builders to send in this modal.
Raises:
-
ValueError
–If both
component
andcomponents
are specified or if none are specified. -
BadRequestError
–When the requests' data is outside Discord's accept ranges/validation.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
NotFoundError
–If the interaction is not found or if the interaction's initial response has already been created or deferred.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
defer abstractmethod
async
#
defer(*, ephemeral=None, flags=hikari.UNDEFINED)
Defer the initial response for this context.
Note
The ephemeral state of the first response is decided by whether the deferral is ephemeral.
Parameters:
-
ephemeral
(bool | None
, default:None
) –Whether the deferred response should be ephemeral.
Passing True here is a shorthand for including
1 << 64
in the passed flags. -
flags
(UndefinedType | int | MessageFlag
, default:UNDEFINED
) –The flags to use for the initial response.
delete_initial_response abstractmethod
async
#
delete_initial_response()
Delete the initial response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no initial response.
delete_last_response abstractmethod
async
#
delete_last_response()
Delete the last response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no responses.
edit_initial_response abstractmethod
async
#
edit_initial_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the initial response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to edit the initial response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the initial response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the initial response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the initial response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the initial response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
edit_last_response abstractmethod
async
#
edit_last_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the last response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the content to edit the last response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the last response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the last response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the last response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the last response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_channel abstractmethod
async
#
fetch_channel()
Fetch the channel the context was invoked in.
Note
This performs an API call. Consider using Context.get_channelif you have the CacheComponents.GUILD_CHANNELS cache component enabled.
Returns:
-
TextableChannel
–The textable DM or guild channel the context was invoked in.
Raises:
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
READ_MESSAGES
permission in the channel. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_guild abstractmethod
async
#
fetch_guild()
Fetch the guild the context was invoked in.
Note
This performs an API call. Consider using Context.get_guild if you have the CacheComponents.GUILDS cache component enabled.
Returns:
-
Guild | None
–An optional guild the context was invoked in. None will be returned if the context was invoked in a DM channel.
Raises:
-
ForbiddenError
–If you are not part of the guild.
-
NotFoundError
–If the guild is not found.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_initial_response abstractmethod
async
#
fetch_initial_response()
Fetch the initial response for this context.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
fetch_last_response abstractmethod
async
#
fetch_last_response()
Fetch the last response for this context.
Raises:
-
(LookupError, NotFoundError)
–The response was not found.
get_channel abstractmethod
#
get_channel()
Retrieve the channel the context was invoked in from the cache.
Note
This method requires the CacheComponents.GUILD_CHANNELS cache component.
Returns:
-
TextableGuildChannel | None
–An optional guild channel the context was invoked in. None will be returned if the channel was not found or if it is DM channel.
get_guild abstractmethod
#
get_guild()
Fetch the guild that the context was invoked in.
Note
This method requires the CacheComponents.GUILDS cache component.
Returns:
mark_not_found abstractmethod
async
#
mark_not_found()
Mark this context as not found.
Dependent on how the client is configured this may lead to a not found response message being sent.
resolve_to_member abstractmethod
#
resolve_to_member() -> hikari.InteractionMember
resolve_to_member(*, default: _T) -> hikari.InteractionMember | _T
resolve_to_member(*, default=...)
Resolve a user context menu context to a member object.
Returns:
-
InteractionMember
–The resolved member.
Raises:
-
TypeError
–If the context is not a user menu context.
-
LookupError
–If the member was not found for this user menu context.
This will happen if this was executed in a DM or the target user isn't in the current guild.
resolve_to_message abstractmethod
#
resolve_to_message()
resolve_to_user abstractmethod
#
resolve_to_user()
respond abstractmethod
async
#
respond(content: hikari.UndefinedOr[typing.Any] = hikari.UNDEFINED, *, ensure_result: typing.Literal[True], delete_after: datetime.timedelta | float | int | None = None, attachment: hikari.UndefinedOr[hikari.Resourceish] = hikari.UNDEFINED, attachments: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] = hikari.UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = hikari.UNDEFINED, components: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] = hikari.UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = hikari.UNDEFINED, embeds: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] = hikari.UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = hikari.UNDEFINED, user_mentions: hikari.SnowflakeishSequence[hikari.PartialUser] | bool | hikari.UndefinedType = hikari.UNDEFINED, role_mentions: hikari.SnowflakeishSequence[hikari.PartialRole] | bool | hikari.UndefinedType = hikari.UNDEFINED) -> hikari.Message
respond(content: hikari.UndefinedOr[typing.Any] = hikari.UNDEFINED, *, ensure_result: bool = False, delete_after: datetime.timedelta | float | int | None = None, attachment: hikari.UndefinedOr[hikari.Resourceish] = hikari.UNDEFINED, attachments: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] = hikari.UNDEFINED, component: hikari.UndefinedOr[hikari.api.ComponentBuilder] = hikari.UNDEFINED, components: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] = hikari.UNDEFINED, embed: hikari.UndefinedOr[hikari.Embed] = hikari.UNDEFINED, embeds: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] = hikari.UNDEFINED, mentions_everyone: hikari.UndefinedOr[bool] = hikari.UNDEFINED, user_mentions: hikari.SnowflakeishSequence[hikari.PartialUser] | bool | hikari.UndefinedType = hikari.UNDEFINED, role_mentions: hikari.SnowflakeishSequence[hikari.PartialRole] | bool | hikari.UndefinedType = hikari.UNDEFINED) -> hikari.Message | None
respond(content=hikari.UNDEFINED, *, ensure_result=False, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Respond to this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to respond with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead be treated as an embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
ensure_result
(bool
, default:False
) –Ensure that this call will always return a message object.
If True then this will always return hikari.Message, otherwise this will return
hikari.Message | None
.It's worth noting that, under certain scenarios within the slash command flow, this may lead to an extre request being made.
-
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedOr[Resourceish]
, default:UNDEFINED
) –If provided, the message attachment. This can be a resource, or string of a path on your computer or a URL.
-
attachments
(UndefinedOr[Sequence[Resourceish]]
, default:UNDEFINED
) –If provided, the message attachments. These can be resources, or strings consisting of paths on your computer or URLs.
-
component
(UndefinedOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this response.
-
components
(UndefinedOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this response.
-
embed
(UndefinedOr[Embed]
, default:UNDEFINED
) –An embed to respond with.
-
embeds
(UndefinedOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to respond with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message | None
–
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
set_command abstractmethod
#
set_command(command)
Set the command for this context.
Parameters:
-
command
(MenuCommand[Any, Any] | None
) –The command this context is for.
MessageCommand #
Bases: ExecutableCommand[MessageContext]
, ABC
, Generic[_MessageCallbackSigT]
Standard interface of a message command.
callback abstractmethod
property
#
callback
Callback which is called during execution.
Note
For command groups, this is called when none of the inner-commands matches the message.
checks abstractmethod
property
#
checks
Collection of checks that must be met before the command can be executed.
metadata abstractmethod
property
#
metadata
Mutable mapping of metadata set for this command.
Note
Any modifications made to this mutable mapping will be preserved by the command.
add_check abstractmethod
#
add_check(*checks)
copy abstractmethod
#
copy(*, parent=None)
Create a copy of this command.
Parameters:
-
parent
(MessageCommandGroup[Any] | None
, default:None
) –The parent of the copy.
Returns:
-
Self
–The copy.
remove_check abstractmethod
#
remove_check(check)
Remove a check from the command.
Parameters:
-
check
(CheckSig[_ContextT_co]
) –The check to remove.
Raises:
-
ValueError
–If the provided check isn't found.
Returns:
-
Self
–This command to enable chained calls
set_hooks abstractmethod
#
set_hooks(hooks)
set_metadata abstractmethod
#
set_metadata(key, value)
set_parent abstractmethod
#
set_parent(parent)
Set the parent of this command.
Parameters:
-
parent
(MessageCommandGroup[Any] | None
) –The parent of this command.
Returns:
-
Self
–The command instance to enable chained calls.
set_parser abstractmethod
#
set_parser(parser)
Set the for this message command.
Parameters:
-
parser
(MessageParser
) –The parser to set.
Returns:
-
Self
–The command instance to enable chained calls.
Raises:
-
ValueError
–If this parser's option keys aren't valid for this command when
validate_arg_keys
is True.
MessageCommandGroup #
Bases: MessageCommand[_MessageCallbackSigT]
, ABC
Standard interface of a message command group.
callback abstractmethod
property
#
callback
Callback which is called during execution.
Note
For command groups, this is called when none of the inner-commands matches the message.
checks abstractmethod
property
#
checks
Collection of checks that must be met before the command can be executed.
commands abstractmethod
property
#
commands
Collection of the commands in this group.
Note
This may include command groups.
metadata abstractmethod
property
#
metadata
Mutable mapping of metadata set for this command.
Note
Any modifications made to this mutable mapping will be preserved by the command.
add_check abstractmethod
#
add_check(*checks)
add_command abstractmethod
#
add_command(command)
Add a command to this group.
Parameters:
-
command
(MessageCommand[Any]
) –The command to add.
Returns:
-
Self
–The group instance to enable chained calls.
copy abstractmethod
#
copy(*, parent=None)
Create a copy of this command.
Parameters:
-
parent
(MessageCommandGroup[Any] | None
, default:None
) –The parent of the copy.
Returns:
-
Self
–The copy.
remove_check abstractmethod
#
remove_check(check)
Remove a check from the command.
Parameters:
-
check
(CheckSig[_ContextT_co]
) –The check to remove.
Raises:
-
ValueError
–If the provided check isn't found.
Returns:
-
Self
–This command to enable chained calls
remove_command abstractmethod
#
remove_command(command)
Remove a command from this group.
Parameters:
-
command
(MessageCommand[Any]
) –The command to remove.
Raises:
-
ValueError
–If the provided command isn't found.
Returns:
-
Self
–The group instance to enable chained calls.
set_hooks abstractmethod
#
set_hooks(hooks)
set_metadata abstractmethod
#
set_metadata(key, value)
set_parent abstractmethod
#
set_parent(parent)
Set the parent of this command.
Parameters:
-
parent
(MessageCommandGroup[Any] | None
) –The parent of this command.
Returns:
-
Self
–The command instance to enable chained calls.
set_parser abstractmethod
#
set_parser(parser)
Set the for this message command.
Parameters:
-
parser
(MessageParser
) –The parser to set.
Returns:
-
Self
–The command instance to enable chained calls.
Raises:
-
ValueError
–If this parser's option keys aren't valid for this command when
validate_arg_keys
is True.
with_command abstractmethod
#
with_command(command)
Add a command to this group through a decorator call.
Parameters:
-
command
(MessageCommand
) –The command to add.
Returns:
-
MessageCommand
–The added command.
MessageContext #
Interface of a message command specific context.
cache abstractmethod
property
#
cache
Hikari cache instance this context's command client was initialised with.
command abstractmethod
property
#
command
Command that was invoked.
Note
This is always set during command, command check and parser converter execution but isn't guaranteed during client callback nor client/component check execution.
component abstractmethod
property
#
component
content abstractmethod
property
#
content
Content of the context's message minus the triggering name and prefix.
events abstractmethod
property
#
events
Object of the event manager this context's client was initialised with.
guild_id abstractmethod
property
#
guild_id
ID of the guild this command was executed in.
Will be None for all DM command executions.
has_responded abstractmethod
property
#
has_responded
Whether an initial response has been made for this context.
is_human abstractmethod
property
#
is_human
Whether this command execution was triggered by a human.
Will be False for bot and webhook triggered commands.
member abstractmethod
property
#
member
Guild member object of this command's author.
Will be None for DM command executions.
rest abstractmethod
property
#
rest
Object of the Hikari REST client this context's client was initialised with.
server abstractmethod
property
#
server
Object of the Hikari interaction server provided for this context's client.
shard abstractmethod
property
#
shard
Shard that triggered the context.
Note
This will be None if Context.shards is also None.
shards abstractmethod
property
#
shards
Object of the Hikari shard manager this context's client was initialised with.
triggering_name abstractmethod
property
#
triggering_name
Command name this execution was triggered with.
voice abstractmethod
property
#
voice
Object of the Hikari voice component this context's client was initialised with.
delete_initial_response abstractmethod
async
#
delete_initial_response()
Delete the initial response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no initial response.
delete_last_response abstractmethod
async
#
delete_last_response()
Delete the last response after invoking this context.
Raises:
-
(LookupError, NotFoundError)
–The last context has no responses.
edit_initial_response abstractmethod
async
#
edit_initial_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the initial response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the message content to edit the initial response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the initial response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the initial response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the initial response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the initial response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
edit_last_response abstractmethod
async
#
edit_last_response(content=hikari.UNDEFINED, *, delete_after=None, attachment=hikari.UNDEFINED, attachments=hikari.UNDEFINED, component=hikari.UNDEFINED, components=hikari.UNDEFINED, embed=hikari.UNDEFINED, embeds=hikari.UNDEFINED, mentions_everyone=hikari.UNDEFINED, user_mentions=hikari.UNDEFINED, role_mentions=hikari.UNDEFINED)
Edit the last response for this context.
Parameters:
-
content
(UndefinedOr[Any]
, default:UNDEFINED
) –If provided, the content to edit the last response with.
If this is a hikari.Embed and no
embed
norembeds
kwarg is provided, then this will instead update the embed. This allows for simpler syntax when sending an embed alone.Likewise, if this is a hikari.Resource, then the content is instead treated as an attachment if no
attachment
and noattachments
kwargs are provided. -
delete_after
(timedelta | float | int | None
, default:None
) –If provided, the seconds after which the response message should be deleted.
Slash command responses can only be deleted within 15 minutes of the command being received.
-
attachment
(UndefinedNoneOr[Resourceish]
, default:UNDEFINED
) –A singular attachment to edit the last response with.
-
attachments
(UndefinedNoneOr[Sequence[Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to edit the last response with.
-
component
(UndefinedNoneOr[ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to set for this message. This component will replace any previously set components and passing None will remove all components.
-
components
(UndefinedNoneOr[Sequence[ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects set for this message. These components will replace any previously set components and passing None or an empty sequence will remove all components.
-
embed
(UndefinedNoneOr[Embed]
, default:UNDEFINED
) –An embed to replace the last response with.
-
embeds
(UndefinedNoneOr[Sequence[Embed]]
, default:UNDEFINED
) –A sequence of embeds to replace the last response with.
-
mentions_everyone
(UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
-
user_mentions
(SnowflakeishSequence[PartialUser] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialUser derivatives to enforce mentioning specific users.
-
role_mentions
(SnowflakeishSequence[PartialRole] | bool | UndefinedType
, default:UNDEFINED
) –If provided, and True, all mentions will be parsed. If provided, and False, no mentions will be parsed.
Alternatively this may be a collection of hikari.Snowflake, or hikari.PartialRole derivatives to enforce mentioning specific roles.
Returns:
-
Message
–The message that has been edited.
Raises:
-
ValueError
–If more than 100 unique objects/entities are passed for
role_mentions
oruser_mentions
.If
delete_after
would be more than 15 minutes after the slash command was called.If both
attachment
andattachments
are passed or bothcomponent
andcomponents
are passed or bothembed
andembeds
are passed. -
BadRequestError
–This may be raised in several discrete situations, such as messages being empty with no attachments or embeds; messages with more than 2000 characters in them, embeds that exceed one of the many embed limits; too many attachments; attachments that are too large; invalid image URLs in embeds; too many components.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
SEND_MESSAGES
in the channel or the person you are trying to message has the DM's disabled. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_channel abstractmethod
async
#
fetch_channel()
Fetch the channel the context was invoked in.
Note
This performs an API call. Consider using Context.get_channelif you have the CacheComponents.GUILD_CHANNELS cache component enabled.
Returns:
-
TextableChannel
–The textable DM or guild channel the context was invoked in.
Raises:
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
ForbiddenError
–If you are missing the
READ_MESSAGES
permission in the channel. -
NotFoundError
–If the channel is not found.
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -
InternalServerError
–If an internal error occurs on Discord while handling the request.
fetch_guild abstractmethod
async
#
fetch_guild()
Fetch the guild the context was invoked in.
Note
This performs an API call. Consider using Context.get_guild if you have the CacheComponents.GUILDS cache component enabled.
Returns:
-
Guild | None
–An optional guild the context was invoked in. None will be returned if the context was invoked in a DM channel.
Raises:
-
ForbiddenError
–If you are not part of the guild.
-
NotFoundError
–If the guild is not found.
-
UnauthorizedError
–If you are unauthorized to make the request (invalid/missing token).
-
RateLimitTooLongError
–Raised in the event that a rate limit occurs that is longer than
max_rate_limit
when making a request. -