Add error handler and error channel

Update dependencies
This commit is contained in:
Dusty Pianalto
2020-04-19 17:23:05 -08:00
parent a4fda79677
commit 1ca743ac1b
3 changed files with 13 additions and 48 deletions
+10 -1
View File
@@ -50,7 +50,7 @@ func main() {
Prefixes: getPrefixes,
Owners: owners,
StatusManager: disgoman.GetDefaultStatusManager(),
OnErrorFunc: nil,
ErrorChannel: make(chan disgoman.CommandError, 10),
Commands: make(map[string]*disgoman.Command),
IgnoreBots: true,
CheckPermissions: false,
@@ -59,6 +59,9 @@ func main() {
// Add Command Handlers
exts.AddCommandHandlers(&handler)
// Start the Error handler in a goroutine
go ErrorHandler(handler.ErrorChannel)
//if _, ok := handler.Commands["help"]; !ok {
// handler.AddDefaultHelpCommand()
//}
@@ -87,3 +90,9 @@ func main() {
func getPrefixes(guild_id string) []string {
return []string{"Go.", "go."}
}
func ErrorHandler(ErrorChan chan disgoman.CommandError) {
for ce := range ErrorChan {
_, _ = ce.Context.Send(ce.Message)
}
}