Browse Source

Fix parts[] for everyone

master
Gregory Rudolph 4 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 {
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)

2
discordMessage.go

@ -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 {

Loading…
Cancel
Save