Search in sources :

Example 6 with CharacterObject

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

the class CharInfo method execute.

@Override
public String execute(String args, CommandObject command) {
    for (CharacterObject object : command.guild.characters.getCharacters(command.guild.get())) {
        if (object.getName().equalsIgnoreCase(args)) {
            XEmbedBuilder builder = new XEmbedBuilder(command);
            builder.withTitle(object.getNickname());
            IUser user = command.guild.getUserByID(object.getUserID());
            if (user == null) {
                builder.withFooterText("Author: No longer on this server | Character ID: " + object.getName());
            } else {
                builder.withFooterText("Author: " + user.getDisplayName(command.guild.get()) + " | Character ID: " + object.getName());
            }
            ArrayList<IRole> roles = new ArrayList<>();
            ArrayList<String> roleNames = new ArrayList<>();
            for (Long roleId : object.getRoleIDs()) {
                if (command.client.get().getRoleByID(roleId) != null) {
                    roles.add(command.client.get().getRoleByID(roleId));
                    roleNames.add(command.client.get().getRoleByID(roleId).getName());
                }
            }
            if (roles.size() != 0) {
                builder.withColor(GuildHandler.getUsersColour(roles));
            } else {
                builder.withColor(GuildHandler.getUsersColour(user, command.guild.get()));
            }
            StringBuilder description = new StringBuilder();
            description.append("**Age:** " + object.getAge());
            description.append("\n**Gender:** " + object.getGender());
            if (object.getHeight() != null || object.getWeight() != null) {
                description.append("\n");
                if (object.getHeight() != null) {
                    description.append("**Height:** " + object.getHeight() + indent);
                }
                if (object.getWeight() != null) {
                    description.append("**Weight:** " + object.getWeight());
                }
            }
            if (roleNames.size() != 0) {
                if (command.guild.characters.getRolePrefix() != null && !command.guild.characters.getRolePrefix().isEmpty()) {
                    description.append("\n" + command.guild.characters.getRolePrefix() + " " + Utility.listFormatter(roleNames, true));
                } else {
                    description.append("\n" + Utility.listFormatter(roleNames, true));
                }
            }
            description.append("\n**Bio:** " + object.getShortBio());
            if (object.getLongBioURL() != null && !object.getLongBioURL().isEmpty()) {
                description.append("\n\n**[Long Description Link...](" + object.getLongBioURL() + ")**");
            }
            builder.withDesc(description.toString());
            if (object.getAvatarURL() != null && !object.getAvatarURL().isEmpty()) {
                if (object.getAvatarURL().contains("\n") || object.getAvatarURL().contains(" ")) {
                    return "> An Error Occurred. Avatar url needs to be reset.";
                }
                builder.withThumbnail(object.getAvatarURL());
            }
            RequestHandler.sendEmbedMessage("", builder, command.channel.get());
            return null;
        }
    }
    return "> Character with that name not found.";
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) CharacterObject(com.github.vaerys.objects.CharacterObject) IRole(sx.blah.discord.handle.obj.IRole) ArrayList(java.util.ArrayList) IUser(sx.blah.discord.handle.obj.IUser)

Aggregations

CharacterObject (com.github.vaerys.objects.CharacterObject)6 IRole (sx.blah.discord.handle.obj.IRole)3 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)2 IUser (sx.blah.discord.handle.obj.IUser)2 CommandObject (com.github.vaerys.commands.CommandObject)1 ChannelSetting (com.github.vaerys.enums.ChannelSetting)1 SAILType (com.github.vaerys.enums.SAILType)1 CCommandObject (com.github.vaerys.objects.CCommandObject)1 ProfileObject (com.github.vaerys.objects.ProfileObject)1 ServerObject (com.github.vaerys.objects.ServerObject)1 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1 SubCommandObject (com.github.vaerys.objects.SubCommandObject)1 Command (com.github.vaerys.templates.Command)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ListIterator (java.util.ListIterator)1 Collectors (java.util.stream.Collectors)1 Permissions (sx.blah.discord.handle.obj.Permissions)1