diff --git a/discordMessage.go b/discordMessage.go index a91b116..9f03dc6 100644 --- a/discordMessage.go +++ b/discordMessage.go @@ -10,19 +10,6 @@ import ( func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { defer log.PanicSafe() - var b BotCommand - if strings.Contains(m.Content, s.State.User.ID) { - b = BotCommand{ - Session: s, - Message: m, - Parts: strings.Split(m.Content, " ")[1:], - } - } else { - log.LogDebug("strings.Contains(m.Content, s.State.User.ID) was false for %+v", m.Content) - if bump { - s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v please say \"!d bump\" without the quotes to bump our server :)", m.Author.Mention())) - } - } if m.Author.ID == s.State.User.ID || m.Author.Bot { return } @@ -36,25 +23,12 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { } return } - if isAdmin(m.Member) { - adminInteraction(s, m.Author.ID) - } - if m.ChannelID != config.AdminChannel { - lastActiveChan = m.ChannelID - lastActiveTime = time.Now() - } - if strings.HasPrefix(m.Content, "!d bump") { - if time.Since(config.BumpTime) < 2*time.Hour { - s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Sorry, <@%+v> already claimed the bump. Better luck next time!", config.LastBumper)) - return - } - config.LastBumper = m.Author.ID - go bumpTimer(s) - return - } - if strings.Contains(m.Content, s.State.User.ID) { - log.LogDebug("%+v contained %+v", m.Content, s.State.User.ID) + b := BotCommand{ + Session: s, + Message: m, + Parts: strings.Split(m.Content, " ")[1:], + } for _, cmd := range commands { for _, keyword := range cmd.Keywords { log.LogDebug("Checking if %+v contains %+v", m.Content, keyword) @@ -83,6 +57,27 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { } } } + } else { + log.LogDebug("strings.Contains(m.Content, s.State.User.ID) was false for %+v", m.Content) + if bump { + s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("%+v please say \"!d bump\" without the quotes to bump our server :)", m.Author.Mention())) + } + } + if isAdmin(m.Member) { + adminInteraction(s, m.Author.ID) + } + if m.ChannelID != config.AdminChannel { + lastActiveChan = m.ChannelID + lastActiveTime = time.Now() + } + if strings.HasPrefix(m.Content, "!d bump") { + if time.Since(config.BumpTime) < 2*time.Hour { + s.ChannelMessageSend(m.ChannelID, fmt.Sprintf("Sorry, <@%+v> already claimed the bump. Better luck next time!", config.LastBumper)) + return + } + config.LastBumper = m.Author.ID + go bumpTimer(s) + return } }