hikari.events.base_events#

Base types and functions for events in Hikari.

Module Contents#

class hikari.events.base_events.Event[source]#

Bases: abc.ABC

Base event type that all Hikari events should subclass.

abstract property app: hikari.traits.RESTAware[source]#

App instance for this application.

classmethod bitmask()[source]#

Bitmask for this event.

classmethod dispatches()[source]#

Sequence of the event classes this event is dispatched as.

class hikari.events.base_events.ExceptionEvent[source]#

Bases: Event, Generic[EventT]

Event that is raised when another event handler raises an Exception.

Note

Only exceptions that derive from Exception will be caught. Other exceptions outside this range will propagate past this callback. This prevents event handlers interfering with critical exceptions such as KeyboardError which would have potentially undesired side-effects on the application runtime.

property app: hikari.traits.RESTAware[source]#

App instance for this application.

property exc_info: Tuple[Type[Exception], Exception, types.TracebackType | None][source]#

Exception triplet that follows the same format as sys.exc_info.

The sys.exc_info tiplet consists of the exception type, the exception instance, and the traceback of the exception.

property shard: hikari.api.shard.GatewayShard | None[source]#

Shard that received the event, if there was one associated.

This may be None if no specific shard was the cause of this exception (e.g. when starting up or shutting down).

exception: Exception[source]#

Exception that was raised.

failed_callback: FailedCallbackT[EventT][source]#

Event callback that threw an exception.

failed_event: EventT[source]#

Event instance that caused the exception.

async retry()[source]#

Invoke the failed event again.

If an exception is thrown this time, it will need to be manually caught in-code, or will be discarded.

hikari.events.base_events.get_required_intents_for(event_type)[source]#

Retrieve the intents that are required to listen to an event type.

Parameters:
event_typetyping.Type[Event]

The event type to get required intents for.

Returns:
typing.Collection[hikari.intents.Intents]

Collection of acceptable subset combinations of intent needed to be able to receive the given event type.

hikari.events.base_events.is_no_recursive_throw_event(obj)[source]#

Return True if this event is marked as ___norecursivethrow___.

hikari.events.base_events.no_recursive_throw()[source]#

Decorate an event type to indicate errors should not be handled.

This is useful for exception event types that you do not want to have invoked recursively.

hikari.events.base_events.requires_intents(first, *rest)[source]#

Decorate an event type to define what intents it requires.

Parameters:
firsthikari.intents.Intents

First combination of intents that are acceptable in order to receive the decorated event type.

*resthikari.intents.Intents

Zero or more additional combinations of intents to require for this event to be subscribed to.