Search in sources :

Example 6 with TreeCommand

use of net.kodehawa.mantarobot.core.modules.commands.TreeCommand in project MantaroBot by Mantaro.

the class InfoCmds method about.

@Subscribe
public void about(CommandRegistry cr) {
    TreeCommand aboutCommand = (TreeCommand) cr.register("about", new TreeCommand(Category.INFO) {

        @Override
        public Command defaultTrigger(GuildMessageReceivedEvent event, String thisCommand, String attemptedSubCommand) {
            return new SubCommand() {

                @Override
                protected void call(GuildMessageReceivedEvent event, String content) {
                    SnowflakeCacheView<Guild> guilds = MantaroBot.getInstance().getGuildCache();
                    SnowflakeCacheView<User> users = MantaroBot.getInstance().getUserCache();
                    SnowflakeCacheView<TextChannel> textChannels = MantaroBot.getInstance().getTextChannelCache();
                    SnowflakeCacheView<VoiceChannel> voiceChannels = MantaroBot.getInstance().getVoiceChannelCache();
                    event.getChannel().sendMessage(new EmbedBuilder().setColor(Color.PINK).setAuthor("About Mantaro", "http://is.gd/mantaro", event.getJDA().getSelfUser().getEffectiveAvatarUrl()).setThumbnail(event.getJDA().getSelfUser().getEffectiveAvatarUrl()).setDescription("Hello, I'm **MantaroBot**! I'm here to make your life a little easier. To get started, type `~>help`!\n" + "Some of my features include:\n" + "\u2713 **Moderation made easy** (``Mass kick/ban, prune commands, logs and more!``)\n" + "\u2713 **Funny and useful commands**, see `~>help anime` or `~>help hug` for examples.\n" + "\u2713 **First quality music**, check out `~>help play` for example!.\n" + "\u2713 **[Support server](https://discordapp.com/invite/cMTmuPa)! |" + " [Support Mantaro development!](https://www.patreon.com/mantaro)**\n\n" + EmoteReference.POPPER + "Check ~>about credits!" + (MantaroData.config().get().isPremiumBot() ? "\nRunning a Patreon Bot instance, thanks you for your support! \u2764" : "")).addField("MantaroBot Version", MantaroInfo.VERSION, false).addField("Uptime", Utils.getHumanizedTime(ManagementFactory.getRuntimeMXBean().getUptime()), false).addField("Shards", String.valueOf(MantaroBot.getInstance().getShardedMantaro().getTotalShards()), true).addField("Threads", String.format("%,d", Thread.activeCount()), true).addField("Servers", String.format("%,d", guilds.size()), true).addField("Users (Unique)", String.format("%,d", users.stream().mapToLong(ISnowflake::getIdLong).distinct().count()), true).addField("Text Channels", String.format("%,d", textChannels.size()), true).addField("Voice Channels", String.format("%,d", voiceChannels.size()), true).setFooter(String.format("Invite link: http://is.gd/mantaro (Commands this session: %,d | Current shard: %d)", CommandListener.getCommandTotalInt(), MantaroBot.getInstance().getShardForGuild(event.getGuild().getId()).getId() + 1), event.getJDA().getSelfUser().getEffectiveAvatarUrl()).build()).queue();
                }
            };
        }

        @Override
        public MessageEmbed help(GuildMessageReceivedEvent event) {
            return helpEmbed(event, "About Command").setDescription("**Read info about Mantaro!**").addField("Information", "`~>about credits` - **Lists everyone who has helped on the bot's development**, " + "`~>about patreon` - **Lists our patreon supporters**", false).setColor(Color.PINK).build();
        }
    });
    aboutCommand.addSubCommand("patreon", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            Guild mantaroGuild = MantaroBot.getInstance().getGuildById("213468583252983809");
            String donators = mantaroGuild.getMembers().stream().filter(member -> member.getRoles().stream().filter(role -> role.getName().equals("Patron")).collect(Collectors.toList()).size() > 0).map(Member::getUser).map(user -> String.format("%s#%s", user.getName(), user.getDiscriminator())).collect(Collectors.joining("\n"));
            boolean hasReactionPerms = event.getGuild().getSelfMember().hasPermission(event.getChannel(), Permission.MESSAGE_ADD_REACTION);
            List<String> donatorList = DiscordUtils.divideString(300, donators);
            List<String> messages = new LinkedList<>();
            for (String s1 : donatorList) {
                messages.add("**Mantaro's Patreon Pledgers**\n" + (hasReactionPerms ? "Use the arrow reactions to change pages. " : "Use &page >> and &page << to change pages and &cancel to end") + String.format("```%s```", s1));
            }
            messages.add("Thanks to **MrLar#8117** for a $1025 donation and many other people who has donated once via paypal.");
            if (hasReactionPerms) {
                DiscordUtils.list(event, 45, false, messages);
            } else {
                DiscordUtils.listText(event, 45, false, messages);
            }
        }
    });
    aboutCommand.addSubCommand("credits", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            EmbedBuilder builder = new EmbedBuilder();
            builder.setAuthor("Credits.", null, event.getJDA().getSelfUser().getEffectiveAvatarUrl()).setColor(Color.BLUE).setDescription(String.join("\n", "**Main developer**: Kodehawa#3457", "**Developer**: AdrianTodt#0722", "**Developer**: Natan#1289", "**Documentation**: MrLar#8117 & Yuvira#7832", "**Community Admin**: MrLar#8117", "**Grammar Nazi**: Desiree#3658")).addField("Special mentions", "Thanks to bots.discord.pw, Carbonitex and discordbots.org for helping us with increasing the bot's visibility.", false).setFooter("Much thanks to everyone above for helping make Mantaro better!", event.getJDA().getSelfUser().getEffectiveAvatarUrl());
            event.getChannel().sendMessage(builder.build()).queue();
        }
    });
}
Also used : SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) List(java.util.List) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Subscribe (com.google.common.eventbus.Subscribe)6 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)6 SubCommand (net.kodehawa.mantarobot.core.modules.commands.SubCommand)6 TreeCommand (net.kodehawa.mantarobot.core.modules.commands.TreeCommand)6 java.util (java.util)5 List (java.util.List)5 TimeUnit (java.util.concurrent.TimeUnit)5 Collectors (java.util.stream.Collectors)5 EmbedBuilder (net.dv8tion.jda.core.EmbedBuilder)5 CommandRegistry (net.kodehawa.mantarobot.core.CommandRegistry)5 Module (net.kodehawa.mantarobot.core.modules.Module)5 SimpleCommand (net.kodehawa.mantarobot.core.modules.commands.SimpleCommand)5 Category (net.kodehawa.mantarobot.core.modules.commands.base.Category)5 Command (net.kodehawa.mantarobot.core.modules.commands.base.Command)5 MantaroData (net.kodehawa.mantarobot.data.MantaroData)5 Utils (net.kodehawa.mantarobot.utils.Utils)5 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)5 StringUtils (br.com.brjdevs.java.utils.texts.StringUtils)4 java.awt (java.awt)4 ItemStack (net.kodehawa.mantarobot.commands.currency.item.ItemStack)4