Skip to content

Installation


DiscordKit is distributed as a standard Go module.

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 directory for your application:

Terminal window
mkdir my-discord-bot
cd my-discord-bot

Initialize a Go module:

Terminal window
go mod init example.com/my-discord-bot

You can replace example.com/my-discord-bot with the actual module path you intend to use.

Add DiscordKit to the project:

Terminal window
go get github.com/freitaseric/discordkit

Go 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.26

with DiscordKit listed among its dependencies after it is imported or resolved by the Go toolchain.

Create main.go:

package main
import (
"fmt"
"github.com/freitaseric/discordkit"
)
func main() {
router := discordkit.NewRouter()
fmt.Printf("%T\n", router)
}

Run the program:

Terminal window
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.

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:

Terminal window
go get github.com/freitaseric/discordkit@VERSION

Now build a complete connection to Discord in Your first bot.