geforkt von SteamWar/BungeeCore
Fix DiscordRanks
Dieser Commit ist enthalten in:
Ursprung
aeaed0db99
Commit
95ab4d3344
@ -28,7 +28,9 @@ import net.dv8tion.jda.api.entities.Guild;
|
|||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
@ -43,18 +45,22 @@ public class DiscordRanks {
|
|||||||
if (member == null) {
|
if (member == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Set<UserGroup> toRemove = new HashSet<>(SteamwarDiscordBotConfig.RANKS.keySet());
|
|
||||||
toRemove.remove(steamwarUser.getUserGroup());
|
|
||||||
|
|
||||||
for (UserGroup userGroup : toRemove) {
|
List<Role> roleList = member.getRoles();
|
||||||
System.out.println(steamwarUser + " REMOVING");
|
Set<String> strings = new HashSet<>(SteamwarDiscordBotConfig.RANKS.values());
|
||||||
String roleId = SteamwarDiscordBotConfig.RANKS.get(userGroup);
|
String needed = SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup());
|
||||||
guild.removeRoleFromMember(member, guild.getRoleById(roleId)).complete();
|
for (Role role : roleList) {
|
||||||
|
if (!strings.contains(role.getId())) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
if (role.getId().equals(needed)) {
|
||||||
if (steamwarUser.getUserGroup() != UserGroup.Member) {
|
needed = "";
|
||||||
System.out.println(steamwarUser + " ADDING");
|
continue;
|
||||||
guild.addRoleToMember(member, guild.getRoleById(SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup()))).complete();
|
}
|
||||||
|
guild.removeRoleFromMember(member, role).complete();
|
||||||
|
}
|
||||||
|
if (!needed.isEmpty()) {
|
||||||
|
guild.addRoleToMember(member, guild.getRoleById(needed)).complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren