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 channelmsgs, _:=c.Messages().Read(ctx, "", 20, "") // oldest-first| Accessor | Operations |
|---|---|
Messages() | SendReplyReadGetEditDeleteLastMessageAt |
Channels() | ListGetTypeCreateCreateUnderRenameUpdateDeleteEnsureEnsureUnderArchive |
Guilds() | ListSole |
Members() | ListGetKickBan |
Roles() | ListCreateUpdateDeleteAssignUnassign |
Threads() | StartStartPrivateAddMemberCreateForumForumPost |
Reactions() | AddRemove |
Permissions() | SetRemove |
Webhooks() | CreateListDeleteExecute |
Components() | SendSelectMenuAck |
Interactions() | RegisterRegisterCommandsListCreateEditDeleteRegistryRespondDeferRespondAutocompleteEditResponseUpsertStatusMessageAppID |
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