Installation
DiscordKit is distributed as a standard Go module.
Requirements
Section titled “Requirements”DiscordKit currently requires:
- Go 1.26 or newer;
- a Discord application and bot token;
- discordgo through the version pinned by DiscordKit.
You do not need to install discordgo separately when starting a new project. Go’s module system will resolve DiscordKit’s dependencies automatically.
Create a Go project
Section titled “Create a Go project”Create a directory for your application:
mkdir my-discord-botcd my-discord-botInitialize a Go module:
go mod init example.com/my-discord-botYou can replace example.com/my-discord-bot with the actual module path you
intend to use.
Install DiscordKit
Section titled “Install DiscordKit”Add DiscordKit to the project:
go get github.com/freitaseric/discordkitGo will add DiscordKit and its required dependencies to go.mod.
A new project will contain something similar to:
module example.com/my-discord-bot
go 1.26with DiscordKit listed among its dependencies after it is imported or resolved by the Go toolchain.
Verify the installation
Section titled “Verify the installation”Create main.go:
package main
import ( "fmt"
"github.com/freitaseric/discordkit")
func main() { router := discordkit.NewRouter()
fmt.Printf("%T\n", router)}Run the program:
go run .If the project compiles successfully, DiscordKit is ready to use.
Using DiscordKit with an existing discordgo project
Section titled “Using DiscordKit with an existing discordgo project”DiscordKit does not create or replace your discordgo.Session.
Existing applications can adopt it incrementally.
For example:
session, err := discordgo.New("Bot " + token)if err != nil { return err}
router := discordkit.NewRouter()
session.AddHandler(router.Handle)Your existing discordgo handlers and DiscordKit handlers can coexist while you migrate application functionality gradually.
Development versions
Section titled “Development versions”Before DiscordKit reaches a stable v1 API, new releases may contain breaking
changes.
For applications that require reproducible builds, commit your go.mod and
go.sum files and use an explicit DiscordKit version when appropriate:
go get github.com/freitaseric/discordkit@VERSIONNext step
Section titled “Next step”Now build a complete connection to Discord in Your first bot.