From cf494d4c11b7f404be8156d030d975eef5f88a3b Mon Sep 17 00:00:00 2001 From: = Date: Wed, 24 Nov 2021 13:05:27 -0500 Subject: [PATCH] Listen for successful bumps --- discordMessage.go | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/discordMessage.go b/discordMessage.go index 3c06a20..664bd2a 100644 --- a/discordMessage.go +++ b/discordMessage.go @@ -12,16 +12,31 @@ import ( func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { defer log.PanicSafe() - if m.Author.ID == "302050872383242240" && len(m.Embeds) > 0 && strings.Contains(m.Embeds[0].Description, "minutes until the server can be bumped") { - log.LogDebug("Failed bump detected") - re := regexp.MustCompile("Please wait another (.*) minutes until the server can be bumped") - match := re.FindStringSubmatch(m.Embeds[0].Description) - m.Content = fmt.Sprintf("%+v bs %+v", s.State.User.Mention(), match[1]) - BumpSet(BotCommand{ - Message: m, - Session: s, - Parts: strings.Split(m.Content, " ")[2:], - }) + if m.Author.ID == "302050872383242240" && len(m.Embeds) > 0 { + if strings.Contains(m.Embeds[0].Description, "minutes until the server can be bumped") { + log.LogDebug("Failed bump detected") + re := regexp.MustCompile("Please wait another (.*) minutes until the server can be bumped") + match := re.FindStringSubmatch(m.Embeds[0].Description) + m.Content = fmt.Sprintf("%+v bs %+v", s.State.User.Mention(), match[1]) + BumpSet(BotCommand{ + Message: m, + Session: s, + Parts: strings.Split(m.Content, " ")[2:], + }) + + } + if strings.Contains(m.Embeds[0].Description, "Bump done!") { + log.LogDebug("Finding string %+v", m.Embeds[0].Description) + 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 + } + activeInteraction(s, m.Author.ID) + config.LastBumper = m.Author.ID + //go bumpTimer(s) + } + return + } if m.Author.Bot || m.Author.ID == s.State.User.ID { return