Discord REST API (v10) client for Go. Dependency-free — standard library only, enforced by a test that fails on any non-stdlib import. No gateway websocket, no event loop, no CLI: every call is an on-demand HTTP request.
go get github.com/Herrscherd/dctlc := dctl.New(token, defaultChannelID)
msg, _ := c.Messages().Send(ctx, "", "deploy finished") // "" => default channel
msgs, _ := c.Messages().Read(ctx, "", 20, "") // oldest-first| Accessor | Operations |
|---|---|
Messages() |
Send Reply Read Get Edit Delete LastMessageAt |
Channels() |
List Get Type Create CreateUnder Rename Update Delete Ensure EnsureUnder Archive |
Guilds() |
List Sole |
Members() |
List Get Kick Ban |
Roles() |
List Create Update Delete Assign Unassign |
Threads() |
Start StartPrivate AddMember CreateForum ForumPost |
Reactions() |
Add Remove |
Permissions() |
Set Remove |
Webhooks() |
Create List Delete Execute |
Components() |
SendSelectMenu Ack |
Interactions() |
Register RegisterCommands List Create Edit Delete Registry Respond Defer RespondAutocomplete EditResponse UpsertStatusMessage AppID |
Channel-scoped ops accept "" for the configured default channel; guild-scoped
ops accept "" for the bot's sole guild — or for the guild pinned by
WithGuild, which a bot in several servers needs. CreateUnder / EnsureUnder
need neither: they read the guild off the parent category. Nothing is read from the
environment — pass the token explicitly. Without one, Enabled() is false and
every call returns ErrDisabled. WithHTTPClient overrides the default 15s
client.
Slash commands: NewCommand(...).With(dctl.String(...), dctl.Sub(...)) builds a
typed command; c.Interactions().Registry() owns Add, Sync (diff against
Discord: create/edit/delete), and Dispatch / DispatchAutocomplete. They are
registered on the default guild — instant, one server — or on the application
with WithGlobalCommands, which reaches every server the bot is in and takes up
to an hour to propagate.
Interaction.UserID() is who invoked it, from member.user in a guild and from
user in a DM — read either field alone and permission checks see an empty id in
the other context.
Path segments are percent-escaped and queries built with url.Values.
Webhook.Token and Interaction.Token are Secret — [REDACTED] in logs and
JSON, .Reveal() to read.
MIT