prestige: Remove all level roles on prestige

master
Luther Wen Xu 2019-11-19 15:11:32 +07:00
parent 11cc377789
commit f165fa1516
Signed by: chanbakjsd
GPG Key ID: B7D77E3E9D102B70
2 changed files with 17 additions and 0 deletions

@ -110,6 +110,7 @@ func checkPrestigeReact(s *discordgo.Session, m *discordgo.MessageReactionAdd) {
}
xp := getXP(s, m.UserID)
newPrestigeLevel := xp/130000 + 1
go cleanUpRole(s, m.UserID)
setPrestige(s, m.UserID, newPrestigeLevel)
s.ChannelMessageSend(m.ChannelID, "**PRESTIGE > ** <@%s>, you have prestiged!")
}

@ -62,3 +62,19 @@ func getPrestige(dg *discordgo.Session, discordID string) int {
prestigeCache[discordID] = 1
return 1
}
func cleanUpRole(s *discordgo.Session, discordID string) {
member, err := s.GuildMember(guildID, discordID)
if err != nil {
logError(s, "cleanUpRole", "guildMember", discordID)
return
}
for _, v := range member.Roles {
for _, w := range rolesFromLevel {
if v == w {
s.GuildMemberRoleRemove(guildID, discordID, v)
break
}
}
}
}