modules: Check for errors and report them

master
Luther Wen Xu 2019-12-13 18:14:32 +07:00
parent 801f9f8d6f
commit eb23870513
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
2 changed files with 14 additions and 4 deletions

@ -46,8 +46,14 @@ func ScheduleUpdates(s *discordgo.Session) {
return return
} }
if newLevel > oldLevel { if newLevel > oldLevel {
gacha.RollReward(s, checkID, newLevel-oldLevel) err = gacha.RollReward(s, checkID, newLevel-oldLevel)
roles.GiveLevelRoles(s, checkID, oldLevel, newLevel) if err != nil {
log.Error(s, err)
}
err = roles.GiveLevelRoles(s, checkID, oldLevel, newLevel)
if err != nil {
log.Error(s, err)
}
} }
}(id, level) }(id, level)
} }

@ -7,10 +7,14 @@ import (
"PermissionGacha/modules/log" "PermissionGacha/modules/log"
) )
func GiveLevelRoles(s *discordgo.Session, discordID string, oldLevel, newLevel int) { func GiveLevelRoles(s *discordgo.Session, discordID string, oldLevel, newLevel int) error {
for i := oldLevel + 1; i <= newLevel; i++ { for i := oldLevel + 1; i <= newLevel; i++ {
s.GuildMemberRoleAdd(config.GuildID, discordID, config.LevelRoles[i-1]) err := s.GuildMemberRoleAdd(config.GuildID, discordID, config.LevelRoles[i-1])
if err != nil {
return err
}
} }
return nil
} }
func RemoveAllLevelRoles(s *discordgo.Session, discordID string) { func RemoveAllLevelRoles(s *discordgo.Session, discordID string) {