geforkt von SteamWar/BungeeCore
Add DiscordRanks
Dieser Commit ist enthalten in:
Ursprung
f3a448a68e
Commit
398b3e9b5a
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.bot.config;
|
||||
|
||||
import de.steamwar.bungeecore.sql.UserGroup;
|
||||
import net.md_5.bungee.config.Configuration;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -47,7 +48,7 @@ public class SteamwarDiscordBotConfig {
|
||||
public static String TICKET_CREATED;
|
||||
public static String TICKET_LOG;
|
||||
public static Map<String, DiscordTicketType> TICKET_TYPES;
|
||||
public static Map<String, String> RANKS;
|
||||
public static Map<UserGroup, String> RANKS;
|
||||
|
||||
public static void loadConfig(Configuration config) {
|
||||
TOKEN = config.getString("token");
|
||||
@ -101,7 +102,7 @@ public class SteamwarDiscordBotConfig {
|
||||
RANKS = new HashMap<>();
|
||||
Configuration ranksSections = config.getSection("ranks");
|
||||
for (String type : ranksSections.getKeys()) {
|
||||
RANKS.put(type, ranksSections.getString(type));
|
||||
RANKS.put(UserGroup.getUsergroup(type), ranksSections.getString(type));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,16 +43,18 @@ public class DiscordRanks {
|
||||
if (member == null) {
|
||||
return;
|
||||
}
|
||||
Set<String> toRemove = new HashSet<>(SteamwarDiscordBotConfig.RANKS.keySet());
|
||||
if (steamwarUser.getUserGroup() != UserGroup.Member) {
|
||||
toRemove.remove(steamwarUser.getUserGroup().name().toLowerCase());
|
||||
}
|
||||
for (String s : toRemove) {
|
||||
String roleId = SteamwarDiscordBotConfig.RANKS.get(s);
|
||||
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();
|
||||
}
|
||||
|
||||
if (steamwarUser.getUserGroup() != UserGroup.Member) {
|
||||
guild.addRoleToMember(member, guild.getRoleById(SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup().name())));
|
||||
System.out.println(steamwarUser + " ADDING");
|
||||
guild.addRoleToMember(member, guild.getRoleById(SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren