SteamWar/BungeeCore
Archiviert
13
2

discord-bot #230

Manuell gemergt
YoyoNow hat 38 Commits von discord-bot nach master 2021-07-28 23:59:27 +02:00 zusammengeführt
Nur Änderungen aus Commit 95ab4d3344 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -28,7 +28,9 @@ import net.dv8tion.jda.api.entities.Guild;
import net.dv8tion.jda.api.entities.Member;
import net.dv8tion.jda.api.entities.Role;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@UtilityClass
@ -43,18 +45,22 @@ public class DiscordRanks {
if (member == null) {
return;
}
Set<UserGroup> toRemove = new HashSet<>(SteamwarDiscordBotConfig.RANKS.keySet());
toRemove.remove(steamwarUser.getUserGroup());
for (UserGroup userGroup : toRemove) {
System.out.println(steamwarUser + " REMOVING");
String roleId = SteamwarDiscordBotConfig.RANKS.get(userGroup);
guild.removeRoleFromMember(member, guild.getRoleById(roleId)).complete();
List<Role> roleList = member.getRoles();
Set<String> strings = new HashSet<>(SteamwarDiscordBotConfig.RANKS.values());
String needed = SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup());
for (Role role : roleList) {
if (!strings.contains(role.getId())) {
continue;
}
if (role.getId().equals(needed)) {
needed = "";
continue;
}
guild.removeRoleFromMember(member, role).complete();
}
if (steamwarUser.getUserGroup() != UserGroup.Member) {
System.out.println(steamwarUser + " ADDING");
guild.addRoleToMember(member, guild.getRoleById(SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup()))).complete();
if (!needed.isEmpty()) {
guild.addRoleToMember(member, guild.getRoleById(needed)).complete();
}
}
}