diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java index 5114f085..3ade058f 100644 --- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java +++ b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java @@ -22,6 +22,7 @@ package de.steamwar.bungeecore.bot; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; import de.steamwar.bungeecore.bot.events.EventManager; +import de.steamwar.bungeecore.bot.listeners.AnnouncementListener; import de.steamwar.bungeecore.bot.listeners.DiscordTicketListener; import de.steamwar.bungeecore.bot.listeners.RolesInteractionButtonListener; import de.steamwar.bungeecore.bot.util.DiscordTicketMessage; @@ -76,6 +77,7 @@ public class SteamwarDiscordBot { new RolesInteractionButtonListener(); new DiscordTicketListener(); + new AnnouncementListener(); } private int index = 0; diff --git a/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java b/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java index 1e00925f..0c3349f2 100644 --- a/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java +++ b/src/de/steamwar/bungeecore/bot/config/SteamwarDiscordBotConfig.java @@ -30,6 +30,7 @@ public class SteamwarDiscordBotConfig { public static String TOKEN; public static String GUILD; + public static String ANNOUNCEMENTS_CHANNEL; public static String EVENTS_CHANNEL; public static String ROLES_CHANNEL; public static String ROLES_BASE_MESSAGE; @@ -50,6 +51,7 @@ public class SteamwarDiscordBotConfig { public static void loadConfig(Configuration config) { TOKEN = config.getString("token"); GUILD = config.getString("guild"); + ANNOUNCEMENTS_CHANNEL = config.getString("announcements-channel"); EVENTS_CHANNEL = config.getString("events-channel"); Configuration rolesSection = config.getSection("roles-claim"); ROLES_CHANNEL = rolesSection.getString("channel"); diff --git a/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java b/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java new file mode 100644 index 00000000..46d7054c --- /dev/null +++ b/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java @@ -0,0 +1,39 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2020 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +package de.steamwar.bungeecore.bot.listeners; + +import de.steamwar.bungeecore.Message; +import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig; +import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent; +import org.jetbrains.annotations.NotNull; + +public class AnnouncementListener extends BasicDiscordListener { + + @Override + public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) { + if (!event.getChannel().getId().equals(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL)) { + return; + } + if (event.getAuthor().isBot()) { + return; + } + Message.broadcast("ALERT", event.getMessage().getContentRaw()); + } +}