Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zackartz/cmdlr2
Command handler for disgord. Based off of the excellent command handler dgc
https://github.com/zackartz/cmdlr2
Last synced: 8 days ago
JSON representation
Command handler for disgord. Based off of the excellent command handler dgc
- Host: GitHub
- URL: https://github.com/zackartz/cmdlr2
- Owner: zackartz
- License: mit
- Created: 2021-01-10T08:55:03.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-06T01:50:14.000Z (about 3 years ago)
- Last Synced: 2024-06-21T09:56:15.495Z (5 months ago)
- Language: Go
- Homepage:
- Size: 22.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cmdlr2
cmdlr2 is a command handler framework for the discord wrapper [disgord](https://github.com/andersfylling/disgord). It is heavily inspired (some files are the same) to a framework for discordgo called [dgc](https://github.com/lus/dgc/). I in no way claim to be the original creator of this, this is only a fork for disgord.
Example starter app:
```go
package mainimport (
"github.com/andersfylling/disgord"
"github.com/sirupsen/logrus"
"github.com/zackartz/cmdlr2"
"os"
)var log = &logrus.Logger{
Out: os.Stderr,
Formatter: new(logrus.TextFormatter),
Hooks: make(logrus.LevelHooks),
Level: logrus.DebugLevel,
}func main() {
// Set up a new Disgord client
client := disgord.New(disgord.Config{
BotToken: os.Getenv("DISCORD_TOKEN"),
Logger: log,
})
defer client.Gateway().StayConnectedUntilInterrupted()router := cmdlr2.Create(&cmdlr2.Router{
Prefixes: []string{"$"},
Client: client,
BotsAllowed: false,
IgnorePrefixCase: true,
})router.RegisterCMD(&cmdlr2.Command{
Name: "ping",
Description: "It pings.. and yknow.. pongs",
Usage: "ping",
Example: "ping",
Handler: func(ctx *cmdlr2.Ctx) {
ctx.ResponseText("pong")
},
})router.RegisterDefaultHelpCommand(client)
router.Initialize(client)
}
```In this case make sure to set the DISCORD_TOKEN environment variable to the value of your discord token.
### CONSIDER THIS BETA SOFTWARE
I have a bot that it is using this and it is working however, you may have problems with dgc's implementation of middleware.
Good luck.