Documentation

Discord

The discord package wraps bwmarrin/discordgo for gateway events, REST sends, attachment persistence, and native Discord interactions.

Start and dispatch

New(token) configures guild, guild-message, direct-message, and message-content intents. Start(ctx) validates the token with User("@me") before opening the WebSocket. Dispatch ignores the bot's own messages and invokes the registered handler synchronously. Enable Message Content Intent in the Discord Developer Portal to receive normal message text.

Sending and saving

Method Behavior
Send / Delete send a text reply or delete a message
SendFiles stream 1–10 local attachments in one message
SendVoice Gemini TTS as an OGG audio attachment, not a native voice bubble
Save UUID-named download with a 25 MiB cap

Native interactions

SendInput posts a button. Clicking it opens a modal, and submitting it invokes Reply with the answer in Input.Text. SendSelect and SendMultiSelect use Discord String Select menus. Select state is stored under a generated UUID and removed after completion; single selection uses Text, multi-selection uses CallbackPicks.

Status

Status is maintained per channel, debounced for one second, and initially adds the configured reaction (default 🤔) to the referenced message. FinishStatus waits for any active edit, removes the reaction, and deletes the status message.

中文