gda is a low-level Go driver for the Discord API v10 and Gateway WebSocket protocol, implemented using only the Go standard library. It provides direct access to event streams
8FDD
, REST endpoints, and interaction webhooks without forcing an opinionated application architecture.
gda is designed to be the protocol foundation:
gda: Direct access to Gateway events, REST routes, and interaction handlers. You control socket lifecycles, HTTP servers, and execution flows directly.gdk: A higher-level interaction framework built on top ofgda. Choosegdkif you want automated slash command registration, cooldowns, role permission guards, and auto-deferrals.
Note
gdk is currently under development and will be available soon.
go get github.com/sfossl/gdapackage main
import (
"context"
"fmt"
"log"
"os"
"github.com/sfossl/gda"
"github.com/sfossl/gda/rest"
"github.com/sfossl/gda/types"
)
func main() {
client, err := gda.New(
os.Getenv("TOKEN"),
gda.WithIntents(types.IntentGuildMessages|types.IntentMessageContent),
)
if err != nil {
log.Fatal(err)
}
client.OnReady(func(ctx context.Context, r *types.ReadyEvent) {
fmt.Printf("Logged in as %s\n", r.User.Username)
})
client.OnMessageCreate(func(ctx context.Context, msg *types.Message) {
if msg.Author.Bot {
return
}
if msg.Content == "hi" {
_, _ = client.REST.SendMessage(ctx, msg.ChannelID, rest.MessagePayload{
Content: "hello from gda!",
})
}
})
if err := client.Start(context.Background()); err != nil {
log.Fatal(err)
}
}- State Storage:
gdadoes not maintain global caches for guilds, channels, or members. State requirements vary drastically between a single-process bot and a multi-shard cluster, so caching strategy is left entirely to the application layer. - Audio: Discord voice streaming requires Opus encoding and media transcoding. Rather than introducing CGO or external FFmpeg dependencies,
gdaprovides voice protocol types and leaves media processing to dedicated audio tooling. - Dependencies: The entire driver relies solely on standard library packages (
net/http,crypto/ed25519,compress/zlib), ensuring fast builds, zero dependency drift, and simple cross-compilation.