Added !source command

This commit is contained in:
Ryan Cavicchioni 2022-08-05 10:04:04 -05:00
parent 2674645475
commit b852b02aed
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 38 additions and 0 deletions

View File

@ -33,6 +33,7 @@ var (
command.NewPingHandler(), command.NewPingHandler(),
command.NewRollHandler(), command.NewRollHandler(),
command.NewRouletteHandler(), command.NewRouletteHandler(),
command.NewSourceHandler(),
command.NewTimeHandler(), command.NewTimeHandler(),
command.NewWeatherHandler(), command.NewWeatherHandler(),
} }

37
command/source.go Normal file
View File

@ -0,0 +1,37 @@
package command
import (
"strings"
"github.com/bwmarrin/discordgo"
)
const (
SourceURI = "https://git.kill0.net/chill9/bb"
)
type (
SourceHandler struct {
config Config
}
)
func NewSourceHandler() *SourceHandler {
return new(SourceHandler)
}
func (h *SourceHandler) SetConfig(config Config) {
h.config = config
}
func (h *SourceHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
if m.Author.ID == s.State.User.ID {
return
}
if !strings.HasPrefix(m.Content, "!source") {
return
}
s.ChannelMessageSend(m.ChannelID, SourceURI)
}