diff options
| author | William Hergès <anhgelus.morhtuuzh@proton.me> | 2024-04-16 15:46:52 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-04-16 15:46:52 +0200 |
| commit | 6b595b8b11e9ac05302ee15ab7734e49b89594e5 (patch) | |
| tree | 1bcea973dbec09ca70f0c20eaa41c29ded00d62f /main.go | |
| parent | ff711c918d196e60c60ad598f70d4efb89795a95 (diff) | |
| parent | b4e72dcae10265bbc1595f2e520b1407cf8e250d (diff) | |
Merge pull request #1 from anhgelus/feat/xp-reducer
[Feat] Add XP reducer
Diffstat (limited to 'main.go')
| -rw-r--r-- | main.go | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -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) + }) } |
