Search in sources :

Example 1 with ChannelSettingObject

use of com.github.vaerys.objects.ChannelSettingObject in project DiscordSailv2 by Vaerys-Dawn.

the class ChannelStats method execute.

@Override
public String execute(String args, CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle("Channel Stats");
    ArrayList<String> channelTypes = new ArrayList<>();
    ArrayList<String> channelSettings = new ArrayList<>();
    if (args != null && !args.isEmpty()) {
        for (ChannelSetting s : command.guild.channelSettings) {
            if (s.toString().equalsIgnoreCase(args)) {
                List<IChannel> channels = command.guild.getChannelsByType(s);
                List<String> channelMentions = Utility.getChannelMentions(channels);
                if (channels.size() != 0) {
                    builder.appendField(s.toString(), Utility.listFormatter(channelMentions, true), false);
                    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
                    return null;
                } else {
                    if (s.isSetting()) {
                        return "> Could not find any channels with the **" + s.toString() + "** setting enabled.";
                    } else {
                        return "> Could not find a channel with the **" + s.toString() + "** type enabled.";
                    }
                }
            }
        }
        return "> Could not any channel settings with that name.";
    }
    for (ChannelSettingObject c : command.guild.channelData.getChannelSettings()) {
        if (c.getChannelIDs().contains(command.channel.longID)) {
            for (ChannelSetting setting : Globals.getChannelSettings()) {
                if (c.getType() == setting) {
                    if (setting.isSetting()) {
                        channelSettings.add(c.getType().toString());
                    } else {
                        channelTypes.add(c.getType().toString());
                    }
                }
            }
        }
    }
    if (channelSettings.size() == 0 && channelTypes.size() == 0) {
        return "> I found nothing of value.";
    }
    if (channelTypes.size() != 0) {
        builder.appendField("Types:", Utility.listFormatter(channelTypes, true), false);
    }
    if (channelSettings.size() != 0) {
        builder.appendField("Settings:", Utility.listFormatter(channelSettings, true), false);
    }
    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) ChannelSetting(com.github.vaerys.enums.ChannelSetting) IChannel(sx.blah.discord.handle.obj.IChannel) ChannelSettingObject(com.github.vaerys.objects.ChannelSettingObject) ArrayList(java.util.ArrayList)

Aggregations

ChannelSetting (com.github.vaerys.enums.ChannelSetting)1 ChannelSettingObject (com.github.vaerys.objects.ChannelSettingObject)1 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)1 ArrayList (java.util.ArrayList)1 IChannel (sx.blah.discord.handle.obj.IChannel)1