Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fedorlap2006/disgolf
Make Discord bots on Go with ease
https://github.com/fedorlap2006/disgolf
discord framework golang
Last synced: 10 days 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 (over 3 years ago)
- Default Branch: master
- Last Pushed: 2023-12-18T22:57:15.000Z (11 months ago)
- Last Synced: 2024-10-14T17:41:00.347Z (24 days ago)
- Topics: discord, framework, golang
- Language: Go
- Homepage:
- Size: 141 KB
- Stars: 29
- Watchers: 4
- Forks: 5
- Open Issues: 1
-
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 mainimport (
"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)
}
}```