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