SteamWar/BungeeCore
Archiviert
13
2

discord-bot #230

Manuell gemergt
YoyoNow hat 38 Commits von discord-bot nach master 2021-07-28 23:59:27 +02:00 zusammengeführt
3 geänderte Dateien mit 19 neuen und 2 gelöschten Zeilen
Nur Änderungen aus Commit 31a07c30e2 werden angezeigt - Alle Commits anzeigen

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