Search in sources :

Example 1 with UserSetting

use of com.github.vaerys.enums.UserSetting in project DiscordSailv2 by Vaerys-Dawn.

the class PixelHandler method isUnRanked.

public static boolean isUnRanked(long userID, GuildUsers users, IGuild guild) {
    ProfileObject user = users.getUserByID(userID);
    GuildObject guildObject = Globals.getGuildContent(guild.getLongID());
    if (user == null) {
        return true;
    }
    if (guild.getUserByID(userID) == null) {
        return true;
    }
    if (user.getXP() == 0) {
        return true;
    }
    for (UserSetting s : user.getSettings()) {
        for (UserSetting test : Constants.dontLogStates) {
            if (s == test) {
                return true;
            }
        }
    }
    ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
    long diff = now.toEpochSecond() - user.getLastTalked();
    long days = TimeUnit.DAYS.convert(diff, TimeUnit.SECONDS);
    if (days > 14 && guildObject.config.xpDecay && !user.getSettings().contains(UserSetting.DONT_DECAY)) {
        return true;
    }
    return false;
}
Also used : GuildObject(com.github.vaerys.masterobjects.GuildObject) ZonedDateTime(java.time.ZonedDateTime) ProfileObject(com.github.vaerys.objects.ProfileObject) UserSetting(com.github.vaerys.enums.UserSetting)

Example 2 with UserSetting

use of com.github.vaerys.enums.UserSetting in project DiscordSailv2 by Vaerys-Dawn.

the class ProfileSettings method getSettings.

private String getSettings(CommandObject object) {
    StringBuilder builder = new StringBuilder();
    List<IChannel> levelUp = object.guild.getChannelsByType(ChannelSetting.LEVEL_UP);
    builder.append("**Settings:**\n");
    if (object.guild.config.modulePixels) {
        if (levelUp.size() != 0) {
            builder.append("> " + UserSetting.SEND_LVLUP_RANK_CHANNEL + " - `Level up messages will be sent to `" + levelUp.get(0).mention() + "\n");
        }
        builder.append("> " + UserSetting.SEND_LVLUP_CURRENT_CHANNEL + " - `Level up messages will be sent to the current channel.`\n" + "> " + UserSetting.SEND_LVLUP_DMS + " - `Level up messages will be sent to your DMs.`\n" + "> " + UserSetting.DONT_SEND_LVLUP + " - `Hides your Level up messages.`\n" + "> " + UserSetting.NO_XP_GAIN + " - `Stops you from gaining pixels.`\n" + "> " + UserSetting.HIDE_RANK + " - `Hides your rank on the server.`\n" + "> " + UserSetting.NO_LEVEL_UP_REACTIONS + " - `Stops level up reactions.`\n");
    }
    builder.append("> " + UserSetting.PRIVATE_PROFILE + " - `Hides your profile from other users.`");
    if (object.guild.config.modulePixels) {
        UserSetting setting = object.guild.config.defaultLevelMode;
        if (setting == UserSetting.SEND_LVLUP_RANK_CHANNEL && levelUp.size() == 0) {
            setting = UserSetting.SEND_LVLUP_CURRENT_CHANNEL;
        }
        builder.append("\n\nCurrent Guild Default: **" + setting.toString() + "**\n");
    } else {
        builder.append("\n");
    }
    return builder.toString();
}
Also used : IChannel(sx.blah.discord.handle.obj.IChannel) UserSetting(com.github.vaerys.enums.UserSetting)

Example 3 with UserSetting

use of com.github.vaerys.enums.UserSetting in project DiscordSailv2 by Vaerys-Dawn.

the class ProfileSettings method execute.

