Browse Source

Listen for successful bumps

master
Gregory Rudolph 3 years ago
parent
commit
cf494d4c11
  1. 35
      discordMessage.go

35
discordMessage.go

@ -12,16 +12,31 @@ import (
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) { func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
defer log.PanicSafe() 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") { if m.Author.ID == "302050872383242240" && len(m.Embeds) > 0 {
log.LogDebug("Failed bump detected") if strings.Contains(m.Embeds[0].Description, "minutes until the server can be bumped") {
re := regexp.MustCompile("Please wait another (.*) minutes until the server can be bumped") log.LogDebug("Failed bump detected")
match := re.FindStringSubmatch(m.Embeds[0].Description) re := regexp.MustCompile("Please wait another (.*) minutes until the server can be bumped")
m.Content = fmt.Sprintf("%+v bs %+v", s.State.User.Mention(), match[1]) match := re.FindStringSubmatch(m.Embeds[0].Description)
BumpSet(BotCommand{ m.Content = fmt.Sprintf("%+v bs %+v", s.State.User.Mention(), match[1])
Message: m, BumpSet(BotCommand{
Session: s, Message: m,
Parts: strings.Split(m.Content, " ")[2:], 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 { if m.Author.Bot || m.Author.ID == s.State.User.ID {
return return

Loading…
Cancel
Save