Async (TM)
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
f0e7f52fd6
Commit
a0ac0a0be2
@ -48,11 +48,7 @@ public class AuthManager {
|
|||||||
|
|
||||||
TOKENS.put(code, member.getIdLong());
|
TOKENS.put(code, member.getIdLong());
|
||||||
BungeeCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
BungeeCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
|
||||||
ScheduledTask[] task = new ScheduledTask[1];
|
BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
|
||||||
task[0] = BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> {
|
|
||||||
TOKENS.remove(code);
|
|
||||||
task[0].cancel();
|
|
||||||
}, 10, 10, TimeUnit.MINUTES);
|
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,10 +62,10 @@ public class AuthManager {
|
|||||||
builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht")));
|
builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht")));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
member.getUser().openPrivateChannel().complete().sendMessage(builder.build()).complete();
|
member.getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(builder.build()).queue());
|
||||||
if (member.getNickname() == null) {
|
if (member.getNickname() == null) {
|
||||||
try {
|
try {
|
||||||
member.getGuild().modifyNickname(member, user.getUserName()).complete();
|
member.getGuild().modifyNickname(member, user.getUserName()).queue();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// Ignored
|
// Ignored
|
||||||
}
|
}
|
||||||
|
@ -78,6 +78,7 @@ public class SteamwarDiscordBot {
|
|||||||
} catch (LoginException e) {
|
} catch (LoginException e) {
|
||||||
throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e);
|
throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e);
|
||||||
}
|
}
|
||||||
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
|
||||||
try {
|
try {
|
||||||
jda.awaitReady();
|
jda.awaitReady();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
@ -106,7 +107,7 @@ public class SteamwarDiscordBot {
|
|||||||
jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());
|
jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());
|
||||||
|
|
||||||
Guild guild = jda.getGuildById(SteamwarDiscordBotConfig.GUILD);
|
Guild guild = jda.getGuildById(SteamwarDiscordBotConfig.GUILD);
|
||||||
guild.retrieveCommands().complete().forEach(command -> guild.deleteCommandById(command.getId()).queue());
|
guild.retrieveCommands().queue(commands -> commands.forEach(command -> guild.deleteCommandById(command.getId()).queue()));
|
||||||
CommandListUpdateAction commands = jda.getGuildById(SteamwarDiscordBotConfig.GUILD).updateCommands();
|
CommandListUpdateAction commands = jda.getGuildById(SteamwarDiscordBotConfig.GUILD).updateCommands();
|
||||||
addCommand(commands, new MuteCommand());
|
addCommand(commands, new MuteCommand());
|
||||||
addCommand(commands, new BanCommand());
|
addCommand(commands, new BanCommand());
|
||||||
@ -115,6 +116,7 @@ public class SteamwarDiscordBot {
|
|||||||
addCommand(commands, new ListCommand());
|
addCommand(commands, new ListCommand());
|
||||||
addCommand(commands, new UnbanCommand());
|
addCommand(commands, new UnbanCommand());
|
||||||
commands.queue();
|
commands.queue();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) {
|
private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) {
|
||||||
|
@ -45,13 +45,13 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Timestamp time = de.steamwar.bungeecore.commands.BanCommand.parseTime(null, event.getOption("time").getAsString());
|
Timestamp time = de.steamwar.bungeecore.commands.BanCommand.parseTime(null, event.getOption("time").getAsString());
|
||||||
if (time == null) {
|
if (time == null) {
|
||||||
event.reply("Angegebene Zeit invalide").setEphemeral(true).complete();
|
event.reply("Angegebene Zeit invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,6 +60,6 @@ public class BanCommand extends BasicDiscordCommand {
|
|||||||
|
|
||||||
target.ban(time, msg, sender.getId(), isPerma);
|
target.ban(time, msg, sender.getId(), isPerma);
|
||||||
Message.team("BAN_TEAM_BANNED", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
Message.team("BAN_TEAM_BANNED", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
||||||
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).complete();
|
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,7 @@ public abstract class BasicDiscordCommand extends CommandData {
|
|||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
||||||
if (steamwarUser == null || (!steamwarUser.getUserGroup().isTeamGroup() && steamwarUser.getUserGroup() != UserGroup.Builder)) {
|
if (steamwarUser == null || (!steamwarUser.getUserGroup().isTeamGroup() && steamwarUser.getUserGroup() != UserGroup.Builder)) {
|
||||||
event.reply("Du hast für " + event.getName() + " keine Rechte oder es existiert keine Verknüpfung für dich.").setEphemeral(true).complete();
|
event.reply("Du hast für " + event.getName() + " keine Rechte oder es existiert keine Verknüpfung für dich.").setEphemeral(true).queue();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -38,6 +38,6 @@ public class ListCommand extends BasicDiscordCommand {
|
|||||||
de.steamwar.bungeecore.commands.ListCommand.getPlayerMap().forEach((s, proxiedPlayers) -> {
|
de.steamwar.bungeecore.commands.ListCommand.getPlayerMap().forEach((s, proxiedPlayers) -> {
|
||||||
embedBuilder.addField(s, proxiedPlayers.stream().map(player -> "`" + player.getName() + "`").collect(Collectors.joining(", ")), true);
|
embedBuilder.addField(s, proxiedPlayers.stream().map(player -> "`" + player.getName() + "`").collect(Collectors.joining(", ")), true);
|
||||||
});
|
});
|
||||||
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete();
|
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -61,6 +61,6 @@ public class MuteCommand extends BasicDiscordCommand {
|
|||||||
|
|
||||||
target.mute(time, msg, sender.getId(), isPerma);
|
target.mute(time, msg, sender.getId(), isPerma);
|
||||||
Message.team("MUTE_TEAM_MUTED", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
Message.team("MUTE_TEAM_MUTED", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
|
||||||
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gemutet").setEphemeral(true).complete();
|
event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gemutet").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,11 +58,11 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
Team team;
|
Team team;
|
||||||
if (optionMapping == null) {
|
if (optionMapping == null) {
|
||||||
if (steamwarUser == null) {
|
if (steamwarUser == null) {
|
||||||
event.reply("Dein Discord ist nicht verknüpft").setEphemeral(true).complete();
|
event.reply("Dein Discord ist nicht verknüpft").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (steamwarUser.getTeam() == 0) {
|
if (steamwarUser.getTeam() == 0) {
|
||||||
event.reply("Du bist in keinem Team").setEphemeral(true).complete();
|
event.reply("Du bist in keinem Team").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
team = Team.get(steamwarUser.getTeam());
|
team = Team.get(steamwarUser.getTeam());
|
||||||
@ -70,7 +70,7 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
team = Team.get(optionMapping.getAsString());
|
team = Team.get(optionMapping.getAsString());
|
||||||
}
|
}
|
||||||
if (team == null) {
|
if (team == null) {
|
||||||
event.reply("Unbekanntes Team").setEphemeral(true).complete();
|
event.reply("Unbekanntes Team").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||||
@ -81,10 +81,10 @@ public class TeamCommand extends BasicDiscordCommand {
|
|||||||
embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
|
embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
|
||||||
embedBuilder.addField("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
|
embedBuilder.addField("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
|
||||||
embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false);
|
embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false);
|
||||||
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete();
|
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
default:
|
default:
|
||||||
event.reply("Unbekannter Befehl").setEphemeral(true).complete();
|
event.reply("Unbekannter Befehl").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@
|
|||||||
|
|
||||||
package de.steamwar.bungeecore.bot.commands;
|
package de.steamwar.bungeecore.bot.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
|
||||||
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
import net.dv8tion.jda.api.interactions.commands.OptionType;
|
||||||
@ -44,16 +43,16 @@ public class UnbanCommand extends BasicDiscordCommand {
|
|||||||
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
|
||||||
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
SteamwarUser target = SteamwarUser.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
event.reply("Angegebener User invalide").setEphemeral(true).complete();
|
event.reply("Angegebener User invalide").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!target.isBanned()) {
|
if (!target.isBanned()) {
|
||||||
event.reply("Angegebener User ist nicht gebannt").setEphemeral(true).complete();
|
event.reply("Angegebener User ist nicht gebannt").setEphemeral(true).queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
target.ban(Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
|
target.ban(Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
|
||||||
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).complete();
|
event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -89,6 +89,6 @@ public class WhoisCommand extends BasicDiscordCommand {
|
|||||||
embedBuilder.addField(punishment.getType().name() + " von " + SteamwarUser.get(punishment.getPunisher()).getUserName(), "Von: " + punishment.getBantime(punishment.getStartTime(), false) + "\nBis: " + punishment.getBantime(punishment.getEndTime(), punishment.isPerma()) + "\nGrund: " + punishment.getReason(), true);
|
embedBuilder.addField(punishment.getType().name() + " von " + SteamwarUser.get(punishment.getPunisher()).getUserName(), "Von: " + punishment.getBantime(punishment.getStartTime(), false) + "\nBis: " + punishment.getBantime(punishment.getEndTime(), punishment.isPerma()) + "\nGrund: " + punishment.getReason(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).complete();
|
event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class EventManager {
|
|||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageBuilder messageBuilder = new MessageBuilder();
|
||||||
messageBuilder.setEmbeds(embedBuilder.build());
|
messageBuilder.setEmbeds(embedBuilder.build());
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
message = textChannel.sendMessage(messageBuilder.build()).complete();
|
textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1);
|
||||||
} else {
|
} else {
|
||||||
message.editMessage(messageBuilder.build()).complete();
|
message.editMessage(messageBuilder.build()).complete();
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,7 @@ public class SchematicsManager {
|
|||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageBuilder messageBuilder = new MessageBuilder();
|
||||||
messageBuilder.setEmbeds(embedBuilder.build());
|
messageBuilder.setEmbeds(embedBuilder.build());
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
message = textChannel.sendMessage(messageBuilder.build()).complete();
|
textChannel.sendMessage(messageBuilder.build()).queue(message1 -> message = message1);
|
||||||
} else {
|
} else {
|
||||||
message.editMessage(messageBuilder.build()).queue();
|
message.editMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,6 @@ public class AnnouncementListener extends BasicDiscordListener {
|
|||||||
assert textChannel != null;
|
assert textChannel != null;
|
||||||
MessageBuilder messageBuilder = new MessageBuilder();
|
MessageBuilder messageBuilder = new MessageBuilder();
|
||||||
messageBuilder.append(message.replace("&", ""));
|
messageBuilder.append(message.replace("&", ""));
|
||||||
textChannel.sendMessage(messageBuilder.build()).complete();
|
textChannel.sendMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,23 +35,23 @@ public class DiscordAuthListener extends BasicDiscordListener {
|
|||||||
if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.RULES_CHANNEL) && event.getComponentId().equals("auth")) {
|
if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.RULES_CHANNEL) && event.getComponentId().equals("auth")) {
|
||||||
String authMessage = AuthManager.createDiscordAuthToken(event.getMember());
|
String authMessage = AuthManager.createDiscordAuthToken(event.getMember());
|
||||||
if(authMessage != null) {
|
if(authMessage != null) {
|
||||||
event.reply("Gebe innerhalb der nächsten 10 Minuten ``/verify " + authMessage + "`` auf dem Minecraft Server ein").setEphemeral(true).complete();
|
event.reply("Gebe innerhalb der nächsten 10 Minuten ``/verify " + authMessage + "`` auf dem Minecraft Server ein").setEphemeral(true).queue();
|
||||||
} else {
|
} else {
|
||||||
event.reply("Du hast bereits einen Code am laufen").setEphemeral(true).complete();
|
event.reply("Du hast bereits einen Code am laufen").setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.getComponentId().equals("tada") && event.getChannelType() == ChannelType.PRIVATE) {
|
if(event.getComponentId().equals("tada") && event.getChannelType() == ChannelType.PRIVATE) {
|
||||||
event.reply(":tada:").setEphemeral(false).complete();
|
event.reply(":tada:").setEphemeral(false).queue();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(event.getComponentId().equals("invalid") && event.getChannelType() == ChannelType.PRIVATE) {
|
if(event.getComponentId().equals("invalid") && event.getChannelType() == ChannelType.PRIVATE) {
|
||||||
SteamwarUser user = SteamwarUser.get(event.getUser().getIdLong());
|
SteamwarUser user = SteamwarUser.get(event.getUser().getIdLong());
|
||||||
if(user == null) {
|
if(user == null) {
|
||||||
event.reply(":question: Da ist keine verknüpfung?").setEphemeral(false).complete();
|
event.reply(":question: Da ist keine verknüpfung?").setEphemeral(false).queue();
|
||||||
} else {
|
} else {
|
||||||
user.setDiscordId(null);
|
user.setDiscordId(null);
|
||||||
event.reply(":x: Die Verknüpfung wurde beendet").setEphemeral(false).complete();
|
event.reply(":x: Die Verknüpfung wurde beendet").setEphemeral(false).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.SpecialPermissions;
|
||||||
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
import de.steamwar.bungeecore.bot.config.DiscordTicketType;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
@ -114,7 +115,7 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
|||||||
logChannel.sendMessage(builder.build()).complete();
|
logChannel.sendMessage(builder.build()).complete();
|
||||||
|
|
||||||
Message.team("DISCORD_TICKET_CLOSED", event.getTextChannel().getName());
|
Message.team("DISCORD_TICKET_CLOSED", event.getTextChannel().getName());
|
||||||
event.getTextChannel().delete().reason("Closed").complete();
|
event.getTextChannel().delete().reason("Closed").queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,16 +127,15 @@ public class DiscordTicketListener extends BasicDiscordListener {
|
|||||||
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
BungeeCore.get().getProxy().getPlayers().forEach(player -> {
|
||||||
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
|
||||||
SteamwarUser user = SteamwarUser.get(player);
|
SteamwarUser user = SteamwarUser.get(player);
|
||||||
|
boolean sendMessage;
|
||||||
if(user.getDiscordId() == null) {
|
if(user.getDiscordId() == null) {
|
||||||
if(user.getUserGroup().isTeamGroup()) {
|
sendMessage = user.getUserGroup().isCheckSchematics();
|
||||||
Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if(event.getAuthor().getId().equals(user.getDiscordId())) return;
|
if(event.getAuthor().getId().equals(user.getDiscordId())) return;
|
||||||
Member member = event.getGuild().retrieveMemberById(user.getDiscordId()).complete();
|
sendMessage = user.getDiscordId().equals(event.getChannel().getTopic()) || user.getUserGroup().isCheckSchematics();
|
||||||
if(member.hasPermission(event.getChannel().getManager().getChannel(), Permission.MESSAGE_WRITE)) {
|
|
||||||
Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
|
|
||||||
}
|
}
|
||||||
|
if(sendMessage) {
|
||||||
|
Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -43,15 +43,15 @@ public class IngameChatListener extends BasicDiscordListener {
|
|||||||
Member member = event.getMember();
|
Member member = event.getMember();
|
||||||
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
|
||||||
if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250) {
|
if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250) {
|
||||||
event.getMessage().delete().complete();
|
event.getMessage().delete().queue();
|
||||||
} else {
|
} else {
|
||||||
String s = event.getMessage().getContentDisplay();
|
String s = event.getMessage().getContentDisplay();
|
||||||
if (steamwarUser.getUserGroup() == UserGroup.Member && (s.contains("http") || s.contains("www"))) {
|
if (steamwarUser.getUserGroup() == UserGroup.Member && (s.contains("http") || s.contains("www"))) {
|
||||||
event.getMessage().delete().complete();
|
event.getMessage().delete().queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (steamwarUser.isMuted() || steamwarUser.isBanned()) {
|
if (steamwarUser.isMuted() || steamwarUser.isBanned()) {
|
||||||
event.getMessage().delete().complete();
|
event.getMessage().delete().queue();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ChatListener.discordChat(steamwarUser, event.getMessage().getContentDisplay().replaceAll("§[a-f0-9]", "").replace('\n', ' '));
|
ChatListener.discordChat(steamwarUser, event.getMessage().getContentDisplay().replaceAll("§[a-f0-9]", "").replace('\n', ' '));
|
||||||
|
@ -32,10 +32,10 @@ public class RolesInteractionButtonListener extends BasicDiscordListener {
|
|||||||
if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.ROLES_CHANNEL) && SteamwarDiscordBotConfig.ROLES.stream().anyMatch(discordRole -> discordRole.getRoleId().equals(event.getComponentId()))) {
|
if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.ROLES_CHANNEL) && SteamwarDiscordBotConfig.ROLES.stream().anyMatch(discordRole -> discordRole.getRoleId().equals(event.getComponentId()))) {
|
||||||
if (event.getMember().getRoles().stream().anyMatch(role -> role.getId().equals(event.getComponentId()))) {
|
if (event.getMember().getRoles().stream().anyMatch(role -> role.getId().equals(event.getComponentId()))) {
|
||||||
event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
|
event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
|
||||||
event.reply(SteamwarDiscordBotConfig.ROLES_REMOVED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).complete();
|
event.reply(SteamwarDiscordBotConfig.ROLES_REMOVED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).queue();
|
||||||
} else {
|
} else {
|
||||||
event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
|
event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
|
||||||
event.reply(SteamwarDiscordBotConfig.ROLES_ADDED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).complete();
|
event.reply(SteamwarDiscordBotConfig.ROLES_ADDED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,7 +22,6 @@ package de.steamwar.bungeecore.bot.listeners;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.commands.ServerTeamchatCommand;
|
import de.steamwar.bungeecore.commands.ServerTeamchatCommand;
|
||||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.dv8tion.jda.api.MessageBuilder;
|
import net.dv8tion.jda.api.MessageBuilder;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
import net.dv8tion.jda.api.entities.Member;
|
||||||
|
@ -22,13 +22,11 @@ package de.steamwar.bungeecore.bot.util;
|
|||||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import de.steamwar.bungeecore.sql.UserGroup;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
import net.dv8tion.jda.api.entities.Guild;
|
import net.dv8tion.jda.api.entities.Guild;
|
||||||
import net.dv8tion.jda.api.entities.Member;
|
|
||||||
import net.dv8tion.jda.api.entities.Role;
|
import net.dv8tion.jda.api.entities.Role;
|
||||||
|
import net.dv8tion.jda.api.exceptions.ErrorResponseException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -41,11 +39,7 @@ public class DiscordRanks {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Guild guild = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD);
|
Guild guild = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD);
|
||||||
Member member = guild.retrieveMemberById(steamwarUser.getDiscordId()).complete();
|
guild.retrieveMemberById(steamwarUser.getDiscordId()).queue(member -> {
|
||||||
if (member == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Role> roleList = member.getRoles();
|
List<Role> roleList = member.getRoles();
|
||||||
Set<String> strings = new HashSet<>(SteamwarDiscordBotConfig.RANKS.values());
|
Set<String> strings = new HashSet<>(SteamwarDiscordBotConfig.RANKS.values());
|
||||||
String needed = SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup());
|
String needed = SteamwarDiscordBotConfig.RANKS.get(steamwarUser.getUserGroup());
|
||||||
@ -63,5 +57,13 @@ public class DiscordRanks {
|
|||||||
if (needed != null && !needed.isEmpty()) {
|
if (needed != null && !needed.isEmpty()) {
|
||||||
guild.addRoleToMember(member, guild.getRoleById(needed)).complete();
|
guild.addRoleToMember(member, guild.getRoleById(needed)).complete();
|
||||||
}
|
}
|
||||||
|
}, throwable -> {
|
||||||
|
if(throwable instanceof ErrorResponseException) {
|
||||||
|
ErrorResponseException e = (ErrorResponseException) throwable;
|
||||||
|
if(e.getErrorCode() == 10007) {
|
||||||
|
steamwarUser.setDiscordId(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,9 +60,9 @@ public class DiscordRulesMessage {
|
|||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(ActionRow.of(buttons), ActionRow.of(authButton));
|
messageBuilder.setActionRows(ActionRow.of(buttons), ActionRow.of(authButton));
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.editMessage(messageBuilder.build()).complete();
|
message.editMessage(messageBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
channel.sendMessage(messageBuilder.build()).complete();
|
channel.sendMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,9 @@ public class DiscordTicketMessage {
|
|||||||
messageBuilder.setEmbeds(builder.build());
|
messageBuilder.setEmbeds(builder.build());
|
||||||
messageBuilder.setActionRows(ActionRow.of(buttons));
|
messageBuilder.setActionRows(ActionRow.of(buttons));
|
||||||
if (message != null) {
|
if (message != null) {
|
||||||
message.editMessage(messageBuilder.build()).complete();
|
message.editMessage(messageBuilder.build()).queue();
|
||||||
} else {
|
} else {
|
||||||
channel.sendMessage(messageBuilder.build()).complete();
|
channel.sendMessage(messageBuilder.build()).queue();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren