Merge branch 'main' into refactor/config-command
This commit is contained in:
commit
bbfaaaf04b
5 changed files with 30 additions and 40 deletions
|
@ -1,14 +1,15 @@
|
|||
package user
|
||||
|
||||
import (
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/anhgelus/gokord"
|
||||
"github.com/anhgelus/gokord/logger"
|
||||
"github.com/anhgelus/les-copaings-bot/config"
|
||||
"github.com/anhgelus/les-copaings-bot/exp"
|
||||
"github.com/bwmarrin/discordgo"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func onNewLevel(dg *discordgo.Session, m *discordgo.Member, level uint) {
|
||||
|
@ -86,14 +87,14 @@ func PeriodicReducer(dg *discordgo.Session) {
|
|||
go func() {
|
||||
defer wg.Done()
|
||||
cfg := config.GetGuildConfig(g.ID)
|
||||
err := gokord.DB.
|
||||
res := gokord.DB.
|
||||
Model(&CopaingXP{}).
|
||||
Where("guild_id = ? and created_at < ?", g.ID, exp.TimeStampNDaysBefore(cfg.DaysXPRemains)).
|
||||
Delete(&CopaingXP{}).
|
||||
Error
|
||||
if err != nil {
|
||||
logger.Alert("user/level.go - Removing old XP", err.Error(), "guild_id", g.ID)
|
||||
Delete(&CopaingXP{})
|
||||
if res.Error != nil {
|
||||
logger.Alert("user/level.go - Removing old XP", res.Error.Error(), "guild_id", g.ID)
|
||||
}
|
||||
logger.Debug("Guild cleaned", "guild", g.Name, "rows affected", res.RowsAffected)
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue