aboutsummaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorWilliam Hergès <anhgelus.morhtuuzh@proton.me>2024-04-16 15:46:52 +0200
committerGitHub <noreply@github.com>2024-04-16 15:46:52 +0200
commit6b595b8b11e9ac05302ee15ab7734e49b89594e5 (patch)
tree1bcea973dbec09ca70f0c20eaa41c29ded00d62f /main.go
parentff711c918d196e60c60ad598f70d4efb89795a95 (diff)
parentb4e72dcae10265bbc1595f2e520b1407cf8e250d (diff)
Merge pull request #1 from anhgelus/feat/xp-reducer
[Feat] Add XP reducer
Diffstat (limited to 'main.go')
-rw-r--r--main.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/main.go b/main.go
index ed84b8a..d8cdbc2 100644
--- a/main.go
+++ b/main.go
@@ -3,10 +3,12 @@ package main
import (
"flag"
"github.com/anhgelus/gokord"
+ "github.com/anhgelus/gokord/utils"
"github.com/anhgelus/les-copaings-bot/commands"
"github.com/anhgelus/les-copaings-bot/config"
"github.com/anhgelus/les-copaings-bot/xp"
"github.com/bwmarrin/discordgo"
+ "time"
)
var token string
@@ -120,7 +122,18 @@ func main() {
}
func afterInit(dg *discordgo.Session) {
+ // handlers
dg.AddHandler(xp.OnMessage)
dg.AddHandler(xp.OnVoiceUpdate)
dg.AddHandler(xp.OnLeave)
+
+ // setup timer for periodic reducer
+ d := 24 * time.Hour
+ if gokord.Debug {
+ // reduce time for debug
+ d = time.Minute
+ }
+ utils.NewTimer(d, func(stop chan struct{}) {
+ xp.PeriodicReducer(dg)
+ })
}