@Override
public String execute(String args, CommandObject command) {
    String message = "> Your Level messages will now be sent to ";
    ProfileObject userObject = command.guild.users.getUserByID(command.user.longID);
    StringBuilder builder = new StringBuilder();
    boolean pixels = command.guild.config.modulePixels;
    boolean levelChannel = command.guild.getChannelsByType(ChannelSetting.LEVEL_UP).size() != 0;
    String error = getSettings(command) + "\n" + Utility.getCommandInfo(this, command);
    for (String s : args.split(" ")) {
        UserSetting toTest = UserSetting.get(s);
        if (toTest == null) {
            return error;
        }
        if (pixels && levelChannel && toTest == UserSetting.SEND_LVLUP_RANK_CHANNEL) {
            IChannel levelUp = command.guild.getChannelByType(ChannelSetting.LEVEL_UP);
            if (levelUp != null) {
                removeLevelSettings(userObject);
                userObject.getSettings().add(UserSetting.SEND_LVLUP_RANK_CHANNEL);
                builder.append(message + levelUp.mention() + ".");
            } else {
                removeLevelSettings(userObject);
                userObject.getSettings().add(UserSetting.SEND_LVLUP_CURRENT_CHANNEL);
                builder.append(message + "the current channel.");
            }
        } else if (pixels && toTest == UserSetting.SEND_LVLUP_CURRENT_CHANNEL) {
            removeLevelSettings(userObject);
            userObject.getSettings().add(UserSetting.SEND_LVLUP_CURRENT_CHANNEL);
            builder.append(message + "the current channel.");
        } else if (pixels && toTest == UserSetting.SEND_LVLUP_DMS) {
            removeLevelSettings(userObject);
            userObject.getSettings().add(UserSetting.SEND_LVLUP_DMS);
            builder.append(message + "your Direct messages.");
        } else if (pixels && toTest == UserSetting.DONT_SEND_LVLUP) {
            removeLevelSettings(userObject);
            userObject.getSettings().add(UserSetting.DONT_SEND_LVLUP);
            builder.append("> You will no longer see any level up messages.");
        } else if (pixels && toTest == UserSetting.NO_XP_GAIN) {
            builder.append(toggleSetting(userObject, UserSetting.NO_XP_GAIN, "> You will now gain Xp again.", "> You will no longer gain XP"));
        } else if (pixels && toTest == UserSetting.HIDE_RANK) {
            builder.append(toggleSetting(userObject, UserSetting.HIDE_RANK, "> Your rank is now visible.", "> Your rank is now hidden."));
        } else if (pixels && toTest == UserSetting.NO_LEVEL_UP_REACTIONS) {
            builder.append(toggleSetting(userObject, UserSetting.NO_LEVEL_UP_REACTIONS, "> You will now get reactions added to the message that leveled you up.", "> You will no longer get reactions added to the message that leveled you up."));
        } else if (toTest == UserSetting.PRIVATE_PROFILE) {
            builder.append(toggleSetting(userObject, UserSetting.PRIVATE_PROFILE, "> Your profile is now public.", "> Your profile is now private."));
        } else {
            if (!builder.toString().contains(error)) {
                builder.append(error);
            }
        }
        if (!builder.toString().endsWith("\n")) {
            builder.append("\n");
        }
    }
    return builder.toString();
}
Also used : IChannel(sx.blah.discord.handle.obj.IChannel) ProfileObject(com.github.vaerys.objects.ProfileObject) UserSetting(com.github.vaerys.enums.UserSetting)

Example 4 with UserSetting

use of com.github.vaerys.enums.UserSetting in project DiscordSailv2 by Vaerys-Dawn.

the class UserSettings method sendList.

private String sendList(String prefix, ProfileObject profile, CommandObject command, UserObject user, boolean showCommand) {
    List<String> userSettings = new ArrayList<>();
    for (UserSetting s : profile.getSettings()) {
        userSettings.add(s.toString());
    }
    XEmbedBuilder builder = new XEmbedBuilder(command);
    builder.withTitle(user.displayName + "'s User settings:");
    if (userSettings.size() == 0) {
        return "> **" + user.displayName + "** has no settings on their profile.";
    } else {
        String desc = "```\n" + Utility.listFormatter(userSettings, true) + "```";
        if (showCommand) {
            desc += "\n" + Utility.getCommandInfo(this, command);
        }
        builder.withDesc(desc);
    }
    RequestHandler.sendEmbedMessage(prefix, builder, command.channel.get());
    return "";
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) ArrayList(java.util.ArrayList) UserSetting(com.github.vaerys.enums.UserSetting)

Example 5 with UserSetting

use of com.github.vaerys.enums.UserSetting in project DiscordSailv2 by Vaerys-Dawn.

the class UserSettings method execute.

