discord-bot #230
@ -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;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren