Search in sources :

Example 26 with XEmbedBuilder

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

the class ListServers method execute.

@Override
public String execute(String args, CommandObject command) {
    if (command.guild.servers.getServers().size() == 0) {
        return "> No servers have been listed yet, If you would like to list one yourself you can do so using **" + get(AddServer.class).getUsage(command) + "**.";
    }
    XEmbedBuilder builder = new XEmbedBuilder(command);
    String title = "> Here are the Servers I have Listed:";
    ArrayList<String> serverNames = command.guild.servers.getServers().stream().map(ServerObject::getName).collect(Collectors.toCollection(ArrayList::new));
    Collections.sort(serverNames);
    String suffix = Utility.getCommandInfo(new Server(), command);
    Utility.listFormatterEmbed(title, builder, serverNames, false, suffix);
    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Example 27 with XEmbedBuilder

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

the class TopTen method execute.

@Override
public String execute(String args, CommandObject command) {
    ArrayList<ProfileObject> ranks = new ArrayList<>();
    ArrayList<String> response = new ArrayList<>();
    for (ProfileObject u : command.guild.users.getProfiles()) {
        long rank = PixelHandler.rank(command.guild.users, command.guild.get(), u.getUserID());
        if (rank <= 10 && rank != -1) {
            ranks.add(u);
        }
    }
    Utility.sortUserObjects(ranks, false);
    // format rank stats
    for (ProfileObject r : ranks) {
        IUser ranked = command.guild.getUserByID(r.getUserID());
        String rankPos = "**" + PixelHandler.rank(command.guild.users, command.guild.get(), r.getUserID()) + "** - ";
        StringBuilder toFormat = new StringBuilder(ranked.getDisplayName(command.guild.get()));
        toFormat.append("\n " + indent + "`Level: " + r.getCurrentLevel() + ", Pixels: " + NumberFormat.getInstance().format(r.getXP()) + "`");
        if (r.getUserID() == command.user.get().getLongID()) {
            response.add(rankPos + spacer + "**" + toFormat + "**");
        } else {
            response.add(rankPos + toFormat);
        }
    }
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle("Top Ten Users for the " + command.guild.get().getName() + " Server.");
    builder.withDesc(Utility.listFormatter(response, false));
    RequestHandler.sendEmbedMessage("", builder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) ArrayList(java.util.ArrayList) IUser(sx.blah.discord.handle.obj.IUser) ProfileObject(com.github.vaerys.objects.ProfileObject)

Example 28 with XEmbedBuilder

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

the class TopUserForRole method getEmbed.

private void getEmbed(CommandObject command, IRole role, List<Long> userIDs) {
    XEmbedBuilder embed = new XEmbedBuilder(command);
    int showing = (userIDs.size() > 5 ? 5 : userIDs.size());
    embed.withTitle("Top " + (userIDs.size() == 1 ? " user" : showing + " users") + " for role " + role.getName());
    embed.withFooterText("Total ranked users with this role: " + userIDs.size());
    ProfileObject userProfile;
    UserObject userObject;
    NumberFormat nf = NumberFormat.getInstance();
    String titlef = "#%s. %s";
    String contentf = "**XP:** %s\t**Level:** %s\n**UID:** %s";
    for (int i = 0; i < showing; i++) {
        userProfile = command.guild.users.getUserByID(userIDs.get(i));
        userObject = userProfile.getUser(command.guild);
        embed.appendField(String.format(titlef, i + 1, userObject.displayName), String.format(contentf, nf.format(userProfile.getXP()), userProfile.getCurrentLevel(), userObject.longID), false);
    }
    embed.send(command.channel);
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) UserObject(com.github.vaerys.masterobjects.UserObject) ProfileObject(com.github.vaerys.objects.ProfileObject) NumberFormat(java.text.NumberFormat)

Example 29 with XEmbedBuilder

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

the class ListModifs method getList.

public static XEmbedBuilder getList(CommandObject command) {
    String title = "> Here are the Modifier roles you can choose from:";
    List<String> list = command.guild.getModifierRoles().stream().map(iRole -> iRole.getName()).collect(Collectors.toList());
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle(title);
    builder.withDesc("```\n" + Utility.listFormatter(list, true) + "```\n" + get(ModifierRoles.class).missingArgs(command));
    return builder;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) List(java.util.List) CommandObject(com.github.vaerys.commands.CommandObject) RequestHandler(com.github.vaerys.handlers.RequestHandler) ChannelSetting(com.github.vaerys.enums.ChannelSetting) SAILType(com.github.vaerys.enums.SAILType) Permissions(sx.blah.discord.handle.obj.Permissions) Command(com.github.vaerys.templates.Command) Utility(com.github.vaerys.main.Utility) Collectors(java.util.stream.Collectors) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

Example 30 with XEmbedBuilder

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

the class ListRoles method getList.

public static XEmbedBuilder getList(CommandObject command) {
    String title = "> Here are the Cosmetic roles you can choose from:";
    List<String> list = command.guild.getCosmeticRoles().stream().map(iRole -> iRole.getName()).collect(Collectors.toList());
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle(title);
    builder.withDesc("```\n" + Utility.listFormatter(list, true) + "```\n" + get(CosmeticRoles.class).missingArgs(command));
    return builder;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) List(java.util.List) CommandObject(com.github.vaerys.commands.CommandObject) RequestHandler(com.github.vaerys.handlers.RequestHandler) ChannelSetting(com.github.vaerys.enums.ChannelSetting) SAILType(com.github.vaerys.enums.SAILType) Permissions(sx.blah.discord.handle.obj.Permissions) Command(com.github.vaerys.templates.Command) Utility(com.github.vaerys.main.Utility) Collectors(java.util.stream.Collectors) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder)

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