Search in sources :

Example 6 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class AdminEcho method execute.

@Override
public String execute(String args, CommandObject command) {
    List<TagObject> tags = TagList.getType(TagType.CC);
    ListIterator<TagObject> iterator = tags.listIterator();
    while (iterator.hasNext()) {
        TagObject object = iterator.next();
        if (object.name.equals(new TagRemoveMentions(0).name)) {
            iterator.remove();
        }
    }
    args += new TagRemoveSanitizeTag(0).name;
    TagList.sort(tags);
    for (TagObject t : tags) {
        args = t.handleTag(args, command, "");
    }
    return args;
}
Also used : TagRemoveMentions(com.github.vaerys.tags.cctags.TagRemoveMentions) TagObject(com.github.vaerys.templates.TagObject) TagRemoveSanitizeTag(com.github.vaerys.tags.cctags.TagRemoveSanitizeTag)

Example 7 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class TagList method getType.

public static List<TagObject> getType(TagType type) {
    List<TagObject> list = new LinkedList<>();
    for (TagObject o : tags) {
        for (TagType t : o.getTypes()) {
            if (t == type) {
                list.add(o);
                break;
            }
        }
    }
    sort(list);
    return list;
}
Also used : TagType(com.github.vaerys.enums.TagType) TagObject(com.github.vaerys.templates.TagObject) LinkedList(java.util.LinkedList)

Example 8 with TagObject

use of com.github.vaerys.templates.TagObject in project DiscordSailv2 by Vaerys-Dawn.

the class PixelHandler method handleMessage.

/**
 * Handles the sending of the level up message
 *
 * @param user   the user that leveled up.
 * @param object the container for all relevant API content.
 * @param reward reward object that contains info on the reward they have received.
 */
private static void handleMessage(ProfileObject user, CommandObject object, RewardRoleObject reward) {
    UserSetting defaultOverride = object.guild.config.defaultLevelMode;
    UserSetting userState = user.getLevelState();
    boolean rankedUp = reward != null;
    IChannel levelChannel = object.guild.getChannelByType(ChannelSetting.LEVEL_UP);
    IChannel currentChannel = object.channel.get();
    IChannel dmChannel = object.user.getDmChannel();
    IMessage levelMessage = null;
    // force override
    if (userState == null || defaultOverride == DONT_SEND_LVLUP || defaultOverride == SEND_LVLUP_DMS) {
        userState = defaultOverride;
    }
    // get custom level up message.
    StringHandler levelUpMessage = new StringHandler(object.guild.config.levelUpMessage);
    // handle level up tags
    for (TagObject t : TagList.getType(TagType.LEVEL)) {
        levelUpMessage.setContent(t.handleTag(levelUpMessage.toString(), object, ""));
    }
    // build rank up message
    if (rankedUp) {
        levelUpMessage.replace("%s", "");
        if (user.getSettings().contains(HIT_LEVEL_FLOOR)) {
            levelUpMessage.appendFront("Welcome Back.\n");
            levelUpMessage.append("\nYour **@%s** role has been returned to you.");
            user.getSettings().remove(HIT_LEVEL_FLOOR);
        } else {
            levelUpMessage.append("\nYou have been granted the **@%s** role for reaching this level.");
        }
        levelUpMessage.format(reward.getRole(object).getName());
    }
    if (user.getCurrentLevel() == 1) {
        levelUpMessage.appendFormatted("\n\n> If you want to change where these messages are sent or want" + " to remove them completely you can change that with `%s`.", Command.get(ProfileSettings.class).getUsage(object));
    }
    // do send message
    switch(userState) {
        case SEND_LVLUP_CURRENT_CHANNEL:
            levelMessage = sendLevelMessage(levelUpMessage.toString(), currentChannel, rankedUp, false);
            break;
        case SEND_LVLUP_RANK_CHANNEL:
            if (levelChannel == null) {
                levelMessage = sendLevelMessage(levelUpMessage.toString(), currentChannel, rankedUp, false);
            } else {
                sendLevelMessage(levelUpMessage.toString(), levelChannel, rankedUp, true);
            }
            break;
        case SEND_LVLUP_DMS:
            sendLevelMessage(levelUpMessage.toString(), dmChannel, rankedUp, true);
            break;
    }
    // self destruct level messages
    if (levelMessage != null) {
        selfDestruct(levelMessage, user, object);
    }
}
Also used : TagObject(com.github.vaerys.templates.TagObject) UserSetting(com.github.vaerys.enums.UserSetting)

Aggregations

TagObject (com.github.vaerys.templates.TagObject)8 CCommandObject (com.github.vaerys.objects.CCommandObject)2 TagType (com.github.vaerys.enums.TagType)1 UserSetting (com.github.vaerys.enums.UserSetting)1 ProfileObject (com.github.vaerys.objects.ProfileObject)1 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1 TagEmbedImage (com.github.vaerys.tags.cctags.TagEmbedImage)1 TagRemoveMentions (com.github.vaerys.tags.cctags.TagRemoveMentions)1 TagRemoveSanitizeTag (com.github.vaerys.tags.cctags.TagRemoveSanitizeTag)1 LinkedList (java.util.LinkedList)1 Random (java.util.Random)1 IChannel (sx.blah.discord.handle.obj.IChannel)1