DisGo
DisGo is a Discord API wrapper written in GoLang aimed to be consistent, modular, customizable and higher level than other Discord API wrappers.
Summary
- Stability
- Features
- Missing Features
- Getting Started
- Documentation
- Examples
- Other interesting Projects to look at
- Other GoLang Discord Libraries
- Troubleshooting
- Contributing
- License
Stability
The public API of DisGo is mostly stable at this point in time. Smaller breaking changes can happen before the v1 is released.
After v1 is released breaking changes may only happen if the Discord API requires them. They tend to break their released API versions now and then. In general for every new Discord APi version the major version of DisGo should be increased and with that breaking changes between non major versions should be helt to a minimum.
Features
Missing Features
Getting Started
Installing
go get github.com/disgoorg/disgo
Building a DisGo Instance
Build a bot client to interact with the discord api
package main
import (
"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/disgo/gateway"
)
func main() {
client, err := disgo.New("token",
// set gateway options
bot.WithGatewayConfigOpts(
// set enabled intents
gateway.WithGatewayIntents(
discord.GatewayIntentGuilds,
discord.GatewayIntentGuildMessages,
discord.GatewayIntentDirectMessages,
),
),
// add event listeners
bot.WithEventListenerFunc(func(e *events.MessageCreateEvent) {
// event code here
}),
)
}
Full Ping Pong Example
This example can also be found [here]https://github.com/disgoorg/disgo/blob/development/_examples/ping_pong/example.go()
package main
import (
"context"
"os"
"os/signal"
"syscall"
"github.com/disgoorg/disgo"
"github.com/disgoorg/disgo/bot"
"github.com/disgoorg/disgo/cache"
"github.com/disgoorg/disgo/discord"
"github.com/disgoorg/disgo/events"
"github.com/disgoorg/disgo/gateway"
"github.com/disgoorg/log"
)
func main() {
client, err := disgo.New(os.Getenv("token"),
bot.WithGatewayConfigOpts(
gateway.WithGatewayIntents(
discord.GatewayIntentGuildMessages,
discord.GatewayIntentMessageContent,
),
),
bot.WithEventListenerFunc(onMessageCreate),
)
if err != nil {
log.Fatal("error while building disgo: ", err)
}
defer client.Close(context.TODO())
if err = client.ConnectGateway(context.TODO()); err != nil {
log.Fatal("errors while connecting to gateway: ", err)
}
log.Info("example is now running. Press CTRL-C to exit.")
s := make(chan os.Signal, 1)
signal.Notify(s, syscall.SIGINT, syscall.SIGTERM, os.Interrupt)
<-s
}
func onMessageCreate(event *events.MessageCreateEvent) {
var message string
if event.Message.Content == "ping" {
message = "pong"
} else if event.Message.Content == "pong" {
message = "ping"
}
if message != "" {
_, _ = event.Client().Rest().CreateMessage(event.ChannelID, discord.NewMessageCreateBuilder().SetContent(message).Build())
}
}
Logging
DisGo uses our own small logging interface which you can use with most other logging libaries. This lib also comes with a default logger which is based on the standard log package.
Documentation
Documentation is wip and can be found under
GitHub Wiki is currently under construction. We appreciate help here.
Examples
You can find examples here
There is also a bot template with commands & db here
or in these projects:
Other interesting Projects to look at
Is a standalone audio sending node based on Lavaplayer and JDA-Audio. Which allows for sending audio without it ever reaching any of your shards. Lavalink can be used in combinatio with DisGolink for music Bots
Being used in production by FredBoat, Dyno, LewdBot, and more.
Is a Lavalink-Client which can be used to communicate with LavaLink to play/search tracks
Is a Discord webhook logger hook for logrus
Other GoLang Discord Libraries
Troubleshooting
For help feel free to open an issues or reach out on Discord
Contributing
Contributions are welcomed but for bigger changes we recommend first reaching out via Discord or create an issue to discuss your problems, intentions and ideas.
License
Distributed under the
. See LICENSE for more information.