Discord Events
All Discord events are available through thediscord namespace. Set a function to an event property to handle that event in real-time.
Message Events
discord.on_message
Fired when any message is received in Discord.Event Context
The event receives actx object:
| Property | Type | Description |
|---|---|---|
ctx.message | Message | Full message object (id, content, timestamp, etc.) |
ctx.guild | Guild | Full guild object (name, member_count, icon, etc.) |
ctx.channel | Channel | Full channel object (name, type, topic, etc.) |
ctx.author | Author | Full author object (username, id, avatar, etc.) |
ctx.content | string | Message content (shortcut for ctx.message.content) |
ctx.mentions | Author[] | Mentioned users |
ctx.attachments | Attachment[] | Message attachments |
ctx.embeds | Embed[] | Message embeds |
Example
discord.on_message_update
Fired when a message is edited.Event Context
Example
discord.on_message_delete
Fired when a message is deleted.Event Context
Example
discord.on_message_delete_bulk
Fired when multiple messages are deleted at once (e.g., bulk delete).Event Context
Example
Reaction Events
discord.on_message_reaction_add
Fired when a reaction is added to a message.Event Context
Example
discord.on_message_reaction_remove
Fired when a reaction is removed from a message.Event Context
Same structure ason_message_reaction_add.
Example
discord.on_message_reaction_remove_all
Fired when all reactions are removed from a message.Event Context
Example
discord.on_message_reaction_remove_emoji
Fired when all reactions of a specific emoji are removed from a message.Event Context
| Property | Type | Description |
|---|---|---|
ctx.message_id | string | Message ID |
ctx.channel_id | string | Channel ID |
ctx.guild_id | string | Guild ID (if in a server) |
ctx.emoji | Object | Emoji that was removed |
ctx.emoji.name | string | Emoji name |
ctx.emoji.id | string | Emoji ID (custom emojis) |
ctx.channel | Channel | Full channel object |
ctx.guild | Guild | Full guild object (if in a server) |
Example
Poll Events
discord.on_message_poll_vote_add
Fired when a user votes in a poll.Event Context
Example
discord.on_message_poll_vote_remove
Fired when a user removes their vote from a poll.Event Context
Same structure ason_message_poll_vote_add.
Example
Channel Events
discord.on_channel_create
Fired when a channel is created.Event Context
Example
discord.on_channel_update
Fired when a channel is updated (name, topic, permissions, etc.).Event Context
Example
discord.on_channel_delete
Fired when a channel is deleted.Event Context
Example
discord.on_channel_pins_update
Fired when a message is pinned or unpinned in a channel.Event Context
Example
discord.on_channel_recipient_add
Fired when a user is added to a group DM.Event Context
Example
discord.on_channel_recipient_remove
Fired when a user is removed from a group DM.Event Context
Same structure ason_channel_recipient_add.
Example
Guild Events
discord.on_guild_create
Fired when YOU join a server or when a server becomes available.
Note: This is different from on_guild_member_add which fires when OTHER users join a server.
Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild | Guild | Full guild object |
Example
discord.on_guild_update
Fired when a guild is updated (name, icon, settings, etc.).Event Context
Example
discord.on_guild_delete
Fired when YOU leave a server or when a server becomes unavailable.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild_id | string | ID of the guild you left |
ctx.unavailable | boolean | True if the guild is unavailable (outage), false if you left |
Example
discord.on_guild_emojis_update
Fired when a guild’s emojis are updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild_id | string | Guild ID |
ctx.emojis | Emoji[] | Array of emoji objects |
ctx.guild | Guild | Full guild object |
Example
discord.on_guild_integrations_update
Fired when a guild’s integrations are updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild_id | string | The guild ID |
ctx.guild | Guild | Guild context |
Example
discord.on_guild_members_chunk
Fired when a chunk of guild members is received.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild_id | string | The guild ID |
ctx.members | Member[] | Array of member objects |
ctx.chunk_index | number | Current chunk index |
ctx.chunk_count | number | Total number of chunks |
ctx.nonce | string | Request nonce |
ctx.guild | Guild | Guild context |
Example
Member Events
discord.on_guild_member_add
Fired when ANOTHER USER joins a server/guild.
Important: This event only fires when OTHER users join servers, not when YOU join a server. If you want to detect when you join a server, use discord.on_guild_create instead.
Event Context
Example
discord.on_guild_member_update
Fired when a member is updated (roles changed, nickname changed, etc.).Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated member state with user, nick, roles, joined_at |
ctx.before | object | Previous member state (if cached) |
ctx.guild | Guild | Full guild object |
Example
discord.on_guild_member_remove
Fired when a member leaves or is kicked from a server.Event Context
Example
Role Events
discord.on_guild_role_create
Fired when a role is created.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild | Guild | Full guild object |
ctx.role | Role | Full role object (id, name, color, permissions, etc.) |
Example
discord.on_guild_role_update
Fired when a role is updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated role object |
ctx.before | object | Previous role state (if cached) |
ctx.guild | Guild | Full guild object |
Example
discord.on_guild_role_delete
Fired when a role is deleted.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild | Guild | Full guild object |
ctx.role_id | string | The deleted role ID |
Example
Ban Events
discord.on_guild_ban_add
Fired when a user is banned from a guild.Event Context
Example
discord.on_guild_ban_remove
Fired when a user is unbanned from a guild.Event Context
Same structure ason_guild_ban_add.
Example
Thread Events
discord.on_thread_create
Fired when a thread is created.Event Context
Example
discord.on_thread_update
Fired when a thread is updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated thread object |
ctx.before | object | Previous thread state (if cached) |
ctx.guild | Guild | Full guild object |
Example
discord.on_thread_delete
Fired when a thread is deleted.Event Context
Example
discord.on_thread_list_sync
Fired when thread member lists are synchronized.Event Context
Example
discord.on_thread_member_update
Fired when the current user’s thread member object is updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Thread ID |
ctx.guild_id | string | Guild ID |
ctx.user_id | string | User ID |
ctx.join_timestamp | string | When the user joined the thread |
ctx.flags | number | Thread member flags |
ctx.guild | Guild | Full guild object |
Example
discord.on_thread_members_update
Fired when members are added or removed from a thread.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Thread ID |
ctx.guild_id | string | Guild ID |
ctx.member_count | number | Approximate member count |
ctx.added_members | ThreadMember[] | Array of added members |
ctx.removed_member_ids | string[] | Array of removed member IDs |
ctx.guild | Guild | Full guild object |
Example
Voice Events
discord.on_voice_state_update
Fired when a user’s voice state changes (joins/leaves voice channel, mutes, deafens, etc.).Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated voice state with all properties |
ctx.before | object | Previous voice state (if cached) |
ctx.guild | Guild | Full guild object |
Example
discord.on_voice_server_update
Fired when a voice server endpoint is updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.token | string | Voice connection token |
ctx.guild_id | string | Guild ID |
ctx.endpoint | string | Voice server endpoint |
Example
Typing & Presence Events
discord.on_typing_start
Fired when a user starts typing in a channel.Event Context
Example
discord.on_presence_update
Fired when a user’s presence/status changes (online, offline, idle, etc.).Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated presence with user, status, activities |
ctx.before | object | Previous presence state (if cached) |
ctx.guild | Guild | Full guild object |
Example
discord.on_presences_replace
Fired when all presences are replaced (rare event during reconnection).Event Context
| Property | Type | Description |
|---|---|---|
ctx.presences | Presence[] | Array of presence objects |
Example
User & Relationship Events
discord.on_user_update
Fired when the current user’s account is updated (username, avatar, email, etc.).Event Context
Example
discord.on_relationship_add
Fired when a relationship is added (friend request sent/received, friend added, blocked user, etc.).Event Context
| Property | Type | Description |
|---|---|---|
ctx.relationship.id | string | User ID of the relationship |
ctx.relationship.type | number | Relationship type (1=friend, 2=blocked, 3=incoming request, 4=outgoing request) |
ctx.relationship.user | Author | User object |
ctx.relationship.since | string | ISO timestamp of when relationship was created |
ctx.relationship.status | string | User’s current status |
Example
discord.on_relationship_update
Fired when a relationship is updated (e.g., friend accepted, nickname changed, status changed).Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated relationship with id, type, user, since, status |
ctx.before | object | Previous relationship state (if cached) |
Example
discord.on_relationship_remove
Fired when a relationship is removed (unfriended, unblocked, friend request cancelled/declined, etc.).Event Context
Same structure ason_relationship_add.
Example
Call Events
discord.on_call_create
Fired when a call starts in a private channel or group DM.Event Context
| Property | Type | Description |
|---|---|---|
ctx.channel_id | string | Channel ID |
ctx.message_id | string | Call message ID |
ctx.region | string | Voice region |
ctx.ringing | string[] | Array of user IDs being rung |
ctx.unavailable | boolean | Whether the call is unavailable |
ctx.channel | Channel | Full channel object |
Example
discord.on_call_update
Fired when a call state is updated.Event Context
Same structure ason_call_create.
Example
discord.on_call_delete
Fired when a call ends.Event Context
| Property | Type | Description |
|---|---|---|
ctx.channel_id | string | Channel ID |
ctx.unavailable | boolean | Whether the call ended due to unavailability |
ctx.channel | Channel | Full channel object |
Example
Invite Events
discord.on_invite_create
Fired when an invite is created.Event Context
| Property | Type | Description |
|---|---|---|
ctx.code | string | Invite code |
ctx.guild_id | string | Guild ID |
ctx.channel_id | string | Channel ID |
ctx.inviter | Author | User who created the invite |
ctx.created_at | string | Creation timestamp |
ctx.expires_at | string | Expiration timestamp |
ctx.max_age | number | Max age in seconds |
ctx.max_uses | number | Max number of uses |
ctx.temporary | boolean | Whether invite grants temporary membership |
ctx.uses | number | Number of times used |
ctx.guild | Guild | Full guild object |
ctx.channel | Channel | Full channel object |
Example
discord.on_invite_delete
Fired when an invite is deleted or expires.Event Context
Example
Friend Suggestion Events
discord.on_friend_suggestion_create
Fired when Discord suggests a friend.Event Context
| Property | Type | Description |
|---|---|---|
ctx.suggested_user | Author | Suggested user object |
ctx.reasons | Object[] | Array of suggestion reasons |
Example
discord.on_friend_suggestion_delete
Fired when a friend suggestion is removed.Event Context
| Property | Type | Description |
|---|---|---|
ctx.suggested_user_id | string | ID of the suggested user |
Example
Integration & Webhook Events
discord.on_integration_create
Fired when an integration is created in a guild.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Integration ID |
ctx.name | string | Integration name |
ctx.type | string | Integration type (twitch, youtube, discord, etc.) |
ctx.enabled | boolean | Whether the integration is enabled |
ctx.guild_id | string | Guild ID |
ctx.guild | Guild | Full guild object |
Example
discord.on_integration_update
Fired when an integration is updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated integration object |
ctx.before | object | Previous integration state (if cached) |
ctx.guild | Guild | Full guild object |
Example
discord.on_integration_delete
Fired when an integration is deleted.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Integration ID |
ctx.guild_id | string | Guild ID |
ctx.application_id | string | Application ID (if applicable) |
ctx.guild | Guild | Full guild object |
Example
discord.on_webhooks_update
Fired when a guild’s webhooks are updated.Event Context
Example
Auto Moderation Events
discord.on_auto_moderation_rule_create
Fired when an auto moderation rule is created.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Rule ID |
ctx.guild_id | string | Guild ID |
ctx.name | string | Rule name |
ctx.creator_id | string | User who created the rule |
ctx.event_type | number | Event type |
ctx.trigger_type | number | Trigger type |
ctx.enabled | boolean | Whether the rule is enabled |
ctx.guild | Guild | Full guild object |
Example
discord.on_auto_moderation_rule_update
Fired when an auto moderation rule is updated.Event Context
Same structure ason_auto_moderation_rule_create.
Example
discord.on_auto_moderation_rule_delete
Fired when an auto moderation rule is deleted.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Rule ID |
ctx.guild_id | string | Guild ID |
ctx.guild | Guild | Full guild object |
Example
discord.on_auto_moderation_action_execution
Fired when an auto moderation action is executed.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild_id | string | Guild ID |
ctx.action | Object | Action that was executed |
ctx.rule_id | string | Rule ID that triggered |
ctx.user_id | string | User who triggered the rule |
ctx.channel_id | string | Channel ID (if applicable) |
ctx.message_id | string | Message ID (if applicable) |
ctx.matched_keyword | string | Keyword that was matched |
ctx.matched_content | string | Full matched content |
ctx.guild | Guild | Full guild object |
Example
Entitlement Events
discord.on_entitlement_create
Fired when an entitlement (subscription, premium purchase) is created.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Entitlement ID |
ctx.sku_id | string | SKU (product) ID |
ctx.application_id | string | Application ID |
ctx.user_id | string | User who owns the entitlement |
ctx.type | number | Entitlement type |
ctx.starts_at | string | Start timestamp |
ctx.ends_at | string | End timestamp |
Example
discord.on_entitlement_update
Fired when an entitlement is updated.Event Context
Same structure ason_entitlement_create.
Example
discord.on_entitlement_delete
Fired when an entitlement is deleted.Event Context
Same structure ason_entitlement_create.
Example
Guild Scheduled Events
discord.on_guild_scheduled_event_create
Fired when a guild scheduled event is created.Event Context
| Property | Type | Description |
|---|---|---|
ctx.id | string | Event ID |
ctx.guild_id | string | Guild ID |
ctx.name | string | Event name |
ctx.description | string | Event description |
ctx.scheduled_start_time | string | Start timestamp |
ctx.scheduled_end_time | string | End timestamp |
ctx.creator_id | string | User who created the event |
ctx.guild | Guild | Full guild object |
Example
discord.on_guild_scheduled_event_update
Fired when a guild scheduled event is updated.Event Context
| Property | Type | Description |
|---|---|---|
ctx.after | object | Updated scheduled event object |
ctx.before | object | Previous scheduled event state (if cached) |
ctx.guild | Guild | Full guild object |
Example
discord.on_guild_scheduled_event_delete
Fired when a guild scheduled event is deleted.Event Context
Same structure ason_guild_scheduled_event_create.
Example
discord.on_guild_scheduled_event_user_add
Fired when a user subscribes to a guild scheduled event.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild_scheduled_event_id | string | Event ID |
ctx.user_id | string | User ID |
ctx.guild_id | string | Guild ID |
ctx.guild | Guild | Full guild object |
Example
discord.on_guild_scheduled_event_user_remove
Fired when a user unsubscribes from a guild scheduled event.Event Context
Same structure ason_guild_scheduled_event_user_add.
Example
Stage Instance Events
discord.on_stage_instance_create
Fired when a stage instance is created.Event Context
Example
discord.on_stage_instance_update
Fired when a stage instance is updated.Event Context
Same structure ason_stage_instance_create.
Example
discord.on_stage_instance_delete
Fired when a stage instance is deleted.Event Context
Same structure ason_stage_instance_create.
Example
Audit Log & System Events
discord.on_guild_audit_log_entry_create
Fired when a new audit log entry is created in a guild.Event Context
| Property | Type | Description |
|---|---|---|
ctx.guild_id | string | The guild ID |
ctx.entry.id | string | Entry ID |
ctx.entry.action_type | number | Type of action performed |
ctx.entry.user_id | string | User who performed the action |
ctx.entry.target_id | string | Target of the action |
ctx.entry.reason | string | Reason for the action |
ctx.guild | Guild | Guild context |