Skip to main content
alterself translates every raw Discord gateway dispatch into a typed Python event that your handlers receive as structured model objects. You register handlers with the @bot.on("EVENT_NAME") decorator, and alterself automatically parses the incoming JSON payload into the appropriate type before calling your function. This page lists every supported event, the type your handler receives as its argument, and what triggers the event.

Connection Events

Connection events fire during session lifecycle transitions. You receive them when your client first authenticates with the gateway or when a dropped session is successfully resumed.

Message Events

Message events cover the full lifecycle of a Discord message: creation, editing, deletion, bulk deletion, and reactions.
MESSAGE_UPDATE and MESSAGE_DELETE pass None when the message was not present in alterself’s cache at the time of the event. This is normal. Discord does not resend full message content in update or delete payloads, so alterself can only provide a model when the original message was cached from a prior MESSAGE_CREATE.

Guild Events

Guild events fire when servers become available, change, or when members join or leave.

Channel Events

Channel events fire when channels or threads are created, modified, or deleted within guilds you are in.

Presence and Typing Events

These events notify you of user activity: when someone starts typing in a channel, or when a user’s presence (online status, activity) changes.
Presence and typing events are delivered as raw dict objects rather than typed models. Discord’s presence payload is highly variable in structure depending on the activity type, and parsing it into a rigid model would discard information. Use dictionary access to extract the fields you need.

Relationship Events

Relationship events are unique to user accounts. Bots do not receive them. They fire when the friends list or incoming friend request state changes.
Relationship events are only dispatched to user (selfbot) accounts. They will never arrive for bot token sessions.

Voice Events

Voice events fire when voice state changes, such as users joining or leaving voice channels, or when Discord assigns your client a voice server endpoint.

Raw Event Access

Every gateway dispatch, including events not listed above, is accessible by passing its exact name to @bot.listen. You receive the raw unparsed dict payload exactly as Discord sends it.
Use @bot.listen when you need access to fields that alterself’s model layer does not expose, or when you are handling an event type that alterself does not yet parse into a typed object.
Handlers that accept no parameters are completely valid. alterself inspects your handler’s signature at registration time and omits the argument if your function declares none. This is particularly useful for RESUMED, where there is no meaningful payload to act on.