2022-07-26 14:28:02 +00:00
|
|
|
package command
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
"github.com/bwmarrin/discordgo"
|
|
|
|
log "github.com/sirupsen/logrus"
|
|
|
|
)
|
|
|
|
|
2022-07-28 04:43:08 +00:00
|
|
|
type (
|
2022-08-04 04:52:08 +00:00
|
|
|
PingHandler struct {
|
|
|
|
config Config
|
|
|
|
}
|
2022-07-28 04:43:08 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
func NewPingHandler() *PingHandler {
|
|
|
|
return new(PingHandler)
|
|
|
|
}
|
|
|
|
|
2022-08-04 04:52:08 +00:00
|
|
|
func (h *PingHandler) SetConfig(config Config) {
|
|
|
|
h.config = config
|
|
|
|
}
|
|
|
|
|
2022-07-28 04:43:08 +00:00
|
|
|
func (h *PingHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
2022-07-26 14:28:02 +00:00
|
|
|
if m.Author.ID == s.State.User.ID {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
if !strings.HasPrefix(m.Content, "!ping") {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Debug("received ping")
|
|
|
|
|
|
|
|
s.ChannelMessageSend(m.ChannelID, "pong")
|
|
|
|
}
|