diff options
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) + }) } |
