A lightweight and idiomatic Discord API wrapper for Go.
- Context-First: Built entirely around Go's standard
context.Contextpackage. - Pluggable Components: First-class support for swapping core components (like caching, rate limit stores, logging) with custom implementations.
- Automatic Sharding: Full support for automatic and manual sharding in an easy way.
go get github.com/wumpkit/wumpkit
Requires Go 1.27+.
package main import ( "context" "fmt" "log/slog" "os" "github.com/wumpkit/wumpkit" ) func main() { token := os.Getenv("DISCORD_TOKEN") if token == "" { slog.Error("DISCORD_TOKEN is required") os.Exit(1) } bot := wumpkit.New( context.Background(), wumpkit.WithToken(token), wumpkit.WithGatewayConfig(wumpkit.ShardManagerConfig{ Intents: wumpkit.GatewayIntentGuilds | wumpkit.GatewayIntentGuildMessages | wumpkit.GatewayIntentMessageContent, }), ) bot.OnReady(func(ctx context.Context, event wumpkit.ReadyEvent) { slog.Info("Connected", "user", event.User.Username, "guilds", len(event.Guilds)) }) bot.OnMessageCreate(func(ctx context.Context, event wumpkit.MessageCreateEvent) { if event.Message.Author.Bot || event.Message.Content != "!ping" { return } latency := bot.ShardManager().AverageLatency() _, _ = bot.CreateMessage(ctx, event.Message.ChannelID, wumpkit.CreateMessageOptions{ Content: fmt.Sprintf("Pong! Heartbeat latency: %v", latency), }) }) if err := bot.StartGatewayWithSignals(); err != nil { slog.Error("bot stopped", "error", err) } }
For clustered bots sharing rate limits and cache across multiple nodes:
import ( "github.com/wumpkit/wumpkit" "github.com/wumpkit/wumpkit/extra/redis" goredis "github.com/redis/go-redis/v9" ) rdb := goredis.NewClient(&goredis.Options{Addr: "localhost:6379"}) bot := wumpkit.New( ctx, wumpkit.WithToken(token), wumpkit.WithCacheManager(redis.NewRedisCacheManager(rdb, wumpkit.CacheFlagsAll)), wumpkit.WithRateLimitStore(redis.NewRedisRateLimitStore(rdb)), )
Runnable examples are in the _examples directory:
pingpong- Basic ping pong botslash_commands- Application slash commandscomponents- Buttons and select menusjointocreate- Dynamic voice channel creatorsharded_bot- Multi-sharded bot setupredis_cache- Distributed Redis cache and rate limitingoauth2_server- Standalone OAuth2 web server
- Changelog - Release history and version notes following Keep a Changelog.
- Contributing Guide - Development workflow, code style, and PR guidelines.
- Security Policy - Vulnerability disclosure and reporting procedure.
- Code of Conduct - Contributor Covenant 2.1 standards.
- Support Guide - Getting help, reporting bugs, and asking questions.
BSD 3-Clause License. See LICENSE for details.