diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java index 3ade058f..2e338ae8 100644 --- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java +++ b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java @@ -48,6 +48,9 @@ public class SteamwarDiscordBot { return INSTANCE; } + @Getter + private AnnouncementListener announcementListener; + @Getter private final JDA jda; @@ -77,7 +80,7 @@ public class SteamwarDiscordBot { new RolesInteractionButtonListener(); new DiscordTicketListener(); - new AnnouncementListener(); + announcementListener = new AnnouncementListener(); } private int index = 0; diff --git a/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java b/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java index 46d7054c..f3803d2c 100644 --- a/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java +++ b/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java @@ -20,7 +20,10 @@ package de.steamwar.bungeecore.bot.listeners; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; +import net.dv8tion.jda.api.MessageBuilder; +import net.dv8tion.jda.api.entities.TextChannel; import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; import org.jetbrains.annotations.NotNull; @@ -36,4 +39,12 @@ public class AnnouncementListener extends BasicDiscordListener { } Message.broadcast("ALERT", event.getMessage().getContentRaw()); } + + public void announce(String message) { + TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL); + assert textChannel != null; + MessageBuilder messageBuilder = new MessageBuilder(); + messageBuilder.append(message.replace("&", "")); + textChannel.sendMessage(messageBuilder.build()).complete(); + } } diff --git a/src/de/steamwar/bungeecore/commands/AlertCommand.java b/src/de/steamwar/bungeecore/commands/AlertCommand.java index 2b23e99e..02623cb8 100644 --- a/src/de/steamwar/bungeecore/commands/AlertCommand.java +++ b/src/de/steamwar/bungeecore/commands/AlertCommand.java @@ -20,6 +20,7 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.bot.SteamwarDiscordBot; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.CommandSender; @@ -36,6 +37,8 @@ public class AlertCommand extends BasicCommand { return; } - Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', String.join(" ", args))); + String s = String.join(" ", args); + Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', s)); + SteamwarDiscordBot.instance().getAnnouncementListener().announce(s); } }