announce the winner

This commit is contained in:
skeletable 2022-10-28 15:02:25 +02:00
parent e3f3f75a10
commit 1184994799
1 changed files with 9 additions and 4 deletions

13
main.go
View File

@ -28,6 +28,7 @@ var (
)
var url_regexp, _ = regexp.Compile(`https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)`)
var event = false
// The list of games is currently a hardcoded slice of slices. The first element of
// a game slice should be the default ("display") name of the game, second one is a short name, the other ones are aliases.
@ -667,9 +668,13 @@ func checkGame(s string) (bool, string, string) {
// message is created on any channel that the authenticated bot has access to.
func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
// Ignore all messages created by the bot itself
// This isn't required in this specific example but it's a good practice.
if time.Now().Month().String() == "October" {
event = true
} else if event == true {
haul, winner := topUserCandy()
s.ChannelMessageSend("947540183077748820", "<@" + winner + "> has won the candy hunt! Candy claimed: " + fmt.Sprint(haul))
event = false
}
var claimed bool
var tickrate time.Duration
const maxtickrate = 5000 * time.Millisecond
@ -785,7 +790,7 @@ func messageCreate(s *discordgo.Session, m *discordgo.MessageCreate) {
return
}
if m.ChannelID == "946459086554275883" && time.Now().Before(time.Unix(1667260799, 0)) {
if m.ChannelID == "946459086554275883" && event {
rand.Seed(time.Now().Unix())
if rand.Intn(100) < 3 {
time.Sleep(1 * time.Second)