tanjun.errors#
The errors and warnings raised within and by Tanjun.
MissingDependencyError module-attribute
#
MissingDependencyError = alluka.MissingDependencyError
Type alias of alluka.MissingDependencyError.
CommandError #
Bases: TanjunError
An error which is sent as a response to the command call.
attachments instance-attribute
#
attachments: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] = [attachment] if attachment else attachments
Sequence of the attachments to be sent as a response to the command, if set.
components instance-attribute
#
components: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] = [component] if component else components
Sequence of the components to be sent as a response to the command, if set.
content instance-attribute
#
content: hikari.UndefinedOr[str] = content
The response error message's content.
delete_after instance-attribute
#
delete_after: typing.Union[datetime.timedelta, float, int, None] = delete_after
The seconds after which the response message should be deleted, if set.
embeds instance-attribute
#
embeds: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] = [embed] if embed else embeds
Sequence of the embeds to be sent as a response to the command, if set.
mentions_everyone instance-attribute
#
mentions_everyone: hikari.UndefinedOr[bool] = mentions_everyone
Whether or not the response should be allowed to mention @everyone
/@here
.
role_mentions instance-attribute
#
role_mentions: typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, hikari.UndefinedType] = role_mentions
Configuration for the response's allowed role mentions.
If this is a sequence then the response will only be allowed to mention roles in the sequence.
If this is a bool then the response will only be allowed to mention roles if the value is True
.
user_mentions instance-attribute
#
user_mentions: typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, hikari.UndefinedType] = user_mentions
Configuration for the response's allowed user mentions.
If this is a sequence then the response will only be allowed to mention users in the sequence.
If this is a bool then the response will only be allowed to mention users if the value is True
.
__init__ #
__init__(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)
Initialise a command error.
Parameters:
- content (
hikari.UndefinedOr[typing.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 (
typing.Union[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 (
hikari.UndefinedOr[hikari.Resourceish]
, default:UNDEFINED
) –A singular attachment to respond with.
- attachments (
hikari.UndefinedOr[abc.Sequence[hikari.Resourceish]]
, default:UNDEFINED
) –A sequence of attachments to respond with.
- component (
hikari.UndefinedOr[hikari.api.ComponentBuilder]
, default:UNDEFINED
) –If provided, builder object of the component to include in this response.
- components (
hikari.UndefinedOr[abc.Sequence[hikari.api.ComponentBuilder]]
, default:UNDEFINED
) –If provided, a sequence of the component builder objects to include in this response.
- embed (
hikari.UndefinedOr[hikari.Embed]
, default:UNDEFINED
) –An embed to respond with.
- embeds (
hikari.UndefinedOr[abc.Sequence[hikari.Embed]]
, default:UNDEFINED
) –A sequence of embeds to respond with.
- mentions_everyone (
hikari.UndefinedOr[bool]
, default:UNDEFINED
) –If provided, whether the message should parse @everyone/@here mentions.
- user_mentions (
typing.Union[hikari.SnowflakeishSequence[hikari.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 (
typing.Union[hikari.SnowflakeishSequence[hikari.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
–Raised for any of the following reasons:
- When both
attachment
andattachments
are provided. - When both
component
andcomponents
are passed. - When both
embed
andembeds
are passed. - If more than 100 entries are passed for
role_mentions
. - If more than 100 entries are passed for
user_mentions
.
- When both
send async
#
send(ctx, /, *, ensure_result=False)
Send this error as a command response.
Parameters:
- ctx (
Context
) –The command call context to respond to.
- 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.
Raises:
-
ValueError
–If
delete_after
would be more than 15 minutes after the slash command was called. -
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.
ConversionError #
Bases: ParserError
Error raised by a parser parameter when it failed to converter a value.
errors instance-attribute
#
errors: collections.Sequence[ValueError] = tuple(errors)
Sequence of the errors that were caught during conversion for this parameter.
message instance-attribute
#
message: str = message
String message for this error.
Note
This may be used as a command response message.
__init__ #
__init__(message, parameter, /, *, errors=())
Initialise a conversion error.
Parameters:
- parameter (
str
) –The parameter this was raised by.
- errors (
abc.Iterable[ValueError]
, default:()
) –An iterable of the source value errors which were raised during conversion.
FailedCheck #
Bases: TanjunError
, RuntimeError
Error raised as an alternative to returning False
in a check.
FailedModuleImport #
Bases: FailedModuleLoad
Error raised when a module failed to import.
This is a specialisation of FailedModuleLoad.
FailedModuleLoad #
Bases: TanjunError
Error raised when a module fails to load.
This may be raised by the module failing to import or by one of its loaders erroring.
This source error can be accessed at FailedModuleLoad.__cause__.
FailedModuleUnload #
Bases: TanjunError
Error raised when a module fails to unload.
This may be raised by the module failing to import or by one of its unloaders erroring.
The source error can be accessed at FailedModuleUnload.__cause__.
HaltExecution #
Bases: TanjunError
Error raised while looking for a command in-order to end-execution early.
For the most part, this will be raised during checks in-order to prevent other commands from being tried.
InvalidCheck #
Bases: TanjunError
, RuntimeError
Error raised as an assertion that a check will never pass in the current environment.
ModuleMissingLoaders #
Bases: RuntimeError
, TanjunError
Error raised when a module is missing loaders.
ModuleMissingUnloaders #
Bases: RuntimeError
, TanjunError
Error raised when a module is missing unloaders.
ModuleStateConflict #
Bases: ValueError
, TanjunError
Error raised when a module cannot be (un)loaded due to a state conflict.
NotEnoughArgumentsError #
Bases: ParserError
Error raised by the parser when not enough arguments are found for a parameter.
message instance-attribute
#
message: str = message
String message for this error.
Note
This may be used as a command response message.
ParserError #
Bases: TanjunError
, ValueError
Base error raised by a parser or parameter during parsing.
Note
Expected errors raised by the parser will subclass this error.
message instance-attribute
#
message: str = message
String message for this error.
Note
This may be used as a command response message.
TooManyArgumentsError #
Bases: ParserError
Error raised by the parser when too many arguments are found for a parameter.
message instance-attribute
#
message: str = message
String message for this error.
Note
This may be used as a command response message.