SteamWar/BungeeCore
Archiviert
13
2

Add AnnouncementListener

Dieser Commit ist enthalten in:
yoyosource 2021-07-28 18:30:49 +02:00
Ursprung 536d503f6e
Commit 31a07c30e2
3 geänderte Dateien mit 19 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -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;

Datei anzeigen

@ -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();
}
}

Datei anzeigen

@ -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);
}
}