From 1ca743ac1bc03de2f908b0cda92052e090149d04 Mon Sep 17 00:00:00 2001 From: Dusty Pianalto Date: Sun, 19 Apr 2020 17:23:05 -0800 Subject: [PATCH] Add error handler and error channel Update dependencies --- djpianalto.com/goff/goff.go | 11 ++++++++- go.mod | 3 +-- go.sum | 47 ++----------------------------------- 3 files changed, 13 insertions(+), 48 deletions(-) diff --git a/djpianalto.com/goff/goff.go b/djpianalto.com/goff/goff.go index 9635680..6c85ac4 100644 --- a/djpianalto.com/goff/goff.go +++ b/djpianalto.com/goff/goff.go @@ -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) + } +} diff --git a/go.mod b/go.mod index 9b61c49..74e37d4 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,8 @@ module djpianalto.com/goff go 1.14 require ( - github.com/MikeModder/anpan v0.0.0-20190831213521-34b01a6cec0a github.com/bwmarrin/discordgo v0.20.2 - github.com/dustinpianalto/disgoman v0.0.0-20200407073246-017a13d2f100 + github.com/dustinpianalto/disgoman v0.0.0-20200420005144-c3143ea66130 github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 github.com/lib/pq v1.3.0 ) diff --git a/go.sum b/go.sum index d8d66f3..24903be 100644 --- a/go.sum +++ b/go.sum @@ -1,52 +1,9 @@ -github.com/MikeModder/anpan v0.0.0-20190831213521-34b01a6cec0a h1:feAROD9GIkzJHoZNC/p4r29GzomMNu6cJ0qKxs85L/I= -github.com/MikeModder/anpan v0.0.0-20190831213521-34b01a6cec0a/go.mod h1:jTKPbf4E9vER2V891owE1fkKAjK3kSNGxZCTTQ4z9Qw= -github.com/bwmarrin/discordgo v0.19.0/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= github.com/bwmarrin/discordgo v0.20.2 h1:nA7jiTtqUA9lT93WL2jPjUp8ZTEInRujBdx1C9gkr20= github.com/bwmarrin/discordgo v0.20.2/go.mod h1:O9S4p+ofTFwB02em7jkpkV8M3R0/PUVOwN61zSZ0r4Q= -github.com/dustinpianalto/disgoman v0.0.0-20200406015308-c28f5942098e h1:Cud22nvHaHIIbxFJB30SJU40TRmRUz+lnyQTPlwYuEY= -github.com/dustinpianalto/disgoman v0.0.0-20200406015308-c28f5942098e/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200406030359-7057f2019b27 h1:YZQZTn6nZ/Wx9aSITYp5Q+U4B/bWd3yoAcoXIEpYXwc= -github.com/dustinpianalto/disgoman v0.0.0-20200406030359-7057f2019b27/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200406032705-2668bb8cf59a h1:ze1sxGaOGtgN38ZBo9QN6ofblhcQ6IwKkalZfLmOoRw= -github.com/dustinpianalto/disgoman v0.0.0-20200406032705-2668bb8cf59a/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200406033206-5160db811495 h1:jDaoNl1IOgbJqdiEKLyUyZ43ltvHJVcA2FKA6AotKOo= -github.com/dustinpianalto/disgoman v0.0.0-20200406033206-5160db811495/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407055106-ecbe2e958fae h1:QLZN50c1NZRlTb6/anzsbE0EQmKyw6lC/Yst3ULnHRg= -github.com/dustinpianalto/disgoman v0.0.0-20200407055106-ecbe2e958fae/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407055401-5bb2c4a0ba95 h1:39jJNE+n5tcqf+22NgpGPrwALStT32p/C3LGT47ABqE= -github.com/dustinpianalto/disgoman v0.0.0-20200407055401-5bb2c4a0ba95/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407055648-0f8e3058d525 h1:qEaVihOa38TRnNJNOnlPr2H6pppu1pxocFEguia1wiY= -github.com/dustinpianalto/disgoman v0.0.0-20200407055648-0f8e3058d525/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407060739-ad28895b43d2 h1:cMOXryJnVe503twxiAyaYGEP4N17Y12aJt51va/KdZY= -github.com/dustinpianalto/disgoman v0.0.0-20200407060739-ad28895b43d2/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407060953-d7da539153b4 h1:sXlPb9fP5H6ID41n81Lx3YruAkvRrw7a7/Wo5yGVGSk= -github.com/dustinpianalto/disgoman v0.0.0-20200407060953-d7da539153b4/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407064546-2ee91528e807 h1:XRD/g7evUVpYwzD1BvfWUTCMPeSOpP1vK+DRPWXBbL0= -github.com/dustinpianalto/disgoman v0.0.0-20200407064546-2ee91528e807/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407064911-9febf5ddd547 h1:u89NoPsVMYUpoMdlmQi0hfAHine/BySTIrjd6T1sWtU= -github.com/dustinpianalto/disgoman v0.0.0-20200407064911-9febf5ddd547/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407065137-0e81c7e6a1b1 h1:qwfuMmgHSq7COUTH/zY1E9qB/WCKFXq4H9o83qdLIZY= -github.com/dustinpianalto/disgoman v0.0.0-20200407065137-0e81c7e6a1b1/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407065639-48f8ee997f8e h1:DsW5nPC7KZBn1OeWbGN4b4Mhjfq1otpFCs+AlnLcnOw= -github.com/dustinpianalto/disgoman v0.0.0-20200407065639-48f8ee997f8e/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407065901-ca3fe5bd6961 h1:elaeIybXmc4chT26RkP3lXwlBV4yEvzLUjbnecb1+Ks= -github.com/dustinpianalto/disgoman v0.0.0-20200407065901-ca3fe5bd6961/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407070232-0f51576a3509 h1:iajsyEA4RN5rQkyA7dMb/tjAuDfOE8pQWvL7BlWOogs= -github.com/dustinpianalto/disgoman v0.0.0-20200407070232-0f51576a3509/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407070618-70034903f0b4 h1:XI1CCq5CCydSgYCdbIgrm+EGxBOs/TiqgTWBBTwqcoA= -github.com/dustinpianalto/disgoman v0.0.0-20200407070618-70034903f0b4/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407070839-97678e757cbb h1:36S9x0MED3OQ0aWA7+XQ6yZAc+7XNWCDgGKKdevgyzI= -github.com/dustinpianalto/disgoman v0.0.0-20200407070839-97678e757cbb/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407071612-ebd0d77d3229 h1:FWt+RrclGz3NOO02N6UmjkDGh6FLD6kXIPk+naBOask= -github.com/dustinpianalto/disgoman v0.0.0-20200407071612-ebd0d77d3229/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407071848-54e2a741c063 h1:IElz2z+bL0At5IERllxEay7LMHKTBt74VrnweG4iCts= -github.com/dustinpianalto/disgoman v0.0.0-20200407071848-54e2a741c063/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407072206-a0a6b9b54d7e h1:vmNnRwhpB4vbjDGVcZwn9Tac+tvjDZYbwWNmHB3Jcmw= -github.com/dustinpianalto/disgoman v0.0.0-20200407072206-a0a6b9b54d7e/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= -github.com/dustinpianalto/disgoman v0.0.0-20200407072955-f98b62e6fb49 h1:KLZCNt6d4RY3y83YeEHc89KE96+Zhi02qkiZpM2WbOY= -github.com/dustinpianalto/disgoman v0.0.0-20200407072955-f98b62e6fb49/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= github.com/dustinpianalto/disgoman v0.0.0-20200407073246-017a13d2f100 h1:yKyt6EakVkopZRdOYXa5AOQVRl2QgRRDaTPZerpgoCI= github.com/dustinpianalto/disgoman v0.0.0-20200407073246-017a13d2f100/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= +github.com/dustinpianalto/disgoman v0.0.0-20200420005144-c3143ea66130 h1:J967RgBA9J1nBJrNdVxpYeRNYAoA2h5XOc0ndD6zhQQ= +github.com/dustinpianalto/disgoman v0.0.0-20200420005144-c3143ea66130/go.mod h1:v3FM6n+4dH9XlvO+IDx6MN3DUnGq6YVDBvy1A1k202g= github.com/gorilla/websocket v1.4.0 h1:WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 h1:Z9n2FFNUXsshfwJMBgNA0RU6/i7WVaAegv3PtuIHPMs=