Callbacks

Module containing registered callbacks for various events. These events are how various parts of discord.py can communicate with the frontend runner or a user’s custom runner setup. These callbacks should not be used to trigger backend changes, that is the responsibility of the library internals.

async dispatch_event(event: str, *args: Any, **kwargs: Any) None

Dispatch an event to a set handler, if one exists. Will ignore handler errors, just print a log

Parameters:
  • event – Name of the event to dispatch

  • args – Arguments to the callback

  • kwargs – Keyword arguments to the callback

set_callback(cb: Callable[[...], Coroutine[None, None, None]], event: str) None

Set the callback to use for a specific event

Parameters:
  • cb – Callback to use

  • event – Name of the event to register for

get_callback(event: str) Callable[[...], Coroutine[None, None, None]]

Get the current callback for an event, or raise an exception if one isn’t set

Parameters:

event – Event to get callback for

Returns:

Callback for event, if one is set

remove_callback(event: str) Callable[[...], Coroutine[None, None, None]] | None

Remove the callback set for an event, returning it, or None if one isn’t set

Parameters:

event – Event to remove callback for

Returns:

Callback that was previously set or None