added middleware
This commit is contained in:
parent
9f1d13d3aa
commit
ebbbc3680d
@ -64,8 +64,6 @@ func main() {
|
||||
|
||||
mux := NewCommandMux()
|
||||
mux.prefix = "!newpepe"
|
||||
mux.HandleFunc("newcringe", newCringe)
|
||||
mux.HandleFunc(mux.prefix, newSendPepe)
|
||||
|
||||
app := &application{
|
||||
infoLog: infoLog,
|
||||
@ -82,6 +80,9 @@ func main() {
|
||||
app.errorLog.Fatal(err)
|
||||
}
|
||||
|
||||
mux.Handle("newcringe", app.LogToConsole(HandlerFunc(newCringe)))
|
||||
mux.HandleFunc(mux.prefix, app.sendPepe)
|
||||
|
||||
/* token, err := app.readAuthToken()
|
||||
if err != nil {
|
||||
app.errorLog.Fatal(err)
|
||||
|
11
discord/middleware.go
Normal file
11
discord/middleware.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import "github.com/bwmarrin/discordgo"
|
||||
|
||||
func (app *application) LogToConsole(next Command) Command {
|
||||
fn := func(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
app.infoLog.Printf("%s \tsaid: %s\n", m.Author.Username, m.Content)
|
||||
next.Execute(s, m)
|
||||
}
|
||||
return HandlerFunc(fn)
|
||||
}
|
Loading…
Reference in New Issue
Block a user