Skip to content

hikari.events.base_events#

Base types and functions for events in Hikari.

Event #

Bases: ABC

Base event type that all Hikari events should subclass.

app abstractmethod property #

app: RESTAware

App instance for this application.

bitmask classmethod #

bitmask() -> int

Bitmask for this event.

dispatches classmethod #

dispatches() -> Sequence[Type[Event]]

Sequence of the event classes this event is dispatched as.

ExceptionEvent #

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 KeyboardInterrupt which would have potentially undesired side-effects on the application runtime.

app property #

app: RESTAware

App instance for this application.

exc_info property #

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

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

exception class-attribute instance-attribute #

exception: Exception = field()

Exception that was raised.

failed_callback class-attribute instance-attribute #

failed_callback: FailedCallbackT[EventT] = field()

Event callback that threw an exception.

failed_event class-attribute instance-attribute #

failed_event: EventT = field()

Event instance that caused the exception.

shard property #

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

bitmask classmethod #

bitmask() -> int

Bitmask for this event.

dispatches classmethod #

dispatches() -> Sequence[Type[Event]]

Sequence of the event classes this event is dispatched as.

retry async #

retry() -> None

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.

get_required_intents_for #

get_required_intents_for(event_type: Type[Event]) -> Collection[Intents]

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

PARAMETER DESCRIPTION
event_type

The event type to get required intents for.

TYPE: Type[Event]

RETURNS DESCRIPTION
Collection[Intents]

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

is_no_recursive_throw_event #

is_no_recursive_throw_event(obj: Union[_T, Type[_T]]) -> bool

Whether the event is marked as ___norecursivethrow___.

no_recursive_throw #

no_recursive_throw() -> Callable[[_T], _T]

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.

requires_intents #

requires_intents(first: Intents, *rest: Intents) -> Callable[[_T], _T]

Decorate an event type to define what intents it requires.

PARAMETER DESCRIPTION
first

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

TYPE: Intents

*rest

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

TYPE: Intents DEFAULT: ()