Browse Source

Fix parts[] for everyone

master
Gregory Rudolph 3 years ago
parent
commit
70672fd5fd
Signed by: rudi
GPG Key ID: EF64F3CBD1A1EBDD
  1. 10
      commands.go
  2. 2
      discordMessage.go

10
commands.go

@ -102,7 +102,7 @@ func Commands(b BotCommand) bool { @@ -102,7 +102,7 @@ func Commands(b BotCommand) bool {
func Debug(b BotCommand) bool {
defer log.PanicSafe()
level, err := strconv.Atoi(b.Parts[2])
level, err := strconv.Atoi(b.Parts[0])
if err != nil {
return false
}
@ -123,10 +123,9 @@ func Reboot(b BotCommand) bool { @@ -123,10 +123,9 @@ func Reboot(b BotCommand) bool {
func BumpSet(b BotCommand) bool {
defer log.PanicSafe()
bump = false
parts := strings.Split(b.Message.Content, " ")
timer, err := strconv.Atoi(parts[2])
timer, err := strconv.Atoi(b.Parts[0])
if err != nil {
b.Session.ChannelMessageSend(b.Message.ChannelID, fmt.Sprintf("Unable to decode timer: %+v", parts[2]))
b.Session.ChannelMessageSend(b.Message.ChannelID, fmt.Sprintf("Unable to decode timer: %+v", b.Parts[0]))
return false
}
config.BumpTime = time.Now().Add(time.Duration(timer) * time.Minute).Add(-2 * time.Hour)
@ -138,8 +137,7 @@ func RetrieveVerification(b BotCommand) bool { @@ -138,8 +137,7 @@ func RetrieveVerification(b BotCommand) bool {
defer log.PanicSafe()
s := b.Session
m := b.Message
parts := strings.Split(m.Content, " ")
discordId := parts[1]
discordId := b.Parts[0]
_, err := strconv.Atoi(discordId)
if err != nil {
discordId = idFromUsername(discordId)

2
discordMessage.go

@ -43,7 +43,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { @@ -43,7 +43,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
b := BotCommand{
Session: s,
Message: m,
Parts: strings.Split(m.Content, " ")[1:],
Parts: strings.Split(m.Content, " ")[2:],
}
log.LogDebug("%+v", b.Parts)
for _, cmd := range commands {

Loading…
Cancel
Save