aboutsummaryrefslogtreecommitdiff
path: root/xp/level.go
diff options
context:
space:
mode:
Diffstat (limited to 'xp/level.go')
-rw-r--r--xp/level.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/xp/level.go b/xp/level.go
index 328a287..e577920 100644
--- a/xp/level.go
+++ b/xp/level.go
@@ -165,7 +165,10 @@ func XPUpdate(s *discordgo.Session, c *Copaing) {
func PeriodicReducer(s *discordgo.Session) {
var wg sync.WaitGroup
for _, g := range s.State.Guilds {
- for _, m := range utils.FetchGuildUser(s, g.ID) {
+ for i, m := range utils.FetchGuildUser(s, g.ID) {
+ if i%50 == 49 {
+ time.Sleep(15 * time.Second) // sleep prevents from spamming the Discord API and the database
+ }
if m.User.Bot {
continue
}
@@ -178,7 +181,7 @@ func PeriodicReducer(s *discordgo.Session) {
}
wg.Wait() // finish the entire guild before starting another
utils.SendDebug("Periodic reduce, guild finished", "guild", g.Name)
- time.Sleep(10 * time.Second) // sleep prevents from spamming the Discord API and the database
+ time.Sleep(15 * time.Second) // sleep prevents from spamming the Discord API and the database
}
utils.SendDebug("Periodic reduce finished", "len(guilds)", len(s.State.Guilds))
}