Search in sources :

Example 6 with Guild

use of net.dv8tion.jda.api.entities.Guild in project Saber-Bot by notem.

the class GlobalMsgCommand method action.

@Override
public void action(String prefix, String[] args, MessageReceivedEvent event) {
    String msg = "";
    for (String arg : args) {
        msg += arg + " ";
    }
    for (Guild guild : Main.getShardManager().getGuilds()) {
        String channelId = Main.getGuildSettingsManager().getGuildSettings(guild.getId()).getCommandChannelId();
        if (// look for default control channel name
        channelId == null) {
            Collection<TextChannel> chans = guild.getTextChannelsByName(Main.getBotSettingsManager().getControlChan(), true);
            for (TextChannel chan : chans) {
                MessageUtilities.sendMsg(msg, chan, null);
            }
        } else // send to configured control channel
        {
            MessageChannel chan = guild.getTextChannelById(channelId);
            if (chan != null) {
                MessageUtilities.sendMsg(msg, chan, null);
            }
        }
    }
    MessageUtilities.sendPrivateMsg("Finished sending announcements to guilds!", event.getAuthor(), null);
}
Also used : TextChannel(net.dv8tion.jda.api.entities.TextChannel) MessageChannel(net.dv8tion.jda.api.entities.MessageChannel) Guild(net.dv8tion.jda.api.entities.Guild)

Aggregations

Guild (net.dv8tion.jda.api.entities.Guild)6 EmbedBuilder (net.dv8tion.jda.api.EmbedBuilder)3 TextChannel (net.dv8tion.jda.api.entities.TextChannel)3 Collectors (java.util.stream.Collectors)2 JDA (net.dv8tion.jda.api.JDA)2 Permission (net.dv8tion.jda.api.Permission)2 Message (net.dv8tion.jda.api.entities.Message)2 MessageChannel (net.dv8tion.jda.api.entities.MessageChannel)2 Filters.eq (com.mongodb.client.model.Filters.eq)1 Projections.fields (com.mongodb.client.model.Projections.fields)1 Projections.include (com.mongodb.client.model.Projections.include)1 Command (de.c0debase.bot.commands.Command)1 java.util (java.util)1 Collection (java.util.Collection)1 Consumer (java.util.function.Consumer)1 Function (java.util.function.Function)1 Stream (java.util.stream.Stream)1 MessageBuilder (net.dv8tion.jda.api.MessageBuilder)1 MessageEmbed (net.dv8tion.jda.api.entities.MessageEmbed)1 Role (net.dv8tion.jda.api.entities.Role)1