make all handlers a struct
This commit is contained in:
parent
826ac3292f
commit
d0ddca7fe1
@ -94,11 +94,11 @@ func main() {
|
||||
log.Fatalf("error creating Discord session: %v\n", err)
|
||||
}
|
||||
|
||||
dg.AddHandler(command.PingHandler)
|
||||
dg.AddHandler(command.NewPingHandler().Handle)
|
||||
dg.AddHandler(reactionHandler)
|
||||
dg.AddHandler(praiseHandler)
|
||||
dg.AddHandler(command.RollHandler)
|
||||
dg.AddHandler(command.RouletteHandler)
|
||||
dg.AddHandler(command.NewRollHandler().Handle)
|
||||
dg.AddHandler(command.NewRouletteHandler().Handle)
|
||||
|
||||
h := command.NewWeatherHandler(C.Handler.Weather)
|
||||
dg.AddHandler(h.Handle)
|
||||
|
@ -8,7 +8,15 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func PingHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
type (
|
||||
PingHandler struct{}
|
||||
)
|
||||
|
||||
func NewPingHandler() *PingHandler {
|
||||
return new(PingHandler)
|
||||
}
|
||||
|
||||
func (h *PingHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
@ -34,7 +34,9 @@ type (
|
||||
N int
|
||||
}
|
||||
|
||||
CoinHandler struct{}
|
||||
CoinHandler struct{}
|
||||
RollHandler struct{}
|
||||
RouletteHandler struct{}
|
||||
)
|
||||
|
||||
var (
|
||||
@ -140,7 +142,11 @@ func (g *Gun) IsEmpty() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func RollHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
func NewRollHandler() *RollHandler {
|
||||
return new(RollHandler)
|
||||
}
|
||||
|
||||
func (h *RollHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
var (
|
||||
err error
|
||||
msg, roll string
|
||||
@ -178,7 +184,11 @@ func RollHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
s.ChannelMessageSend(m.ChannelID, msg)
|
||||
}
|
||||
|
||||
func RouletteHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
func NewRouletteHandler() *RouletteHandler {
|
||||
return new(RouletteHandler)
|
||||
}
|
||||
|
||||
func (h *RouletteHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
if m.Author.ID == s.State.User.ID {
|
||||
return
|
||||
}
|
||||
|
@ -14,8 +14,7 @@ type (
|
||||
)
|
||||
|
||||
func NewTimeHandler() *TimeHandler {
|
||||
var h *TimeHandler = new(TimeHandler)
|
||||
return h
|
||||
return new(TimeHandler)
|
||||
}
|
||||
|
||||
func (h *TimeHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||
|
Loading…
Reference in New Issue
Block a user