Search in sources :

Example 46 with XEmbedBuilder

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

the class DailyMsg method getInfo.

public XEmbedBuilder getInfo(DailyMessage messageObject, CommandObject command) {
    XEmbedBuilder embedBuilder = new XEmbedBuilder(command);
    IUser user = command.client.get().getUserByID(messageObject.getUserID());
    if (user != null) {
        embedBuilder.withAuthorName(user.getName() + "#" + user.getDiscriminator());
    }
    if (messageObject.getDay() != null) {
        embedBuilder.withTitle(messageObject.getDay() + "");
    }
    String contents = messageObject.getContents(new CommandObject(command.guild, command.channel.get()));
    if (contents.matches("^(> |\\*> |\\*\\*> |\\*\\*\\*> |_> |__> |`> |```> ).*$") || contents.startsWith("> ")) {
        embedBuilder.withDesc(contents);
    } else {
        embedBuilder.withDesc("> " + contents);
    }
    String formattedFooter;
    if (messageObject.getUID() != -1) {
        formattedFooter = new Formatter().format("UID: %04d", messageObject.getUID()).toString();
    } else {
        formattedFooter = messageObject.getSpecialID();
    }
    embedBuilder.withFooterText(formattedFooter);
    return embedBuilder;
}
Also used : CommandObject(com.github.vaerys.commands.CommandObject) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) Formatter(java.util.Formatter) IUser(sx.blah.discord.handle.obj.IUser)

Example 47 with XEmbedBuilder

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

the class EventSetup method execute.

@Override
public String execute(String args, CommandObject command) {
    SplitFirstObject eventName = new SplitFirstObject(args);
    TimedEvent event = null;
    if (eventName.getFirstWord().equalsIgnoreCase("list")) {
        XEmbedBuilder builder = new XEmbedBuilder(command);
        builder.withTitle("All Events:");
        String eventList = Utility.listFormatter(Globals.getEvents().stream().map(event1 -> event1.getEventName()).collect(Collectors.toList()), true);
        builder.withDesc("```\n" + eventList + spacer + "```");
        RequestHandler.sendEmbedMessage("", builder, command.channel.get());
        return null;
    }
    if (eventName.getRest() == null) {
        return "> Missing Mode.\n" + getModes();
    }
    for (TimedEvent t : Globals.getEvents()) {
        if (t.getEventName().equalsIgnoreCase(eventName.getFirstWord())) {
            event = t;
        }
    }
    if (event == null && eventName.getRest().equalsIgnoreCase("Create")) {
        Globals.getEvents().add(new TimedEvent(eventName.getFirstWord()));
        return "> Event Created.";
    } else {
        SplitFirstObject mode = new SplitFirstObject(eventName.getRest());
        if (event == null) {
            return "> Event does not exist yet.";
        }
        String output = doModes(event, mode, command);
        event.sanitizeDates();
        Globals.updateEvent();
        return output;
    }
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) TimedEvent(com.github.vaerys.objects.TimedEvent) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject)

Example 48 with XEmbedBuilder

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

the class CharAvatar method execute.

@Override
public String execute(String args, CommandObject command) {
    CharacterObject charObject = command.guild.characters.getCharByName(args.split(" ")[0]);
    if (charObject == null)
        return "> Could not find any characters with that Character ID.";
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle(charObject.getNickname());
    IUser user = command.guild.getUserByID(charObject.getUserID());
    builder.withFooterText("Author: " + user.getDisplayName(command.guild.get()) + " | Character ID: " + charObject.getName());
    command.guild.characters.validateRoles(command.guild.get());
    if (charObject.getRoleIDs().size() != 0) {
        builder.withColor(charObject.getColor(command.guild));
    }
    if (charObject.getAvatarURL() == null || charObject.getAvatarURL().isEmpty())
        return "> " + charObject.getNickname() + " Does not have an avatar set up.";
    builder.withImage(charObject.getAvatarURL());
    builder.send(command.channel);
    return "";
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) CharacterObject(com.github.vaerys.objects.CharacterObject) IUser(sx.blah.discord.handle.obj.IUser)

Example 49 with XEmbedBuilder

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

Example 50 with XEmbedBuilder

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

the class ChannelHere method execute.

@Override
public String execute(String args, CommandObject command) {
    String desc = "";
    if (!args.isEmpty()) {
        for (ChannelSetting s : command.guild.channelSettings) {
            if (args.equalsIgnoreCase(s.toString())) {
                return s.toggleSetting(command.guild, command.channel.longID);
            }
        }
        desc = "> Could not find channel type \"" + args + "\"\n";
    }
    XEmbedBuilder embedBuilder = new XEmbedBuilder(command);
    String title = "> Here are all of the channel Types and Settings:";
    List<ChannelSetting> channelSettings = command.guild.channelSettings;
    List<String> types = channelSettings.stream().filter(channelSetting -> !channelSetting.isSetting()).map(ChannelSetting::toString).collect(Collectors.toList());
    List<String> settings = channelSettings.stream().filter(channelSetting -> channelSetting.isSetting()).map(ChannelSetting::toString).collect(Collectors.toList());
    Collections.sort(types);
    desc += "**Types**\n```\n" + spacer + Utility.listFormatter(types, true) + "```\n" + spacer + "**Settings**\n```\n" + Utility.listFormatter(settings, true) + "```\n";
    desc += "The Command **" + get(HelpChannel.class).getUsage(command) + "** Can give you extra information about each of the above.\n\n";
    desc += missingArgs(command);
    embedBuilder.withDesc(desc);
    embedBuilder.withTitle(title);
    RequestHandler.sendEmbedMessage("", embedBuilder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) ChannelSetting(com.github.vaerys.enums.ChannelSetting)

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