discord-interactions

Dispatching

class interactions.api.dispatch.Listener

A class representing how events become dispatched and listened to.

Variables
dispatch(name: str, *args, **kwargs) None

Dispatches an event given out by the gateway.

Parameters
  • name (str) – The name of the event to dispatch.

  • *args (typing.list[typing.Any]) – Multiple arguments of the coroutine.

  • **kwargs (dict) – Keyword-only arguments of the coroutine.

Returns

None

register(coro: Coroutine, name: Optional[str] = None) None

Registers a given coroutine as an event to be listened to. If the name of the event is not given, it will then be determined by the coroutine’s name.

i.e. : async def on_guild_create -> “ON_GUILD_CREATE” dispatch.

Parameters
  • coro (typing.Coroutine) – The coroutine to register as an event.

  • name (typing.Optional[str]) – The name to associate the coroutine with. Defaults to None.

Returns

None