geforkt von SteamWar/BungeeCore
Add AnnouncementListener
Dieser Commit ist enthalten in:
Ursprung
536d503f6e
Commit
31a07c30e2
@ -48,6 +48,9 @@ public class SteamwarDiscordBot {
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private AnnouncementListener announcementListener;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final JDA jda;
|
private final JDA jda;
|
||||||
|
|
||||||
@ -77,7 +80,7 @@ public class SteamwarDiscordBot {
|
|||||||
|
|
||||||
new RolesInteractionButtonListener();
|
new RolesInteractionButtonListener();
|
||||||
new DiscordTicketListener();
|
new DiscordTicketListener();
|
||||||
new AnnouncementListener();
|
announcementListener = new AnnouncementListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
private int index = 0;
|
private int index = 0;
|
||||||
|
@ -20,7 +20,10 @@
|
|||||||
package de.steamwar.bungeecore.bot.listeners;
|
package de.steamwar.bungeecore.bot.listeners;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
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 net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
@ -36,4 +39,12 @@ public class AnnouncementListener extends BasicDiscordListener {
|
|||||||
}
|
}
|
||||||
Message.broadcast("ALERT", event.getMessage().getContentRaw());
|
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;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
|
|
||||||
@ -36,6 +37,8 @@ public class AlertCommand extends BasicCommand {
|
|||||||
return;
|
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