A simple message command library for DiscordGo, inspired by discord.py.
- Command aliases
- Argument converters: convert a string input into output of any type
- Command checks (for permissions etc)
- Command usage generation
- Easy to implement in an existing DiscordGo project
It is assumed that you have Go 1.17 installed.
go get github.com/quakecodes/recv
A full scale project can be found in the _example
folder, including examples for checks and converters
router := recv.NewCommandRouter()
router.AddCommand(recv.Command{
Name: "Ping",
Description: "Sends \"pong\"",
Callback: func(c *recv.CommandCtx) {
c.Session.ChannelMessageSend(c.Message.ChannelID, "pong")
},
})
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
res, err := router.ProcessCommands(".", s, m)
if err != nil {
fmt.Println(err)
return
} else if res.Command == nil {
s.ChannelMessageSend(m.ChannelID, "command not found")
}
go res.Callback()
}