remove more slash commands
This commit is contained in:
parent
348cd543fc
commit
b1824f8d33
@ -37,6 +37,7 @@ type (
|
|||||||
|
|
||||||
HandlerConfig struct {
|
HandlerConfig struct {
|
||||||
Reaction ReactionConfig `mapstructure:"reaction"`
|
Reaction ReactionConfig `mapstructure:"reaction"`
|
||||||
|
Weather command.WeatherConfig `mapstructure:"weather"`
|
||||||
}
|
}
|
||||||
|
|
||||||
ReactionConfig struct {
|
ReactionConfig struct {
|
||||||
@ -99,6 +100,12 @@ func main() {
|
|||||||
dg.AddHandler(command.RollHandler)
|
dg.AddHandler(command.RollHandler)
|
||||||
dg.AddHandler(command.RouletteHandler)
|
dg.AddHandler(command.RouletteHandler)
|
||||||
|
|
||||||
|
h := command.NewWeatherHandler(C.Handler.Weather)
|
||||||
|
dg.AddHandler(h.Handle)
|
||||||
|
|
||||||
|
dg.AddHandler(command.NewCoinHandler().Handle)
|
||||||
|
dg.AddHandler(command.NewTimeHandler().Handle)
|
||||||
|
|
||||||
dg.Identify.Intents = discordgo.IntentsGuildMessages
|
dg.Identify.Intents = discordgo.IntentsGuildMessages
|
||||||
|
|
||||||
err = dg.Open()
|
err = dg.Open()
|
||||||
|
@ -8,24 +8,6 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
func PoopCommand(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "💩",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func PingCommand(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: "Pong",
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func PingHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
func PingHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
if m.Author.ID == s.State.User.ID {
|
if m.Author.ID == s.State.User.ID {
|
||||||
return
|
return
|
||||||
|
@ -28,10 +28,14 @@ type (
|
|||||||
S string
|
S string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Coin bool
|
||||||
|
|
||||||
Gun struct {
|
Gun struct {
|
||||||
C [6]bool
|
C [6]bool
|
||||||
N int
|
N int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoinHandler struct{}
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -94,6 +98,11 @@ func (r *Roll) RollDice() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *Coin) Flip() bool {
|
||||||
|
*c = Coin(Itob(RandInt(0, 1)))
|
||||||
|
return bool(*c)
|
||||||
|
}
|
||||||
|
|
||||||
func NewGun() *Gun {
|
func NewGun() *Gun {
|
||||||
return new(Gun)
|
return new(Gun)
|
||||||
}
|
}
|
||||||
@ -192,64 +201,31 @@ func RouletteHandler(s *discordgo.Session, m *discordgo.MessageCreate) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func RollCommand(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
func NewCoinHandler() *CoinHandler {
|
||||||
|
return new(CoinHandler)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (h *CoinHandler) Handle(s *discordgo.Session, m *discordgo.MessageCreate) {
|
||||||
var (
|
var (
|
||||||
err error
|
c Coin
|
||||||
msg string
|
msg string
|
||||||
r *Roll
|
|
||||||
)
|
)
|
||||||
|
|
||||||
options := i.ApplicationCommandData().Options
|
if m.Author.ID == s.State.User.ID {
|
||||||
|
|
||||||
roll := options[0].StringValue()
|
|
||||||
|
|
||||||
r, err = ParseRoll(roll)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: err.Error(),
|
|
||||||
},
|
|
||||||
})
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
r.RollDice()
|
if !strings.HasPrefix(m.Content, "!coin") {
|
||||||
log.Debugf("rolled dice: %+v", r)
|
return
|
||||||
|
|
||||||
if msg == "" {
|
|
||||||
msg = fmt.Sprintf("🎲 %s = %d", JoinInt(r.Rolls, " + "), r.Sum)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
if c.Flip() {
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: msg,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func CoinCommand(s *discordgo.Session, i *discordgo.InteractionCreate) {
|
|
||||||
var (
|
|
||||||
r int
|
|
||||||
msg string
|
|
||||||
)
|
|
||||||
|
|
||||||
r = RandInt(1, 2)
|
|
||||||
|
|
||||||
if r == 1 {
|
|
||||||
msg = "heads"
|
msg = "heads"
|
||||||
} else {
|
} else {
|
||||||
msg = "tails"
|
msg = "tails"
|
||||||
}
|
}
|
||||||
|
|
||||||
s.InteractionRespond(i.Interaction, &discordgo.InteractionResponse{
|
s.ChannelMessageSend(m.ChannelID, msg)
|
||||||
Type: discordgo.InteractionResponseChannelMessageWithSource,
|
|
||||||
Data: &discordgo.InteractionResponseData{
|
|
||||||
Content: msg,
|
|
||||||
},
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func RandInt(min int, max int) int {
|
func RandInt(min int, max int) int {
|
||||||
@ -275,3 +251,11 @@ func SumInt(a []int) int {
|
|||||||
}
|
}
|
||||||
return sum
|
return sum
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func Itob(v int) bool {
|
||||||
|
if v == 1 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user