Serve Events

When running discli serve, events are emitted as JSONL (one JSON object per line) on stdout. Every event includes an "event" field identifying the event type.


ready

Emitted once when the bot connects to the Discord gateway. This fires before slash commands are synced.

{
"event": "ready",
"bot_id": "123456789",
"bot_name": "MyBot#1234"
}
FieldTypeDescription
bot_idstringBot’s user snowflake ID
bot_namestringBot’s username and discriminator

slash_commands_synced

Emitted after slash commands have been registered with Discord (only if --slash-commands was provided).

{
"event": "slash_commands_synced",
"count": 3,
"guilds": 2
}
FieldTypeDescription
countintegerNumber of slash commands registered
guildsintegerNumber of guilds commands were synced to

message

Emitted when a message is sent in a visible channel. Bot messages from other bots are excluded; the bot’s own messages are included by default (controlled by --include-self / --no-include-self).

{
"event": "message",
"server": "My Server",
"server_id": "123456",
"channel": "general",
"channel_id": "789012",
"author": "alice",
"author_id": "111222",
"is_bot": false,
"content": "Hello everyone!",
"timestamp": "2024-01-15T12:30:00+00:00",
"message_id": "333444",
"mentions_bot": false,
"is_dm": false,
"attachments": [],
"reply_to": null
}
FieldTypeDescription
serverstring | nullServer name, or null for DMs
server_idstring | nullServer snowflake ID, or null for DMs
channelstringChannel name, or "DM" for direct messages
channel_idstringChannel snowflake ID
authorstringMessage author’s username
author_idstringAuthor’s user snowflake ID
is_botbooleanWhether the author is a bot
contentstringMessage text content
timestampstringISO 8601 timestamp
message_idstringMessage snowflake ID
mentions_botbooleanWhether the message @-mentions the bot
is_dmbooleanWhether this is a direct message
attachmentsarrayList of {"filename", "url", "size"} objects
reply_tostring | nullMessage ID this is a reply to, or null

slash_command

Emitted when a user invokes a registered slash command. The interaction is automatically deferred (shows “thinking…”). You must respond using interaction_followup or stream_start with the interaction_token.

{
"event": "slash_command",
"command": "ask",
"args": {"question": "What is discli?"},
"channel_id": "789012",
"user": "alice",
"user_id": "111222",
"guild_id": "123456",
"interaction_token": "uuid-string",
"is_admin": false
}
FieldTypeDescription
commandstringSlash command name
argsobjectKey-value map of command arguments (all values are strings)
channel_idstringChannel where the command was invoked
userstringUsername of the invoking user
user_idstringUser snowflake ID
guild_idstring | nullServer ID, or null for DM slash commands
interaction_tokenstringToken for responding via interaction_followup or stream_start
is_adminbooleanWhether the user has administrator permission in the guild

message_edit

Emitted when a non-bot user edits a message.

{
"event": "message_edit",
"server": "My Server",
"server_id": "123456",
"channel": "general",
"channel_id": "789012",
"author": "alice",
"author_id": "111222",
"message_id": "333444",
"old_content": "Hello",
"new_content": "Hello everyone!",
"timestamp": "2024-01-15T12:35:00+00:00"
}
FieldTypeDescription
serverstring | nullServer name
server_idstring | nullServer snowflake ID
channelstringChannel name
channel_idstringChannel snowflake ID
authorstringAuthor username
author_idstringAuthor user snowflake ID
message_idstringEdited message snowflake ID
old_contentstring | nullPrevious message content (may be null if uncached)
new_contentstringNew message content
timestampstringISO 8601 timestamp of the edit

message_delete

Emitted when a message is deleted.

{
"event": "message_delete",
"server": "My Server",
"server_id": "123456",
"channel": "general",
"channel_id": "789012",
"author": "alice",
"author_id": "111222",
"message_id": "333444",
"content": "Hello everyone!"
}
FieldTypeDescription
serverstring | nullServer name
server_idstring | nullServer snowflake ID
channelstringChannel name
channel_idstringChannel snowflake ID
authorstring | nullAuthor username (null if uncached)
author_idstring | nullAuthor user snowflake ID (null if uncached)
message_idstringDeleted message snowflake ID
contentstring | nullMessage content (null if uncached)

reaction_add

Emitted when a user adds a reaction to a message.

{
"event": "reaction_add",
"server": "My Server",
"channel": "general",
"channel_id": "789012",
"message_id": "333444",
"emoji": "thumbsup",
"user": "alice",
"user_id": "111222"
}
FieldTypeDescription
serverstring | nullServer name
channelstringChannel name
channel_idstringChannel snowflake ID
message_idstringMessage snowflake ID
emojistringEmoji name or unicode character
userstringUsername of the user who reacted
user_idstringUser snowflake ID

reaction_remove

Emitted when a user removes a reaction from a message.

{
"event": "reaction_remove",
"server": "My Server",
"channel": "general",
"channel_id": "789012",
"message_id": "333444",
"emoji": "thumbsup",
"user": "alice",
"user_id": "111222"
}
FieldTypeDescription
serverstring | nullServer name
channelstringChannel name
channel_idstringChannel snowflake ID
message_idstringMessage snowflake ID
emojistringEmoji name or unicode character
userstringUsername of the user
user_idstringUser snowflake ID

member_join

Emitted when a new member joins a server.

{
"event": "member_join",
"server": "My Server",
"server_id": "123456",
"member": "alice",
"member_id": "111222"
}
FieldTypeDescription
serverstringServer name
server_idstringServer snowflake ID
memberstringNew member’s username
member_idstringMember’s user snowflake ID

member_remove

Emitted when a member leaves or is removed from a server.

{
"event": "member_remove",
"server": "My Server",
"server_id": "123456",
"member": "alice",
"member_id": "111222"
}
FieldTypeDescription
serverstringServer name
server_idstringServer snowflake ID
memberstringMember’s username
member_idstringMember’s user snowflake ID

response

Emitted as the reply to every stdin action. Contains "ok": true on success or an "error" string on failure. If the original action included a req_id, it is echoed back.

{"event": "response", "ok": true, "message_id": "789", "req_id": "1"}
{"event": "response", "error": "Channel not found: 999", "req_id": "2"}
FieldTypeDescription
okbooleanPresent and true on success
errorstringPresent on failure with an error description
req_idstringEchoed from the original action, if provided
(varies)Additional fields depend on the action (see Serve Actions)

error

Emitted when an internal error occurs (e.g., invalid JSON on stdin, slash command sync failure).

{"event": "error", "message": "Invalid JSON: {bad input"}
FieldTypeDescription
messagestringError description

shutdown

Emitted when the bot process is shutting down (e.g., Ctrl+C).

{"event": "shutdown"}

No additional fields.


Event Filtering

Use the --events option to limit which events are emitted. Pass a comma-separated list of event categories:

CategoryEvents included
messagesmessage
editsmessage_edit
deletesmessage_delete
reactionsreaction_add, reaction_remove
membersmember_join, member_remove

The ready, slash_command, slash_commands_synced, response, error, and shutdown events are always emitted regardless of the filter.

Example:

discli serve --events messages,reactions