Search in sources :

Example 1 with Badge

use of net.kodehawa.mantarobot.commands.currency.profile.Badge in project MantaroBot by Mantaro.

the class OwnerCmd method badge.

@Subscribe
public void badge(CommandRegistry cr) {
    cr.register("addbadge", new SimpleCommand(Category.OWNER, CommandPermission.OWNER) {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
            if (event.getMessage().getMentionedUsers().isEmpty()) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You need to give me an user to apply the badge to!").queue();
                return;
            }
            if (args.length != 2) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "Wrong args length").queue();
                return;
            }
            String b = args[1];
            List<User> users = event.getMessage().getMentionedUsers();
            Badge badge = Badge.lookupFromString(b);
            if (badge == null) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "No badge with that enum name! Valid badges: " + Arrays.stream(Badge.values()).map(b1 -> "`" + b1.name() + "`").collect(Collectors.joining(" ,"))).queue();
                return;
            }
            for (User u : users) {
                Player p = MantaroData.db().getPlayer(u);
                p.getData().addBadgeIfAbsent(badge);
                p.saveAsync();
            }
            event.getChannel().sendMessage(EmoteReference.CORRECT + "Added badge " + badge + " to " + users.stream().map(User::getName).collect(Collectors.joining(" ,"))).queue();
        }

        @Override
        public MessageEmbed help(GuildMessageReceivedEvent event) {
            return null;
        }
    });
    cr.register("removebadge", new SimpleCommand(Category.OWNER, CommandPermission.OWNER) {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content, String[] args) {
            if (event.getMessage().getMentionedUsers().isEmpty()) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You need to give me an user to remove the badge from!").queue();
                return;
            }
            if (args.length != 2) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "Wrong args length").queue();
                return;
            }
            String b = args[1];
            List<User> users = event.getMessage().getMentionedUsers();
            Badge badge = Badge.lookupFromString(b);
            if (badge == null) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "No badge with that enum name! Valid badges: " + Arrays.stream(Badge.values()).map(b1 -> "`" + b1.name() + "`").collect(Collectors.joining(" ,"))).queue();
                return;
            }
            for (User u : users) {
                Player p = MantaroData.db().getPlayer(u);
                p.getData().removeBadge(badge);
                p.saveAsync();
            }
            event.getChannel().sendMessage(String.format("%sRemoved badge %s from %s", EmoteReference.CORRECT, badge, users.stream().map(User::getName).collect(Collectors.joining(" ,")))).queue();
        }

        @Override
        public MessageEmbed help(GuildMessageReceivedEvent event) {
            return null;
        }
    });
}
Also used : Badge(net.kodehawa.mantarobot.commands.currency.profile.Badge) Module(net.kodehawa.mantarobot.core.modules.Module) java.util(java.util) PlayerData(net.kodehawa.mantarobot.db.entities.helpers.PlayerData) CompilationException(com.github.natanbc.javaeval.CompilationException) MantaroBot(net.kodehawa.mantarobot.MantaroBot) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) CommandRegistry(net.kodehawa.mantarobot.core.CommandRegistry) DBUser(net.kodehawa.mantarobot.db.entities.DBUser) Subscribe(com.google.common.eventbus.Subscribe) SimpleCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleCommand) JavaEvaluator(com.github.natanbc.javaeval.JavaEvaluator) MessageEmbed(net.dv8tion.jda.core.entities.MessageEmbed) Player(net.kodehawa.mantarobot.db.entities.Player) Interpreter(bsh.Interpreter) InteractiveOperations(net.kodehawa.mantarobot.core.listeners.operations.InteractiveOperations) Category(net.kodehawa.mantarobot.core.modules.commands.base.Category) SPLIT_PATTERN(net.kodehawa.mantarobot.utils.StringUtils.SPLIT_PATTERN) CompilationResult(com.github.natanbc.javaeval.CompilationResult) ScriptEngineManager(javax.script.ScriptEngineManager) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) Collectors(java.util.stream.Collectors) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) User(net.dv8tion.jda.core.entities.User) CommandPermission(net.kodehawa.mantarobot.core.modules.commands.base.CommandPermission) MantaroObj(net.kodehawa.mantarobot.db.entities.MantaroObj) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) ScriptEngine(javax.script.ScriptEngine) MantaroData(net.kodehawa.mantarobot.data.MantaroData) Operation(net.kodehawa.mantarobot.core.listeners.operations.core.Operation) Player(net.kodehawa.mantarobot.db.entities.Player) DBUser(net.kodehawa.mantarobot.db.entities.DBUser) User(net.dv8tion.jda.core.entities.User) MessageEmbed(net.dv8tion.jda.core.entities.MessageEmbed) SimpleCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleCommand) List(java.util.List) Badge(net.kodehawa.mantarobot.commands.currency.profile.Badge) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with Badge

