ChatRefactor #349
@ -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());
|
||||
|
||||
|
@ -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', ' '));
|
||||
}
|
||||
}
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren