modules/level: Make sure variable is not changed in another thread

master
Luther Wen Xu 2019-11-29 22:32:17 +07:00
parent 2fc1e22e23
commit 1bdf798cb9
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
1 changed files with 6 additions and 6 deletions

@ -39,17 +39,17 @@ func ScheduleUpdates(s *discordgo.Session) {
} }
if lastKnownLevel[id] != level { if lastKnownLevel[id] != level {
lastKnownLevel[id] = level lastKnownLevel[id] = level
go func() { go func(checkID string, newLevel int) {
oldLevel, err := roles.GetOldLevel(s, id) oldLevel, err := roles.GetOldLevel(s, checkID)
if err != nil { if err != nil {
log.Error(s, err) log.Error(s, err)
return return
} }
if level > oldLevel { if newLevel > oldLevel {
gacha.RollReward(s, id, level-oldLevel) gacha.RollReward(s, checkID, newLevel-oldLevel)
roles.GiveLevelRoles(s, id, oldLevel, level) roles.GiveLevelRoles(s, checkID, oldLevel, newLevel)
} }
}() }(id, level)
} }
} }
levelMutex.Unlock() levelMutex.Unlock()