https://github.com/fedorlap2006/disgolf
Make Discord bots on Go with ease
https://github.com/fedorlap2006/disgolf
discord framework golang
Last synced: 9 months ago
JSON representation
Make Discord bots on Go with ease
- Host: GitHub
- URL: https://github.com/fedorlap2006/disgolf
- Owner: FedorLap2006
- License: gpl-3.0
- Created: 2021-03-30T18:32:48.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-12-18T22:57:15.000Z (over 2 years ago)
- Last Synced: 2025-04-04T06:01:31.130Z (12 months ago)
- Topics: discord, framework, golang
- Language: Go
- Homepage:
- Size: 141 KB
- Stars: 28
- Watchers: 3
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Make Discord bots on Go with ease
## About
Disgolf is lightweight Go framework for building bots on Discord.
It does all complicated things for you, keeping your code clean and helps you focus on important stuff.
## Installation
To install the library you must have at least Go of version 1.15 and use `master` version of DiscordGo, otherwise you will end up with a lot of errors.
And that's not good.
```bash
$ go get -u github.com/FedorLap2006/disgolf
```
## Usage
> For complicated usage examples you can visit our [examples](https://github.com/FedorLap2006/disgolf/tree/master/examples) directory.
```go
package main
import (
"os"
"signal"
"syscall"
"time"
"github.com/FedorLap2006/disgolf"
"github.com/bwmarrin/discordgo"
)
func main() {
bot, err := disgolf.New("BOT-TOKEN")
if err != nil {
panic(err)
}
bot.Router.Register(&disgolf.Command{
Name: "hello_world",
Description: "Say hi to the world!",
Handler: disgolf.CommandHandlerFunc(func(ctx *disgolf.Ctx) error {
ctx.Respond(&discordgo.InteractionResponse {
Type: discordgo.InteractionResponseChannelMessageWithSource,
Data: &discordgo.InteractionResponseData{
Content: "Hello world!",
},
})
})
})
err := bot.Router.Sync(bot.Session, "", "GUILD-TEST-ID")
if err != nil {
panic(err)
}
err := bot.Open()
if err != nil {
panic(err)
}
defer bot.Close()
stchan := make(chan os.Signal, 1)
signal.Notify(stchan, syscall.SIGTERM, os.Interrupt, syscall.SIGSEGV)
end:
for {
select {
case <-stchan:
break end
default:
}
time.Sleep(time.Second)
}
}
```