Event Hooks
Event hooks allow your script to respond to Discord events in real-time. Set a function to an event property to handle that event.Scripts are written in JavaScript and executed by the Go client using Goja.
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_edit
Fired when a message is edited.Event Context
Example
discord.on_message_delete
Fired when a message is deleted.Event Context
Example
Reaction Events
discord.on_reaction_add
Fired when a reaction is added to a message.Event Context
Example
discord.on_reaction_remove
Fired when a reaction is removed from a message.Event Context
Same structure ason_reaction_add - includes full user, guild, channel, message, and emoji objects.
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
Same structure ason_channel_create - includes full channel and guild objects.
Example
discord.on_channel_delete
Fired when a channel is deleted.Event Context
Example
Member Events
discord.on_guild_member_add
Fired when a user joins a server/guild.Event Context
Example
discord.on_guild_member_remove
Fired when a member leaves or is kicked from a server.Event Context
Example
discord.on_guild_member_update
Fired when a member is updated (roles changed, nickname changed, etc.).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
Same structure ason_guild_role_create - includes full guild and role objects.
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
Activity 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
Activities Array (if present)
| Property | Type | Description |
|---|---|---|
name | string | Activity name |
type | number | Activity type (0=playing, 1=streaming, 2=listening, 3=watching, 4=custom, 5=competing) |
url | string | undefined | Stream URL (required for streaming type) |
state | string | undefined | Activity state text |
details | string | undefined | Activity details text |
application_id | string | undefined | Application ID for the activity |
timestamps | object | undefined | Unix timestamps (start, end) |
assets | object | undefined | Activity assets (large_image, large_text, small_image, small_text) |
party | object | undefined | Party information (id, size) |
emoji | object | undefined | Emoji for custom status (name, id, animated) |
buttons | string[] | undefined | Button labels (max 2) |
created_at | number | undefined | Unix timestamp of when activity was added |