use of net.kodehawa.mantarobot.commands.currency.profile.Badge in project MantaroBot by Mantaro.

the class PlayerCmds method badges.

@Subscribe
public void badges(CommandRegistry cr) {
    final Random r = new Random();
    ITreeCommand badgeCommand = (ITreeCommand) cr.register("badges", new TreeCommand(Category.CURRENCY) {

        @Override
        public Command defaultTrigger(GuildMessageReceivedEvent event, String mainCommand, String commandName) {
            return new SubCommand() {

                @Override
                protected void call(GuildMessageReceivedEvent event, String content) {
                    Map<String, Optional<String>> t = StringUtils.parse(content.isEmpty() ? new String[] {} : content.split("\\s+"));
                    content = Utils.replaceArguments(t, content, "brief");
                    Member member = Utils.findMember(event, event.getMember(), content);
                    if (member == null)
                        return;
                    User toLookup = member.getUser();
                    Player player = MantaroData.db().getPlayer(toLookup);
                    PlayerData playerData = player.getData();
                    if (!t.isEmpty() && t.containsKey("brief")) {
                        event.getChannel().sendMessage(String.format("**%s's badges:**\n%s", member.getEffectiveName(), playerData.getBadges().stream().map(b -> "*" + b.display + "*").collect(Collectors.joining(", ")))).queue();
                        return;
                    }
                    List<Badge> badges = playerData.getBadges();
                    Collections.sort(badges);
                    // Show the message that tells the person that they can get a free badge for upvoting mantaro one out of 3 times they use this command.
                    // The message stops appearing when they upvote.
                    String toShow = "If you think you got a new badge and it doesn't appear here, please use `~>profile` and then run this command again.\n" + "Use `~>badges info <badge name>` to get more information about a badge.\n" + ((r.nextInt(3) == 0 && !playerData.hasBadge(Badge.UPVOTER) ? "**You can get a free badge for " + "[up-voting Mantaro on discordbots.org](https://discordbots.org/bot/mantaro)!** (It might take some minutes to process)\n\n" : "\n")) + badges.stream().map(badge -> String.format("**%s:** *%s*", badge, badge.description)).collect(Collectors.joining("\n"));
                    if (toShow.isEmpty())
                        toShow = "No badges to show (yet!)";
                    List<String> parts = DiscordUtils.divideString(MessageEmbed.TEXT_MAX_LENGTH, toShow);
                    DiscordUtils.list(event, 30, false, (current, max) -> new EmbedBuilder().setAuthor("Badges achieved by " + toLookup.getName()).setColor(event.getMember().getColor() == null ? Color.PINK : event.getMember().getColor()).setThumbnail(toLookup.getEffectiveAvatarUrl()), parts);
                }
            };
        }

        @Override
        public MessageEmbed help(GuildMessageReceivedEvent event) {
            return helpEmbed(event, "Badge list").setDescription("**Shows your (or another person)'s badges**\n" + "If you want to check out the badges of another person just mention them.\n" + "`~>badges info <name>` - Shows info about a badge.\n" + "You can use `~>badges -brief` to get a brief versions of the badge showcase.").build();
        }
    });
    badgeCommand.addSubCommand("info", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            if (content.isEmpty()) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify a badge to see the info of.").queue();
                return;
            }
            Badge badge = Badge.lookupFromString(content);
            if (badge == null) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "There's no such badge...").queue();
                return;
            }
            Player p = MantaroData.db().getPlayer(event.getAuthor());
            Message message = new MessageBuilder().setEmbed(new EmbedBuilder().setAuthor("Badge information for " + badge.display).setDescription(String.join("\n", EmoteReference.BLUE_SMALL_MARKER + "**Name:** " + badge.display, EmoteReference.BLUE_SMALL_MARKER + "**Description:** " + badge.description, EmoteReference.BLUE_SMALL_MARKER + "**Achieved:** " + p.getData().getBadges().stream().anyMatch(b -> b == badge))).setThumbnail("attachment://icon.png").setColor(Color.CYAN).build()).build();
            event.getChannel().sendFile(badge.icon, "icon.png", message).queue();
        }
    });
}
Also used : Items(net.kodehawa.mantarobot.commands.currency.item.Items) Badge(net.kodehawa.mantarobot.commands.currency.profile.Badge) MantaroInfo(net.kodehawa.mantarobot.MantaroInfo) Module(net.kodehawa.mantarobot.core.modules.Module) java.util(java.util) Command(net.kodehawa.mantarobot.core.modules.commands.base.Command) PlayerData(net.kodehawa.mantarobot.db.entities.helpers.PlayerData) Utils(net.kodehawa.mantarobot.utils.Utils) RateLimiter(net.kodehawa.mantarobot.utils.commands.RateLimiter) DiscordUtils(net.kodehawa.mantarobot.utils.DiscordUtils) MantaroBot(net.kodehawa.mantarobot.MantaroBot) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) ITreeCommand(net.kodehawa.mantarobot.core.modules.commands.base.ITreeCommand) CommandRegistry(net.kodehawa.mantarobot.core.CommandRegistry) Utils.handleDefaultRatelimit(net.kodehawa.mantarobot.utils.Utils.handleDefaultRatelimit) DBUser(net.kodehawa.mantarobot.db.entities.DBUser) Inventory(net.kodehawa.mantarobot.db.entities.helpers.Inventory) Response(okhttp3.Response) StringUtils(br.com.brjdevs.java.utils.texts.StringUtils) Subscribe(com.google.common.eventbus.Subscribe) SimpleCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleCommand) ItemStack(net.kodehawa.mantarobot.commands.currency.item.ItemStack) ResponseBody(okhttp3.ResponseBody) Player(net.kodehawa.mantarobot.db.entities.Player) SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) Request(okhttp3.Request) UserData(net.kodehawa.mantarobot.db.entities.helpers.UserData) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) Category(net.kodehawa.mantarobot.core.modules.commands.base.Category) SPLIT_PATTERN(net.kodehawa.mantarobot.utils.StringUtils.SPLIT_PATTERN) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) OkHttpClient(okhttp3.OkHttpClient) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) MantaroData(net.kodehawa.mantarobot.data.MantaroData) FinderUtil(com.jagrosh.jdautilities.utils.FinderUtil) Player(net.kodehawa.mantarobot.db.entities.Player) SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) DBUser(net.kodehawa.mantarobot.db.entities.DBUser) Badge(net.kodehawa.mantarobot.commands.currency.profile.Badge) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) ITreeCommand(net.kodehawa.mantarobot.core.modules.commands.base.ITreeCommand) PlayerData(net.kodehawa.mantarobot.db.entities.helpers.PlayerData) ITreeCommand(net.kodehawa.mantarobot.core.modules.commands.base.ITreeCommand) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with Badge