@Override
public String execute(String args, CommandObject command) {
    if (args == null || args.isEmpty())
        return settings(command) + "\n\n" + missingArgs(command);
    SplitFirstObject split = new SplitFirstObject(args);
    UserObject user = Utility.getUser(command, split.getFirstWord(), false);
    if (user == null) {
        return "> Could not find user.";
    }
    ProfileObject profile = user.getProfile(command.guild);
    if (profile != null) {
        if (split.getRest() == null || split.getRest().equalsIgnoreCase("list")) {
            return sendList("", profile, command, user, false);
        }
        UserSetting toTest = UserSetting.get(split.getRest());
        if (toTest == null)
            return "> Not a valid user setting.\n" + settings(command);
        if (command.guild.config.modulePixels) {
            switch(toTest) {
                case DENIED_XP:
                    return toggleSetting(profile, UserSetting.DENIED_XP, "> **" + user.displayName + "** will now gain xp again.", "> **" + user.displayName + "** will no longer gain XP.");
                case DONT_SHOW_LEADERBOARD:
                    return toggleSetting(profile, UserSetting.DONT_SHOW_LEADERBOARD, "> **" + user.displayName + "'s** rank is now visible.", "> **" + user.displayName + "** will no longer show their rank.");
                case DONT_DECAY:
                    return toggleSetting(profile, UserSetting.DONT_DECAY, "> **" + user.displayName + "** will now have pixel decay.", "> **" + user.displayName + "** will no longer have pixel decay.");
                case DENY_AUTO_ROLE:
                    return toggleSetting(profile, UserSetting.DENY_AUTO_ROLE, "> **" + user.displayName + "** will now automatically be granted roles.", "> **" + user.displayName + "** will no longer automatically be granted roles.");
            }
        }
        if (command.guild.config.moduleCC) {
            switch(toTest) {
                case DENY_MAKE_CC:
                    return toggleSetting(profile, UserSetting.DENY_MAKE_CC, "> **" + user.displayName + "** can now make custom commands.", "> **" + user.displayName + "** can no longer make custom commands.");
                case DENY_USE_CCS:
                    return toggleSetting(profile, UserSetting.DENY_USE_CCS, "> **" + user.displayName + "** can now use custom commands.", "> **" + user.displayName + "** can no longer use custom commands.");
                case AUTO_SHITPOST:
                    return toggleSetting(profile, UserSetting.AUTO_SHITPOST, "> **" + user.displayName + "** no longer has the shitpost tag automatically added to all of their new Custom Commands.", "> **" + user.displayName + "** now has the shitpost tag automatically added to all of their new Custom Commands.");
            }
        }
        if (command.guild.config.artPinning) {
            switch(toTest) {
                case DENY_ART_PINNING:
                    return toggleSetting(profile, UserSetting.DENY_ART_PINNING, "> **" + user.displayName + "** can now pin art.", "> **" + user.displayName + "** can no longer pin art.");
            }
        }
        switch(toTest) {
            case DENY_INVITES:
                return toggleSetting(profile, UserSetting.DENY_INVITES, "> **" + user.displayName + "** can now post instant invites.", "> **" + user.displayName + "** can no longer post instant invites.");
            default:
                String response = (split.getRest() == null || split.getRest().isEmpty()) ? "" : "> Not a valid User Setting.\n\n";
                if (profile.getSettings().size() == 0) {
                    return response + "> **" + user.displayName + "** has no settings attached to their profile.\n\n" + settings(command) + "\n\n" + Utility.getCommandInfo(this, command);
                } else {
                    return sendList(response, profile, command, user, true);
                }
        }
    } else {
        return "> Invalid user.";
    }
}
Also used : UserObject(com.github.vaerys.masterobjects.UserObject) SplitFirstObject(com.github.vaerys.objects.SplitFirstObject) ProfileObject(com.github.vaerys.objects.ProfileObject) UserSetting(com.github.vaerys.enums.UserSetting)

Aggregations

UserSetting (com.github.vaerys.enums.UserSetting)6 ProfileObject (com.github.vaerys.objects.ProfileObject)3 IChannel (sx.blah.discord.handle.obj.IChannel)2 GuildObject (com.github.vaerys.masterobjects.GuildObject)1 UserObject (com.github.vaerys.masterobjects.UserObject)1 SplitFirstObject (com.github.vaerys.objects.SplitFirstObject)1 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)1 TagObject (com.github.vaerys.templates.TagObject)1 ZonedDateTime (java.time.ZonedDateTime)1 ArrayList (java.util.ArrayList)1