Skip to content

tanjun.errors#

The errors and warnings raised within and by Tanjun.

MissingDependencyError = alluka.MissingDependencyError module-attribute #

CommandError #

Bases: TanjunError

An error which is sent as a response to the command call.

__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.

PARAMETER DESCRIPTION
content

The content to respond with.

If provided, the message contents. If hikari.undefined.UNDEFINED, then nothing will be sent in the content.

TYPE: hikari.UndefinedOr[typing.Any] DEFAULT: hikari.UNDEFINED

delete_after

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.

TYPE: typing.Union[datetime.timedelta, float, int, None] DEFAULT: None

attachment

A singular attachment to respond with.

TYPE: hikari.UndefinedOr[hikari.Resourceish] DEFAULT: hikari.UNDEFINED

attachments

A sequence of attachments to respond with.

TYPE: hikari.UndefinedOr[collections.Sequence[hikari.Resourceish]] DEFAULT: hikari.UNDEFINED

component

If provided, builder object of the component to include in this response.

TYPE: hikari.UndefinedOr[hikari.api.ComponentBuilder] DEFAULT: hikari.UNDEFINED

components

If provided, a sequence of the component builder objects to include in this response.

TYPE: hikari.UndefinedOr[collections.Sequence[hikari.api.ComponentBuilder]] DEFAULT: hikari.UNDEFINED

embed

An embed to respond with.

TYPE: hikari.UndefinedOr[hikari.Embed] DEFAULT: hikari.UNDEFINED

embeds

A sequence of embeds to respond with.

TYPE: hikari.UndefinedOr[collections.Sequence[hikari.Embed]] DEFAULT: hikari.UNDEFINED

mentions_everyone

If provided, whether the message should parse @everyone/@here mentions.

TYPE: hikari.UndefinedOr[bool] DEFAULT: hikari.UNDEFINED

user_mentions

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.snowflakes.Snowflake, or hikari.users.PartialUser derivatives to enforce mentioning specific users.

TYPE: typing.Union[hikari.SnowflakeishSequence[hikari.PartialUser], bool, hikari.UndefinedType] DEFAULT: hikari.UNDEFINED

role_mentions

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.snowflakes.Snowflake, or hikari.guilds.PartialRole derivatives to enforce mentioning specific roles.

TYPE: typing.Union[hikari.SnowflakeishSequence[hikari.PartialRole], bool, hikari.UndefinedType] DEFAULT: hikari.UNDEFINED

RAISES DESCRIPTION
ValueError

Raised for any of the following reasons:

  • When both attachment and attachments are provided.
  • When both component and components are passed.
  • When both embed and embeds are passed.
  • If more than 100 entries are passed for role_mentions.
  • If more than 100 entries are passed for user_mentions.

send(ctx, /, *, ensure_result=False) async #

Send this error as a command response.

PARAMETER DESCRIPTION
ctx

The command call context to respond to.

TYPE: tanjun.Context

ensure_result

Ensure that this call will always return a message object.

If True then this will always return hikari.messages.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.

TYPE: bool DEFAULT: False

RAISES DESCRIPTION
ValueError

If delete_after would be more than 15 minutes after the slash command was called.

hikari.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.

hikari.UnauthorizedError

If you are unauthorized to make the request (invalid/missing token).

hikari.ForbiddenError

If you are missing the SEND_MESSAGES in the channel or the person you are trying to message has the DM's disabled.

hikari.NotFoundError

If the channel is not found.

hikari.RateLimitTooLongError

Raised in the event that a rate limit occurs that is longer than max_rate_limit when making a request.

hikari.RateLimitedError

Usually, Hikari will handle and retry on hitting rate-limits automatically. This includes most bucket-specific rate-limits and global rate-limits. In some rare edge cases, however, Discord implements other undocumented rules for rate-limiting, such as limits per attribute. These cannot be detected or handled normally by Hikari due to their undocumented nature, and will trigger this exception if they occur.

hikari.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.

parameter: str class-attribute #

Name of the parameter this error was raised for.

__init__(message, parameter, /, errors=()) #

Initialise a conversion error.

PARAMETER DESCRIPTION
parameter

The parameter this was raised by.

TYPE: str

errors

An iterable of the source value errors which were raised during conversion.

TYPE: collections.Iterable[ValueError] DEFAULT: ()

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 tanjun.errors.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.

__cause__: Exception class-attribute #

The root error.

path() property #

The path of the module which caused the error.

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.

__cause__: Exception class-attribute #

The root error.

path() property #

The path of the module which caused the error.

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.

message() property #

The error message.

path() property #

The path of the module which is missing loaders.

ModuleMissingUnloaders #

Bases: RuntimeError, TanjunError

Error raised when a module is missing unloaders.

message() property #

The error message.

path() property #

The path of the module which is missing unloaders.

ModuleStateConflict #

Bases: ValueError, TanjunError

Error raised when a module cannot be (un)loaded due to a state conflict.

message() property #

The error message.

path() property #

The path of the module which caused the error.

NotEnoughArgumentsError #

Bases: ParserError

Error raised by the parser when not enough arguments are found for a parameter.

parameter: str class-attribute #

Name of the parameter this error was raised for.

__init__(message, parameter) #

Initialise a not enough arguments error.

PARAMETER DESCRIPTION
message

The error message.

TYPE: str

parameter

The parameter this error was raised for.

TYPE: str

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.

__init__(message, parameter) #

Initialise a parser error.

PARAMETER DESCRIPTION
message

String message for this error.

TYPE: str

parameter

Name of the parameter which caused this error, should be None if not applicable.

TYPE: typing.Optional[str]

TanjunError #

Bases: Exception

The base class for all errors raised by Tanjun.

TooManyArgumentsError #

Bases: ParserError

Error raised by the parser when too many arguments are found for a parameter.

parameter: str class-attribute #

Name of the parameter this error was raised for.

__init__(message, parameter) #

Initialise a too many arguments error.

PARAMETER DESCRIPTION
message

The error message.

TYPE: str

parameter

The parameter this error was raised for.

TYPE: str