use of net.kodehawa.mantarobot.commands.currency.profile.Badge in project MantaroBot by Mantaro.

the class PlayerCmds method profile.

@Subscribe
public void profile(CommandRegistry cr) {
    ITreeCommand profileCommand = (TreeCommand) cr.register("profile", new TreeCommand(Category.CURRENCY) {

        @Override
        public Command defaultTrigger(GuildMessageReceivedEvent event, String mainCommand, String commandName) {
            return new SubCommand() {

                @Override
                protected void call(GuildMessageReceivedEvent event, String content) {
                    User userLooked = event.getAuthor();
                    Player player = MantaroData.db().getPlayer(userLooked);
                    UserData user = MantaroData.db().getUser(event.getMember()).getData();
                    Member memberLooked = event.getMember();
                    List<Member> found = FinderUtil.findMembers(content, event.getGuild());
                    if (found.isEmpty() && !content.isEmpty()) {
                        event.getChannel().sendMessage(EmoteReference.ERROR + "Didn't find any member with your search criteria :(").queue();
                        return;
                    }
                    if (found.size() > 1 && !content.isEmpty()) {
                        event.getChannel().sendMessage(EmoteReference.THINKING + "Too many members found, maybe refine your search? (ex. use name#discriminator)\n" + "**Members found:** " + found.stream().map(m -> m.getUser().getName() + "#" + m.getUser().getDiscriminator()).collect(Collectors.joining(", "))).queue();
                        return;
                    }
                    if (found.size() == 1 && !content.isEmpty()) {
                        userLooked = found.get(0).getUser();
                        memberLooked = found.get(0);
                        if (userLooked.isBot()) {
                            event.getChannel().sendMessage(EmoteReference.ERROR + "Bots don't have profiles.").queue();
                            return;
                        }
                        user = MantaroData.db().getUser(userLooked).getData();
                        player = MantaroData.db().getPlayer(memberLooked);
                    }
                    User marriedTo = (player.getData().getMarriedWith() == null || player.getData().getMarriedWith().isEmpty()) ? null : MantaroBot.getInstance().getUserById(player.getData().getMarriedWith());
                    PlayerData playerData = player.getData();
                    Inventory inv = player.getInventory();
                    // start of badge assigning
                    Guild mh = MantaroBot.getInstance().getGuildById("213468583252983809");
                    Member mhMember = mh == null ? null : mh.getMemberById(memberLooked.getUser().getId());
                    boolean saveAfter = false;
                    if (player.getMoney() > 7526527671L && playerData.addBadgeIfAbsent(Badge.ALTERNATIVE_WORLD))
                        saveAfter = true;
                    if (MantaroData.config().get().isOwner(userLooked) && playerData.addBadgeIfAbsent(Badge.DEVELOPER))
                        saveAfter = true;
                    if (inv.asList().stream().anyMatch(stack -> stack.getAmount() == 5000) && playerData.addBadgeIfAbsent(Badge.SHOPPER))
                        saveAfter = true;
                    if (inv.asList().stream().anyMatch(stack -> stack.getItem().equals(Items.CHRISTMAS_TREE_SPECIAL) || stack.getItem().equals(Items.BELL_SPECIAL)) && playerData.addBadgeIfAbsent(Badge.CHRISTMAS))
                        saveAfter = true;
                    if (MantaroBot.getInstance().getShardedMantaro().getDiscordBotsUpvoters().contains(userLooked.getIdLong()) && playerData.addBadgeIfAbsent(Badge.UPVOTER))
                        saveAfter = true;
                    if (player.getLevel() >= 10 && playerData.addBadgeIfAbsent(Badge.WALKER))
                        saveAfter = true;
                    if (player.getLevel() >= 50 && playerData.addBadgeIfAbsent(Badge.RUNNER))
                        saveAfter = true;
                    if (player.getLevel() >= 100 && playerData.addBadgeIfAbsent(Badge.FAST_RUNNER))
                        saveAfter = true;
                    if (player.getLevel() >= 150 && playerData.addBadgeIfAbsent(Badge.MARATHON_RUNNER))
                        saveAfter = true;
                    if (player.getLevel() >= 200 && playerData.addBadgeIfAbsent(Badge.MARATHON_WINNER))
                        saveAfter = true;
                    if (playerData.getMarketUsed() > 1000 && playerData.addBadgeIfAbsent(Badge.COMPULSIVE_BUYER))
                        saveAfter = true;
                    if (mhMember != null && mhMember.getRoles().stream().anyMatch(r -> r.getIdLong() == 406920476259123201L) && playerData.addBadgeIfAbsent(Badge.HELPER_2))
                        saveAfter = true;
                    if (mhMember != null && mhMember.getRoles().stream().anyMatch(r -> r.getIdLong() == 290257037072531466L || r.getIdLong() == 290902183300431872L) && playerData.addBadgeIfAbsent(Badge.DONATOR_2))
                        saveAfter = true;
                    if (saveAfter)
                        player.saveAsync();
                    // end of badge assigning
                    List<Badge> badges = playerData.getBadges();
                    Collections.sort(badges);
                    String displayBadges = badges.stream().map(Badge::getUnicode).limit(5).collect(Collectors.joining("  "));
                    applyBadge(event.getChannel(), badges.isEmpty() ? null : (playerData.getMainBadge() == null ? badges.get(0) : playerData.getMainBadge()), userLooked, baseEmbed(event, (marriedTo == null || !player.getInventory().containsItem(Items.RING) ? "" : EmoteReference.RING) + memberLooked.getEffectiveName() + "'s Profile", userLooked.getEffectiveAvatarUrl()).setThumbnail(userLooked.getEffectiveAvatarUrl()).setDescription((player.getData().isShowBadge() ? (badges.isEmpty() ? "" : String.format("**%s**\n", (playerData.getMainBadge() == null ? badges.get(0) : playerData.getMainBadge()))) : "") + (player.getData().getDescription() == null ? "No description set" : player.getData().getDescription())).addField(EmoteReference.DOLLAR + "Credits", "$ " + player.getMoney(), true).addField(EmoteReference.ZAP + "Level", player.getLevel() + " (Experience: " + player.getData().getExperience() + ")", true).addField(EmoteReference.REP + "Reputation", String.valueOf(player.getReputation()), true).addField(EmoteReference.POPPER + "Birthday", user.getBirthday() != null ? user.getBirthday().substring(0, 5) : "Not specified.", true).addField(EmoteReference.HEART + "Married with", marriedTo == null ? "Nobody." : marriedTo.getName() + "#" + marriedTo.getDiscriminator(), false).addField(EmoteReference.POUCH + "Inventory", ItemStack.toString(inv.asList()), false).addField(EmoteReference.HEART + "Top 5 Badges", displayBadges.isEmpty() ? "No badges (yet!)" : displayBadges, false).setFooter("User's timezone: " + (user.getTimezone() == null ? "No timezone set." : user.getTimezone()) + " | " + "Requested by " + event.getAuthor().getName(), null));
                }
            };
        }

        @Override
        public MessageEmbed help(GuildMessageReceivedEvent event) {
            return helpEmbed(event, "Profile command.").setDescription("**Retrieves your current user profile.**").addField("Usage", "- To retrieve your profile, `~>profile`\n" + "- To change your description do `~>profile description set <description>`\n" + "  -- To clear it, just do `~>profile description clear`\n" + "- To set your timezone do `~>profile timezone <timezone>`\n" + "- To set your display badge use `~>profile displaybadge` and `~>profile displaybadge reset` to reset it.\n" + "  -- You can also use `~>profile displaybadge none` to display no badge on your profile.\n" + "**The profile only shows the 5 most important badges!.** Use `~>badges` to get a complete list.", false).build();
        }
    });
    profileCommand.addSubCommand("timezone", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            DBUser dbUser = MantaroData.db().getUser(event.getAuthor());
            String[] args = content.split(" ");
            if (args.length < 1) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify the timezone.").queue();
                return;
            }
            String timezone = args[0];
            if (timezone.equalsIgnoreCase("reset")) {
                dbUser.getData().setTimezone(null);
                dbUser.saveAsync();
                event.getChannel().sendMessage(EmoteReference.CORRECT + "Reset timezone.").queue();
                return;
            }
            if (!Utils.isValidTimeZone(timezone)) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "Invalid timezone.").queue();
                return;
            }
            try {
                UtilsCmds.dateGMT(event.getGuild(), timezone);
            } catch (Exception e) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "Not a valid timezone.").queue();
                return;
            }
            dbUser.getData().setTimezone(timezone);
            dbUser.saveAsync();
            event.getChannel().sendMessage(String.format("%sSaved timezone, your profile timezone is now: **%s**", EmoteReference.CORRECT, timezone)).queue();
        }
    });
    profileCommand.addSubCommand("description", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            String[] args = content.split(" ");
            User author = event.getAuthor();
            Player player = MantaroData.db().getPlayer(author);
            if (args.length == 0) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You need to provide an argument! (set or remove)\n" + "for example, ~>profile description set Hi there!").queue();
                return;
            }
            if (args[0].equals("set")) {
                int MAX_LENGTH = 300;
                if (MantaroData.db().getUser(author).isPremium())
                    MAX_LENGTH = 500;
                String content1 = SPLIT_PATTERN.split(content, 2)[1];
                if (content1.length() > MAX_LENGTH) {
                    event.getChannel().sendMessage(EmoteReference.ERROR + "The description is too long! `(Limit of 300 characters for everyone and 500 for premium users)`").queue();
                    return;
                }
                player.getData().setDescription(content1);
                event.getChannel().sendMessage(EmoteReference.POPPER + "Set description to: **" + content1 + "**\n" + "Check your shiny new profile with `~>profile`").queue();
                player.save();
                return;
            }
            if (args[1].equals("clear")) {
                player.getData().setDescription(null);
                event.getChannel().sendMessage(EmoteReference.CORRECT + "Successfully cleared description.").queue();
                player.save();
            }
        }
    });
    profileCommand.addSubCommand("displaybadge", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            String[] args = content.split(" ");
            if (args.length == 0) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify your main badge!").queue();
                return;
            }
            Player player = MantaroData.db().getPlayer(event.getAuthor());
            PlayerData data = player.getData();
            if (args[0].equalsIgnoreCase("none")) {
                data.setShowBadge(false);
                event.getChannel().sendMessage(EmoteReference.CORRECT + "No badge will show on the top of your profile now!").queue();
                player.saveAsync();
                return;
            }
            if (args[0].equalsIgnoreCase("reset")) {
                data.setMainBadge(null);
                data.setShowBadge(true);
                event.getChannel().sendMessage(EmoteReference.CORRECT + "Your display badge is now the most important one.").queue();
                player.saveAsync();
                return;
            }
            Badge badge = Badge.lookupFromString(content);
            if (badge == null) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "There's no such badge...\n" + "Your available badges: " + player.getData().getBadges().stream().map(Badge::getDisplay).collect(Collectors.joining(", "))).queue();
                return;
            }
            if (!data.getBadges().contains(badge)) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You don't have that badge.\n" + "Your available badges: " + player.getData().getBadges().stream().map(Badge::getDisplay).collect(Collectors.joining(", "))).queue();
                return;
            }
            data.setShowBadge(true);
            data.setMainBadge(badge);
            player.saveAsync();
            event.getChannel().sendMessage(EmoteReference.CORRECT + "Your display badge is now: **" + badge.display + "**").queue();
        }
    });
}
Also used : Items(net.kodehawa.mantarobot.commands.currency.item.Items) Badge(net.kodehawa.mantarobot.commands.currency.profile.Badge) MantaroInfo(net.kodehawa.mantarobot.MantaroInfo) Module(net.kodehawa.mantarobot.core.modules.Module) java.util(java.util) Command(net.kodehawa.mantarobot.core.modules.commands.base.Command) PlayerData(net.kodehawa.mantarobot.db.entities.helpers.PlayerData) Utils(net.kodehawa.mantarobot.utils.Utils) RateLimiter(net.kodehawa.mantarobot.utils.commands.RateLimiter) DiscordUtils(net.kodehawa.mantarobot.utils.DiscordUtils) MantaroBot(net.kodehawa.mantarobot.MantaroBot) MessageBuilder(net.dv8tion.jda.core.MessageBuilder) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) ITreeCommand(net.kodehawa.mantarobot.core.modules.commands.base.ITreeCommand) CommandRegistry(net.kodehawa.mantarobot.core.CommandRegistry) Utils.handleDefaultRatelimit(net.kodehawa.mantarobot.utils.Utils.handleDefaultRatelimit) DBUser(net.kodehawa.mantarobot.db.entities.DBUser) Inventory(net.kodehawa.mantarobot.db.entities.helpers.Inventory) Response(okhttp3.Response) StringUtils(br.com.brjdevs.java.utils.texts.StringUtils) Subscribe(com.google.common.eventbus.Subscribe) SimpleCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleCommand) ItemStack(net.kodehawa.mantarobot.commands.currency.item.ItemStack) ResponseBody(okhttp3.ResponseBody) Player(net.kodehawa.mantarobot.db.entities.Player) SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) Request(okhttp3.Request) UserData(net.kodehawa.mantarobot.db.entities.helpers.UserData) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) Category(net.kodehawa.mantarobot.core.modules.commands.base.Category) SPLIT_PATTERN(net.kodehawa.mantarobot.utils.StringUtils.SPLIT_PATTERN) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) OkHttpClient(okhttp3.OkHttpClient) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) MantaroData(net.kodehawa.mantarobot.data.MantaroData) FinderUtil(com.jagrosh.jdautilities.utils.FinderUtil) Player(net.kodehawa.mantarobot.db.entities.Player) SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) DBUser(net.kodehawa.mantarobot.db.entities.DBUser) UserData(net.kodehawa.mantarobot.db.entities.helpers.UserData) Badge(net.kodehawa.mantarobot.commands.currency.profile.Badge) IOException(java.io.IOException) ITreeCommand(net.kodehawa.mantarobot.core.modules.commands.base.ITreeCommand) DBUser(net.kodehawa.mantarobot.db.entities.DBUser) PlayerData(net.kodehawa.mantarobot.db.entities.helpers.PlayerData) ITreeCommand(net.kodehawa.mantarobot.core.modules.commands.base.ITreeCommand) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Inventory(net.kodehawa.mantarobot.db.entities.helpers.Inventory) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)3 java.awt (java.awt)3 java.util (java.util)3 List (java.util.List)3 TimeUnit (java.util.concurrent.TimeUnit)3 Collectors (java.util.stream.Collectors)3 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)3 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)3 MantaroBot (net.kodehawa.mantarobot.MantaroBot)3 Badge (net.kodehawa.mantarobot.commands.currency.profile.Badge)3 CommandRegistry (net.kodehawa.mantarobot.core.CommandRegistry)3 Module (net.kodehawa.mantarobot.core.modules.Module)3 SimpleCommand (net.kodehawa.mantarobot.core.modules.commands.SimpleCommand)3 Category (net.kodehawa.mantarobot.core.modules.commands.base.Category)3 MantaroData (net.kodehawa.mantarobot.data.MantaroData)3 DBUser (net.kodehawa.mantarobot.db.entities.DBUser)3 Player (net.kodehawa.mantarobot.db.entities.Player)3 PlayerData (net.kodehawa.mantarobot.db.entities.helpers.PlayerData)3 SPLIT_PATTERN (net.kodehawa.mantarobot.utils.StringUtils.SPLIT_PATTERN)3 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)3