SteamWar/BungeeCore
Archiviert
13
2

Fix discord targets
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2022-04-22 10:36:28 +02:00
Ursprung 4665d42fc7
Commit 02fd7eb965
2 geänderte Dateien mit 11 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -29,6 +29,7 @@ import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
import de.steamwar.bungeecore.bot.util.DiscordRulesMessage;
import de.steamwar.bungeecore.bot.util.DiscordTicketMessage;
import de.steamwar.bungeecore.sql.Event;
import de.steamwar.messages.ChatSender;
import lombok.Getter;
import net.dv8tion.jda.api.JDA;
import net.dv8tion.jda.api.JDABuilder;
@ -111,8 +112,8 @@ public class SteamwarDiscordBot {
new DiscordEventListener();
new PrivateMessageListener();
announcementListener = new AnnouncementListener();
ingameChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.INGAME_CHANNEL, "CHAT_DISCORD_GLOBAL");
serverTeamChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.SERVER_TEAM_CHANNEL, "CHAT_SERVERTEAM");
ingameChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.INGAME_CHANNEL, "CHAT_DISCORD_GLOBAL", ChatSender::globalReceivers);
serverTeamChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.SERVER_TEAM_CHANNEL, "CHAT_SERVERTEAM", ChatSender::serverteamReceivers);
new SlashCommandListener();
jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());

Datei anzeigen

@ -31,14 +31,20 @@ import net.dv8tion.jda.api.entities.TextChannel;
import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier;
import java.util.stream.Stream;
public class DiscordChatListener extends BasicDiscordListener {
private final String channel;
private final String format;
public DiscordChatListener(String channel, String format) {
private final Supplier<Stream<ChatSender>> targets;
public DiscordChatListener(String channel, String format, Supplier<Stream<ChatSender>> targets) {
this.channel = channel;
this.format = format;
this.targets = targets;
}
@Override
@ -51,7 +57,7 @@ public class DiscordChatListener extends BasicDiscordListener {
if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250 || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
event.getMessage().delete().queue();
} else {
ChatListener.sendChat(ChatSender.of(event.getMessage(), steamwarUser), ChatSender.globalReceivers(), format, event.getMessage().getContentDisplay().replace('§', '&').replace('\n', ' '));
ChatListener.sendChat(ChatSender.of(event.getMessage(), steamwarUser), targets.get(), format, event.getMessage().getContentDisplay().replace('§', '&').replace('\n', ' '));
}
}