Search in sources :

Example 1 with Badge

use of tk.ardentbot.utils.rpg.profiles.Badge in project Ardent by adamint.

the class UserUtils method hasTierTwoPermissions.

public static boolean hasTierTwoPermissions(User user) {
    String id = user.getId();
    boolean normalPermissions = isStaff(user) || tierTwopatrons.contains(id) || tierThreepatrons.contains(id);
    if (!normalPermissions) {
        Profile profile = Profile.get(user);
        for (Badge badge : profile.getBadges()) {
            if (BadgesList.from(badge.getId()).getId().equalsIgnoreCase(BadgesList.PREMIUM_TRIAL.getId())) {
                return true;
            }
        }
        return false;
    } else
        return true;
}
Also used : Badge(tk.ardentbot.utils.rpg.profiles.Badge) Profile(tk.ardentbot.utils.rpg.profiles.Profile)

Example 2 with Badge

use of tk.ardentbot.utils.rpg.profiles.Badge in project Ardent by adamint.

the class UserUtils method hasTierThreePermissions.

public static boolean hasTierThreePermissions(User user) {
    String id = user.getId();
    boolean normalPermissions = isStaff(user) || tierThreepatrons.contains(id);
    if (!normalPermissions) {
        Profile profile = Profile.get(user);
        for (Badge badge : profile.getBadges()) {
            if (BadgesList.from(badge.getId()).getId().equalsIgnoreCase(BadgesList.PREMIUM_TRIAL.getId())) {
                return true;
            }
        }
        return false;
    } else
        return true;
}
Also used : Badge(tk.ardentbot.utils.rpg.profiles.Badge) Profile(tk.ardentbot.utils.rpg.profiles.Profile)

Example 3 with Badge

use of tk.ardentbot.utils.rpg.profiles.Badge in project Ardent by adamint.

the class ProfileUpdater method updateProfiles.

public static void updateProfiles() {
    Cursor<HashMap> profiles = r.db("data").table("profiles").run(connection);
    profiles.forEach(hashMap -> {
        Profile profile = asPojo(hashMap, Profile.class);
        if (profile.getUser() == null && !Ardent.testingBot) {
            r.table("profiles").get(profile.user_id).delete().run(connection);
            return;
        }
        for (Iterator<Badge> iterator = profile.getBadges().iterator(); iterator.hasNext(); ) {
            Badge badge = iterator.next();
            if (badge.getExpirationEpochSeconds() < Instant.now().getEpochSecond() && badge.getExpirationEpochSeconds() != 1) {
                User user = profile.getUser();
                if (user != null) {
                    user.openPrivateChannel().queue(privateChannel -> {
                        Ardent.shard0.help.sendTranslatedMessage("Your badge with the ID of **" + badge.getName() + "** has " + "expired" + ".", privateChannel, user);
                        r.db("data").table("badges").filter(row -> row.g("user_id").eq(user.getId()).and(row.g("badge_id").eq(badge.getId()))).delete().run(connection);
                        iterator.remove();
                    });
                }
            }
        }
    });
}
Also used : User(net.dv8tion.jda.core.entities.User) HashMap(java.util.HashMap) Badge(tk.ardentbot.utils.rpg.profiles.Badge) Profile(tk.ardentbot.utils.rpg.profiles.Profile)

Example 4 with Badge

use of tk.ardentbot.utils.rpg.profiles.Badge in project Ardent by adamint.

the class UserUtils method hasTierOnePermissions.

public static boolean hasTierOnePermissions(User user) {
    String id = user.getId();
    boolean normalPermissions = isStaff(user) || tierOnepatrons.contains(id) || tierTwopatrons.contains(id) || tierThreepatrons.contains(id);
    if (!normalPermissions) {
        Profile profile = Profile.get(user);
        for (Badge badge : profile.getBadges()) {
            if (BadgesList.from(badge.getId()).getId().equalsIgnoreCase(BadgesList.PREMIUM_TRIAL.getId())) {
                return true;
            }
        }
        return false;
    } else
        return true;
}
Also used : Badge(tk.ardentbot.utils.rpg.profiles.Badge) Profile(tk.ardentbot.utils.rpg.profiles.Profile)

Aggregations

Badge (tk.ardentbot.utils.rpg.profiles.Badge)4 Profile (tk.ardentbot.utils.rpg.profiles.Profile)4 HashMap (java.util.HashMap)1 User (net.dv8tion.jda.core.entities.User)1