diff --git a/discord/main.go b/discord/main.go index 247451d..3bd6b4f 100644 --- a/discord/main.go +++ b/discord/main.go @@ -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) diff --git a/discord/middleware.go b/discord/middleware.go new file mode 100644 index 0000000..6a9ef6d --- /dev/null +++ b/discord/middleware.go @@ -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) +}