Fix parts[] for everyone

This commit is contained in:
2021-05-06 08:48:51 -04:00
parent 4d8e33058a
commit 70672fd5fd
2 changed files with 5 additions and 7 deletions

View File

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

View File

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