Search in sources :

Example 6 with XEmbedBuilder

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

the class ListCCs method getUserCommands.

public String getUserCommands(CommandObject command, long userID) {
    IUser user = Globals.getClient().getUserByID(userID);
    int total = 0;
    command.setAuthor(user);
    int max = command.guild.customCommands.maxCCs(command.user, command.guild);
    XEmbedBuilder builder = new XEmbedBuilder(command);
    String title = "> Here are the custom commands for user: **@" + user.getName() + "#" + user.getDiscriminator() + "**.";
    List<String> list = new ArrayList<>();
    for (CCommandObject c : command.guild.customCommands.getCommandList()) {
        if (c.getUserID() == userID) {
            list.add(command.guild.config.getPrefixCC() + c.getName());
            total++;
        }
    }
    builder.withTitle(title);
    String content = Utility.listFormatter(list, true);
    if (content.length() > 2000) {
        String path = Constants.DIRECTORY_TEMP + command.message.longID + ".txt";
        FileHandler.writeToFile(path, content, false);
        File file = new File(path);
        RequestHandler.sendFile(title, file, command.channel.get());
        return null;
    }
    builder.withDescription("```\n" + content + "```");
    builder.withFooterText("Total Custom commands: " + total + "/" + max + ".");
    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) CCommandObject(com.github.vaerys.objects.CCommandObject) ArrayList(java.util.ArrayList) IUser(sx.blah.discord.handle.obj.IUser) File(java.io.File)

Example 7 with XEmbedBuilder

use of com.github.vaerys.objects.XEmbedBuilder 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)

Example 8 with XEmbedBuilder

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

the class InfoEditModes method listFiles.

public static String listFiles(CommandObject command) {
    // send Embed
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle("> Here are the files available to you:");
    File imagDir = new File(Utility.getGuildImageDir(command.guild.longID));
    File[] imageList = imagDir.listFiles();
    ArrayList<String> fileNames = new ArrayList<>();
    for (File f : imageList) {
        fileNames.add(f.getName());
    }
    builder.withDesc("```\n" + Utility.listFormatter(fileNames, true) + "```");
    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) ArrayList(java.util.ArrayList) File(java.io.File)

Example 9 with XEmbedBuilder

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

the class HelpDM method execute.

@Override
public String execute(String args, CommandObject command) {
    XEmbedBuilder builder = new XEmbedBuilder(command);
    List<Command> commands = Utility.getCommandsByType(Globals.getAllCommands(), command, SAILType.DM, true);
    List<String> list = new ArrayList<>();
    for (Command c : commands) {
        list.add(c.getCommand(command));
    }
    Collections.sort(list);
    StringBuilder desc = new StringBuilder("**> Direct Message Commands.**```" + Utility.listFormatter(list, false) + "```\n");
    desc.append(Utility.getCommandInfo(new InfoDM()));
    builder.withDescription(desc.toString());
    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) DMCommand(com.github.vaerys.templates.DMCommand) Command(com.github.vaerys.templates.Command) ArrayList(java.util.ArrayList)

Example 10 with XEmbedBuilder

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

the class GetGuildList method execute.

@Override
public String execute(String args, CommandObject command) {
    ArrayList<String> guilds = new ArrayList<>();
    for (IGuild g : command.client.get().getGuilds()) {
        guilds.add(g.getName() + ": " + g.getLongID());
    }
    XEmbedBuilder builder = new XEmbedBuilder(command);
    Utility.listFormatterEmbed("List Of Guilds", builder, guilds, false);
    command.user.sendEmbededDm("", builder);
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) ArrayList(java.util.ArrayList) IGuild(sx.blah.discord.handle.obj.IGuild)

Aggregations

XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)51 ArrayList (java.util.ArrayList)15 ChannelSetting (com.github.vaerys.enums.ChannelSetting)10 SAILType (com.github.vaerys.enums.SAILType)10 CommandObject (com.github.vaerys.commands.CommandObject)9 IUser (sx.blah.discord.handle.obj.IUser)9 Utility (com.github.vaerys.main.Utility)8 UserObject (com.github.vaerys.masterobjects.UserObject)8 Collectors (java.util.stream.Collectors)8 Command (com.github.vaerys.templates.Command)7 List (java.util.List)6 Permissions (sx.blah.discord.handle.obj.Permissions)6 RequestHandler (com.github.vaerys.handlers.RequestHandler)5 StringHandler (com.github.vaerys.handlers.StringHandler)5 ProfileObject (com.github.vaerys.objects.ProfileObject)5 IRole (sx.blah.discord.handle.obj.IRole)5 CCommandObject (com.github.vaerys.objects.CCommandObject)4 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)4 GuildToggle (com.github.vaerys.templates.GuildToggle)4 LinkedList (java.util.LinkedList)4