Search in sources :

Example 1 with Category

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

the class InfoCmds method stats.

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

        @Override
        public Command defaultTrigger(GuildMessageReceivedEvent event, String currentCommand, String attemptedCommand) {
            return new SubCommand() {

                @Override
                protected void call(GuildMessageReceivedEvent event, String content) {
                    if (content.isEmpty()) {
                        event.getChannel().sendMessage(EmoteReference.MEGA + "**[Stats]** Y-Yeah... gathering them, hold on for a bit...").queue(message -> {
                            GuildStatsManager.MILESTONE = (((int) (MantaroBot.getInstance().getGuildCache().size() + 99) / 100) * 100) + 100;
                            List<Guild> guilds = MantaroBot.getInstance().getGuilds();
                            List<VoiceChannel> voiceChannels = MantaroBot.getInstance().getVoiceChannels();
                            List<VoiceChannel> musicChannels = voiceChannels.parallelStream().filter(vc -> vc.getMembers().contains(vc.getGuild().getSelfMember())).collect(Collectors.toList());
                            IntSummaryStatistics usersPerGuild = calculateInt(guilds, value -> value.getMembers().size());
                            IntSummaryStatistics onlineUsersPerGuild = calculateInt(guilds, value -> (int) value.getMembers().stream().filter(member -> !member.getOnlineStatus().equals(OnlineStatus.OFFLINE)).count());
                            DoubleSummaryStatistics onlineUsersPerUserPerGuild = calculateDouble(guilds, value -> (double) value.getMembers().stream().filter(member -> !member.getOnlineStatus().equals(OnlineStatus.OFFLINE)).count() / (double) value.getMembers().size() * 100);
                            DoubleSummaryStatistics listeningUsersPerUsersPerGuilds = calculateDouble(musicChannels, value -> (double) value.getMembers().size() / (double) value.getGuild().getMembers().size() * 100);
                            DoubleSummaryStatistics listeningUsersPerOnlineUsersPerGuilds = calculateDouble(musicChannels, value -> (double) value.getMembers().size() / (double) value.getGuild().getMembers().stream().filter(member -> !member.getOnlineStatus().equals(OnlineStatus.OFFLINE)).count() * 100);
                            IntSummaryStatistics textChannelsPerGuild = calculateInt(guilds, value -> value.getTextChannels().size());
                            IntSummaryStatistics voiceChannelsPerGuild = calculateInt(guilds, value -> value.getVoiceChannels().size());
                            int musicConnections = (int) voiceChannels.stream().filter(voiceChannel -> voiceChannel.getMembers().contains(voiceChannel.getGuild().getSelfMember())).count();
                            long exclusiveness = MantaroBot.getInstance().getGuildCache().stream().filter(g -> g.getMembers().stream().filter(member -> member.getUser().isBot()).count() == 1).count();
                            double musicConnectionsPerServer = (double) musicConnections / (double) guilds.size() * 100;
                            double exclusivenessPercent = (double) exclusiveness / (double) guilds.size() * 100;
                            long bigGuilds = MantaroBot.getInstance().getGuildCache().stream().filter(g -> g.getMembers().size() > 500).count();
                            message.editMessage(new EmbedBuilder().setColor(Color.PINK).setAuthor("Mantaro Statistics", "https://github.com/Kodehawa/MantaroBot/", event.getJDA().getSelfUser().getAvatarUrl()).setThumbnail(event.getJDA().getSelfUser().getAvatarUrl()).setDescription("Well... I did my math!").addField("Users per Guild", String.format(Locale.ENGLISH, "Min: %d\nAvg: %.1f\nMax: %d", usersPerGuild.getMin(), usersPerGuild.getAverage(), usersPerGuild.getMax()), true).addField("Online Users per Server", String.format(Locale.ENGLISH, "Min: %d\nAvg: %.1f\nMax: %d", onlineUsersPerGuild.getMin(), onlineUsersPerGuild.getAverage(), onlineUsersPerGuild.getMax()), true).addField("Online Users per Users per Server", String.format(Locale.ENGLISH, "Min: %.1f%%\nAvg: %.1f%%\nMax: %.1f%%", onlineUsersPerUserPerGuild.getMin(), onlineUsersPerUserPerGuild.getAverage(), onlineUsersPerUserPerGuild.getMax()), true).addField("Text Channels per Server", String.format(Locale.ENGLISH, "Min: %d\nAvg: %.1f\nMax: %d", textChannelsPerGuild.getMin(), textChannelsPerGuild.getAverage(), textChannelsPerGuild.getMax()), true).addField("Voice Channels per Server", String.format(Locale.ENGLISH, "Min: %d\nAvg: %.1f\nMax: %d", voiceChannelsPerGuild.getMin(), voiceChannelsPerGuild.getAverage(), voiceChannelsPerGuild.getMax()), true).addField("Music Listeners per Users per Server", String.format(Locale.ENGLISH, "Min: %.1f%%\nAvg: %.1f%%\nMax: %.1f%%", listeningUsersPerUsersPerGuilds.getMin(), listeningUsersPerUsersPerGuilds.getAverage(), listeningUsersPerUsersPerGuilds.getMax()), true).addField("Music Listeners per Online Users per Server", String.format(Locale.ENGLISH, "Min: %.1f%%\nAvg: %.1f%%\nMax: %.1f%%", listeningUsersPerOnlineUsersPerGuilds.getMin(), listeningUsersPerOnlineUsersPerGuilds.getAverage(), listeningUsersPerOnlineUsersPerGuilds.getMax()), true).addField("Music Connections per Server", String.format(Locale.ENGLISH, "%.1f%% (%d Connections)", musicConnectionsPerServer, musicConnections), true).addField("Total queue size", Long.toString(MantaroBot.getInstance().getAudioManager().getTotalQueueSize()), true).addField("Total commands (including custom)", String.valueOf(DefaultCommandProcessor.REGISTRY.commands().size()), true).addField("Exclusiveness in Total Servers", Math.round(exclusivenessPercent) + "% (" + exclusiveness + ")", false).addField("Big Servers", String.valueOf(bigGuilds), true).setFooter("! Guilds to next milestone (" + GuildStatsManager.MILESTONE + "): " + (GuildStatsManager.MILESTONE - MantaroBot.getInstance().getGuildCache().size()), event.getJDA().getSelfUser().getAvatarUrl()).build()).override(true).queue();
                            TextChannelGround.of(event).dropItemWithChance(4, 5);
                        });
                    } else {
                        onError(event);
                    }
                }
            };
        }

        @Override
        public MessageEmbed help(GuildMessageReceivedEvent event) {
            return helpEmbed(event, "Statistics command").setDescription("**See the bot, usage or vps statistics**").addField("Usage", "`~>stats <usage/server/cmds/guilds>` - **Returns statistical information**", true).build();
        }
    });
    statsCommand.addSubCommand("usage", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            event.getChannel().sendMessage(new EmbedBuilder().setAuthor("Mantaro's usage information", null, "https://puu.sh/sMsVC/576856f52b.png").setDescription("Hardware and usage information.").setThumbnail("https://puu.sh/suxQf/e7625cd3cd.png").addField("Threads:", getThreadCount() + " Threads", true).addField("Memory Usage:", getTotalMemory() - getFreeMemory() + "MB/" + getMaxMemory() + "MB", true).addField("CPU Cores:", getAvailableProcessors() + " Cores", true).addField("CPU Usage:", String.format("%.2f", getVpsCPUUsage()) + "%", true).addField("Assigned Memory:", getTotalMemory() + "MB", true).addField("Remaining from assigned:", getFreeMemory() + "MB", true).build()).queue();
            TextChannelGround.of(event).dropItemWithChance(4, 5);
        }
    });
    statsCommand.addSubCommand("server", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            TextChannelGround.of(event).dropItemWithChance(4, 5);
            EmbedBuilder embedBuilder = new EmbedBuilder().setAuthor("Mantaro's server usage information", null, "https://puu.sh/sMsVC/576856f52b.png").setThumbnail("https://puu.sh/suxQf/e7625cd3cd.png").addField("CPU Usage", String.format("%.2f", getVpsCPUUsage()) + "%", true).addField("RAM (TOTAL/FREE/USED)", String.format("%.2f", getVpsMaxMemory()) + "GB/" + String.format("%.2f", getVpsFreeMemory()) + "GB/" + String.format("%.2f", getVpsUsedMemory()) + "GB", false);
            event.getChannel().sendMessage(embedBuilder.build()).queue();
        }
    });
    statsCommand.addSubCommand("cmds", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            String[] args = content.split(" ");
            if (args.length > 0) {
                String what = args[0];
                if (what.equals("total")) {
                    event.getChannel().sendMessage(commandStatsManager.fillEmbed(CommandStatsManager.TOTAL_CMDS, baseEmbed(event, "Command Stats | Total")).build()).queue();
                    return;
                }
                if (what.equals("daily")) {
                    event.getChannel().sendMessage(commandStatsManager.fillEmbed(CommandStatsManager.DAY_CMDS, baseEmbed(event, "Command Stats | Daily")).build()).queue();
                    return;
                }
                if (what.equals("hourly")) {
                    event.getChannel().sendMessage(commandStatsManager.fillEmbed(CommandStatsManager.HOUR_CMDS, baseEmbed(event, "Command Stats | Hourly")).build()).queue();
                    return;
                }
                if (what.equals("now")) {
                    event.getChannel().sendMessage(commandStatsManager.fillEmbed(CommandStatsManager.MINUTE_CMDS, baseEmbed(event, "Command Stats | Now")).build()).queue();
                    return;
                }
            }
            // Default
            event.getChannel().sendMessage(baseEmbed(event, "Command Stats").addField("Now", commandStatsManager.resume(CommandStatsManager.MINUTE_CMDS), false).addField("Hourly", commandStatsManager.resume(CommandStatsManager.HOUR_CMDS), false).addField("Daily", commandStatsManager.resume(CommandStatsManager.DAY_CMDS), false).addField("Total", commandStatsManager.resume(CommandStatsManager.TOTAL_CMDS), false).build()).queue();
        }
    });
    statsCommand.addSubCommand("guilds", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            String[] args = content.split(" ");
            if (args.length > 0) {
                String what = args[0];
                if (what.equals("total")) {
                    event.getChannel().sendMessage(guildStatsManager.fillEmbed(GuildStatsManager.TOTAL_EVENTS, baseEmbed(event, "Guild Stats | Total")).build()).queue();
                    return;
                }
                if (what.equals("daily")) {
                    event.getChannel().sendMessage(guildStatsManager.fillEmbed(GuildStatsManager.DAY_EVENTS, baseEmbed(event, "Guild Stats | Daily")).build()).queue();
                    return;
                }
                if (what.equals("hourly")) {
                    event.getChannel().sendMessage(guildStatsManager.fillEmbed(GuildStatsManager.HOUR_EVENTS, baseEmbed(event, "Guild Stats | Hourly")).build()).queue();
                    return;
                }
                if (what.equals("now")) {
                    event.getChannel().sendMessage(guildStatsManager.fillEmbed(GuildStatsManager.MINUTE_EVENTS, baseEmbed(event, "Guild Stats | Now")).build()).queue();
                    return;
                }
            }
            // Default
            event.getChannel().sendMessage(baseEmbed(event, "Guild Stats").addField("Now", guildStatsManager.resume(GuildStatsManager.MINUTE_EVENTS), false).addField("Hourly", guildStatsManager.resume(GuildStatsManager.HOUR_EVENTS), false).addField("Daily", guildStatsManager.resume(GuildStatsManager.DAY_EVENTS), false).addField("Total", guildStatsManager.resume(GuildStatsManager.TOTAL_EVENTS), false).setFooter("Guilds: " + MantaroBot.getInstance().getGuildCache().size(), null).build()).queue();
        }
    });
    statsCommand.addSubCommand("category", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            String[] args = content.split(" ");
            if (args.length > 0) {
                String what = args[0];
                if (what.equals("total")) {
                    event.getChannel().sendMessage(categoryStatsManager.fillEmbed(CategoryStatsManager.TOTAL_CATS, baseEmbed(event, "Category Stats | Total")).build()).queue();
                    return;
                }
                if (what.equals("daily")) {
                    event.getChannel().sendMessage(categoryStatsManager.fillEmbed(CategoryStatsManager.DAY_CATS, baseEmbed(event, "Category Stats | Daily")).build()).queue();
                    return;
                }
                if (what.equals("hourly")) {
                    event.getChannel().sendMessage(categoryStatsManager.fillEmbed(CategoryStatsManager.HOUR_CATS, baseEmbed(event, "Category Stats | Hourly")).build()).queue();
                    return;
                }
                if (what.equals("now")) {
                    event.getChannel().sendMessage(categoryStatsManager.fillEmbed(CategoryStatsManager.MINUTE_CATS, baseEmbed(event, "Category Stats | Now")).build()).queue();
                    return;
                }
            }
            // Default
            event.getChannel().sendMessage(baseEmbed(event, "Category Stats").addField("Now", categoryStatsManager.resume(CategoryStatsManager.MINUTE_CATS), false).addField("Hourly", categoryStatsManager.resume(CategoryStatsManager.HOUR_CATS), false).addField("Daily", categoryStatsManager.resume(CategoryStatsManager.DAY_CATS), false).addField("Total", categoryStatsManager.resume(CategoryStatsManager.TOTAL_CATS), false).build()).queue();
        }
    });
    statsCommand.addSubCommand("custom", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            event.getChannel().sendMessage(customCommandStatsManager.fillEmbed(CustomCommandStatsManager.TOTAL_CUSTOM_CMDS, baseEmbed(event, "CCS Stats | Total")).build()).queue();
        }
    });
    statsCommand.addSubCommand("game", new SubCommand() {

        @Override
        protected void call(GuildMessageReceivedEvent event, String content) {
            event.getChannel().sendMessage(baseEmbed(event, "Game Stats").setDescription(gameStatsManager.resume(GameStatsManager.TOTAL_GAMES)).build()).queue();
        }
    });
}
Also used : MantaroInfo(net.kodehawa.mantarobot.MantaroInfo) Module(net.kodehawa.mantarobot.core.modules.Module) java.util(java.util) DefaultCommandProcessor(net.kodehawa.mantarobot.core.processor.DefaultCommandProcessor) Command(net.kodehawa.mantarobot.core.modules.commands.base.Command) Utils(net.kodehawa.mantarobot.utils.Utils) DiscordUtils(net.kodehawa.mantarobot.utils.DiscordUtils) MantaroBot(net.kodehawa.mantarobot.MantaroBot) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Permission(net.dv8tion.jda.core.Permission) CommandRegistry(net.kodehawa.mantarobot.core.CommandRegistry) SnowflakeCacheView(net.dv8tion.jda.core.utils.cache.SnowflakeCacheView) Subscribe(com.google.common.eventbus.Subscribe) SimpleCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleCommand) net.kodehawa.mantarobot.commands.info.stats.manager(net.kodehawa.mantarobot.commands.info.stats.manager) SimpleFileDataManager(net.kodehawa.mantarobot.utils.data.SimpleFileDataManager) ManagementFactory(java.lang.management.ManagementFactory) TextChannelGround(net.kodehawa.mantarobot.commands.currency.TextChannelGround) CommandListener(net.kodehawa.mantarobot.core.listeners.command.CommandListener) SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) net.dv8tion.jda.core.entities(net.dv8tion.jda.core.entities) Category(net.kodehawa.mantarobot.core.modules.commands.base.Category) AsyncInfoMonitor(net.kodehawa.mantarobot.commands.info.AsyncInfoMonitor) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) Collectors(java.util.stream.Collectors) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) OnlineStatus(net.dv8tion.jda.core.OnlineStatus) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) java.awt(java.awt) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) CommandPermission(net.kodehawa.mantarobot.core.modules.commands.base.CommandPermission) StatsHelper.calculateInt(net.kodehawa.mantarobot.commands.info.stats.StatsHelper.calculateInt) BLUE_SMALL_MARKER(net.kodehawa.mantarobot.utils.commands.EmoteReference.BLUE_SMALL_MARKER) GuildData(net.kodehawa.mantarobot.db.entities.helpers.GuildData) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) DateTimeFormatter(java.time.format.DateTimeFormatter) MantaroData(net.kodehawa.mantarobot.data.MantaroData) HelpUtils.forType(net.kodehawa.mantarobot.commands.info.HelpUtils.forType) StatsHelper.calculateDouble(net.kodehawa.mantarobot.commands.info.stats.StatsHelper.calculateDouble) SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) EmbedBuilder(net.dv8tion.jda.core.EmbedBuilder) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) Subscribe(com.google.common.eventbus.Subscribe)

Example 2 with Category

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

the class CommandOptions method onRegister.

@Subscribe
public void onRegister(OptionRegistryEvent e) {
    // region disallow
    registerOption("server:command:disallow", "Command disallow", "Disallows a command from being triggered at all. Use the command name\n" + "**Example:** `~>opts server command disallow 8ball`", "Disallows a command from being triggered at all.", (event, args) -> {
        if (args.length == 0) {
            onHelp(event);
            return;
        }
        String commandName = args[0];
        if (DefaultCommandProcessor.REGISTRY.commands().get(commandName) == null) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "No command called " + commandName).queue();
            return;
        }
        if (commandName.equals("opts") || commandName.equals("help")) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You cannot disable the options or the help command.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        guildData.getDisabledCommands().add(commandName);
        event.getChannel().sendMessage(EmoteReference.MEGA + "Disabled " + commandName + " on this server.").queue();
        dbGuild.saveAsync();
    });
    // endregion
    // region allow
    registerOption("server:command:allow", "Command allow", "Allows a command from being triggered. Use the command name\n" + "**Example:** `~>opts server command allow 8ball`", "Allows a command from being triggered.", (event, args) -> {
        if (args.length == 0) {
            onHelp(event);
            return;
        }
        String commandName = args[0];
        if (DefaultCommandProcessor.REGISTRY.commands().get(commandName) == null) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "No command called " + commandName).queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        guildData.getDisabledCommands().remove(commandName);
        event.getChannel().sendMessage(EmoteReference.MEGA + "Enabled " + commandName + " on this server.").queue();
        dbGuild.saveAsync();
    });
    // endregion
    // region specific
    registerOption("server:command:specific:disallow", "Specific command disallow", "Disallows a command from being triggered at all in a specific channel. Use the channel **name** and command name\n" + "**Example:** `~>opts server command specific disallow general 8ball`", "Disallows a command from being triggered at all in a specific channel.", (event, args) -> {
        if (args.length == 0) {
            onHelp(event);
            return;
        }
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify the channel name and the command to disallow!").queue();
            return;
        }
        String channelName = args[0];
        String commandName = args[1];
        if (DefaultCommandProcessor.REGISTRY.commands().get(commandName) == null) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "No command called " + commandName).queue();
            return;
        }
        if (commandName.equals("opts") || commandName.equals("help")) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You cannot disable the options or the help command.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        TextChannel channel = Utils.findChannel(event, channelName);
        if (channel == null)
            return;
        String id = channel.getId();
        guildData.getChannelSpecificDisabledCommands().computeIfAbsent(id, k -> new ArrayList<>());
        guildData.getChannelSpecificDisabledCommands().get(id).add(commandName);
        event.getChannel().sendMessage(EmoteReference.MEGA + "Disabled " + commandName + " on channel #" + channel.getName() + ".").queue();
        dbGuild.saveAsync();
    });
    registerOption("server:command:specific:allow", "Specific command allow", "Re-allows a command from being triggered in a specific channel. Use the channel **name** and command name\n" + "**Example:** `~>opts server command specific allow general 8ball`", "Re-allows a command from being triggered in a specific channel.", ((event, args) -> {
        if (args.length == 0) {
            onHelp(event);
            return;
        }
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify the channel name and the command to disallow!").queue();
            return;
        }
        String channelName = args[0];
        String commandName = args[1];
        if (DefaultCommandProcessor.REGISTRY.commands().get(commandName) == null) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "No command called " + commandName).queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        TextChannel channel = Utils.findChannel(event, channelName);
        if (channel == null)
            return;
        String id = channel.getId();
        guildData.getChannelSpecificDisabledCommands().computeIfAbsent(id, k -> new ArrayList<>());
        guildData.getChannelSpecificDisabledCommands().get(id).remove(commandName);
        event.getChannel().sendMessage(EmoteReference.MEGA + "Enabled " + commandName + " on channel #" + channel.getName() + ".").queue();
        dbGuild.saveAsync();
    }));
    // endregion
    // region channel
    // region disallow
    registerOption("server:channel:disallow", "Channel disallow", "Disallows a channel from commands. Use the channel **name**\n" + "**Example:** `~>opts server channel disallow general`", "Disallows a channel from commands.", (event, args) -> {
        if (args.length == 0) {
            onHelp(event);
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        if (args[0].equals("*")) {
            Set<String> allChannelsMinusCurrent = event.getGuild().getTextChannels().stream().filter(textChannel -> textChannel.getId().equals(event.getChannel().getId())).map(ISnowflake::getId).collect(Collectors.toSet());
            guildData.getDisabledChannels().addAll(allChannelsMinusCurrent);
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.CORRECT + "Disallowed all channels except the current one. " + "You can start allowing channels one by one again with `opts server channel allow` from **this** channel. " + "You can disallow this channel later if you so desire.").queue();
            return;
        }
        if ((guildData.getDisabledChannels().size() + 1) >= event.getGuild().getTextChannels().size()) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You cannot disable more channels since the bot wouldn't be able to talk otherwise :<").queue();
            return;
        }
        Consumer<TextChannel> consumer = textChannel -> {
            guildData.getDisabledChannels().add(textChannel.getId());
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.OK + "Channel " + textChannel.getAsMention() + " will not longer listen to commands").queue();
        };
        TextChannel channel = Utils.findChannelSelect(event, args[0], consumer);
        if (channel != null) {
            consumer.accept(channel);
        }
    });
    // endregion
    // region allow
    registerOption("server:channel:allow", "Channel allow", "Allows a channel from commands. Use the channel **name**\n" + "**Example:** `~>opts server channel allow general`", "Re-allows a channel from commands.", (event, args) -> {
        if (args.length == 0) {
            onHelp(event);
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        if (args[0].equals("*")) {
            guildData.getDisabledChannels().clear();
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.CORRECT + "All channels are allowed now.").queue();
            return;
        }
        Consumer<TextChannel> consumer = textChannel -> {
            guildData.getDisabledChannels().remove(textChannel.getId());
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.OK + "Channel " + textChannel.getAsMention() + " will now listen to commands").queue();
        };
        TextChannel channel = Utils.findChannelSelect(event, args[0], consumer);
        if (channel != null) {
            consumer.accept(channel);
        }
    });
    // endregion
    // endregion
    // region category
    registerOption("category:disable", "Disable categories", "Disables a specified category.\n" + "If a non-valid category it's specified, it will display a list of valid categories\n" + "You need the category name, for example ` ~>opts category disable Action`", "Disables a specified category", (event, args) -> {
        if (args.length == 0) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify a category to disable.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        Category toDisable = Category.lookupFromString(args[0]);
        if (toDisable == null) {
            AtomicInteger at = new AtomicInteger();
            event.getChannel().sendMessage(EmoteReference.ERROR + "You entered a invalid category. A list of valid categories to disable (case-insensitive) will be shown below" + "```md\n" + Category.getAllNames().stream().map(name -> "#" + at.incrementAndGet() + ". " + name).collect(Collectors.joining("\n")) + "```").queue();
            return;
        }
        if (guildData.getDisabledCategories().contains(toDisable)) {
            event.getChannel().sendMessage(EmoteReference.WARNING + "This category is already disabled.").queue();
            return;
        }
        if (toDisable.toString().equals("Moderation")) {
            event.getChannel().sendMessage(EmoteReference.WARNING + "You cannot disable moderation since it contains this command.").queue();
            return;
        }
        guildData.getDisabledCategories().add(toDisable);
        dbGuild.save();
        event.getChannel().sendMessage(EmoteReference.CORRECT + "Disabled category `" + toDisable.toString() + "`").queue();
    });
    registerOption("category:enable", "Enable categories", "Enables a specified category.\n" + "If a non-valid category it's specified, it will display a list of valid categories\n" + "You need the category name, for example ` ~>opts category enable Action`", "Enables a specified category", (event, args) -> {
        if (args.length == 0) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify a category to disable.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        Category toEnable = Category.lookupFromString(args[0]);
        if (toEnable == null) {
            AtomicInteger at = new AtomicInteger();
            event.getChannel().sendMessage(EmoteReference.ERROR + "You entered a invalid category. A list of valid categories to disable (case-insensitive) will be shown below" + "```md\n" + Category.getAllNames().stream().map(name -> "#" + at.incrementAndGet() + ". " + name).collect(Collectors.joining("\n")) + "```").queue();
            return;
        }
        guildData.getDisabledCategories().remove(toEnable);
        dbGuild.save();
        event.getChannel().sendMessage(EmoteReference.CORRECT + "Enabled category `" + toEnable.toString() + "`").queue();
    });
    // region specific
    registerOption("category:specific:disable", "Disable categories on a specific channel", "Disables a specified category on a specific channel.\n" + "If a non-valid category it's specified, it will display a list of valid categories\n" + "You need the category name and the channel name, for example ` ~>opts category specific disable Action general`", "Disables a specified category", (event, args) -> {
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify a category to disable and the channel where.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        Category toDisable = Category.lookupFromString(args[0]);
        String channelName = args[1];
        Consumer<TextChannel> consumer = selectedChannel -> {
            if (toDisable == null) {
                AtomicInteger at = new AtomicInteger();
                event.getChannel().sendMessage(EmoteReference.ERROR + "You entered a invalid category. A list of valid categories to disable (case-insensitive) will be shown below" + "```md\n" + Category.getAllNames().stream().map(name -> "#" + at.incrementAndGet() + ". " + name).collect(Collectors.joining("\n")) + "```").queue();
                return;
            }
            guildData.getChannelSpecificDisabledCategories().computeIfAbsent(selectedChannel.getId(), uwu -> new ArrayList<>());
            if (guildData.getChannelSpecificDisabledCategories().get(selectedChannel.getId()).contains(toDisable)) {
                event.getChannel().sendMessage(EmoteReference.WARNING + "This category is already disabled.").queue();
                return;
            }
            if (toDisable.toString().equals("Moderation")) {
                event.getChannel().sendMessage(EmoteReference.WARNING + "You cannot disable moderation since it contains this command.").queue();
                return;
            }
            guildData.getChannelSpecificDisabledCategories().get(selectedChannel.getId()).add(toDisable);
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.CORRECT + "Disabled category `" + toDisable.toString() + "` on channel " + selectedChannel.getAsMention()).queue();
        };
        TextChannel channel = Utils.findChannelSelect(event, channelName, consumer);
        if (channel != null) {
            consumer.accept(channel);
        }
    });
    registerOption("category:specific:enable", "Enable categories on a specific channel", "Enables a specified category on a specific channel.\n" + "If a non-valid category it's specified, it will display a list of valid categories\n" + "You need the category name and the channel name, for example ` ~>opts category specific enable Action general`", "Enables a specified category", (event, args) -> {
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify a category to disable and the channel where.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        Category toEnable = Category.lookupFromString(args[0]);
        String channelName = args[1];
        Consumer<TextChannel> consumer = selectedChannel -> {
            if (toEnable == null) {
                AtomicInteger at = new AtomicInteger();
                event.getChannel().sendMessage(EmoteReference.ERROR + "You entered a invalid category. A list of valid categories to disable (case-insensitive) will be shown below" + "```md\n" + Category.getAllNames().stream().map(name -> "#" + at.incrementAndGet() + ". " + name).collect(Collectors.joining("\n")) + "```").queue();
                return;
            }
            if (selectedChannel == null) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "That's not a valid channel!").queue();
                return;
            }
            List l = guildData.getChannelSpecificDisabledCategories().computeIfAbsent(selectedChannel.getId(), uwu -> new ArrayList<>());
            if (l.isEmpty() || !l.contains(toEnable)) {
                event.getChannel().sendMessage(EmoteReference.THINKING + "This category wasn't disabled?").queue();
                return;
            }
            guildData.getChannelSpecificDisabledCategories().get(selectedChannel.getId()).remove(toEnable);
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.CORRECT + "Enabled category `" + toEnable.toString() + "` on channel " + selectedChannel.getAsMention()).queue();
        };
        TextChannel channel = Utils.findChannelSelect(event, channelName, consumer);
        if (channel != null) {
            consumer.accept(channel);
        }
    });
    // endregion
    // endregion
    registerOption("server:role:specific:disallow", "Disallows a role from executing an specific command", "Disallows a role from executing an specific command\n" + "This command takes the command to disallow and the role name afterwards. If the role name contains spaces, wrap it in quotes \"like this\"\n" + "Example: `~>opts server role specific disallow daily Member`", "Disallows a role from executing an specific command", (event, args) -> {
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need the role and the command to disallow!").queue();
            return;
        }
        String commandDisallow = args[0];
        String roleDisallow = args[1];
        Consumer<Role> consumer = role -> {
            DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
            GuildData guildData = dbGuild.getData();
            if (!DefaultCommandProcessor.REGISTRY.commands().containsKey(commandDisallow)) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "That command doesn't exist!").queue();
                return;
            }
            if (commandDisallow.equals("opts") || commandDisallow.equals("help")) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "You cannot disable the options or the help command.").queue();
                return;
            }
            guildData.getRoleSpecificDisabledCommands().computeIfAbsent(role.getId(), key -> new ArrayList<>());
            if (guildData.getRoleSpecificDisabledCommands().get(role.getId()).contains(commandDisallow)) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "This command was already disabled for the specified role.").queue();
                return;
            }
            guildData.getRoleSpecificDisabledCommands().get(role.getId()).add(commandDisallow);
            dbGuild.save();
            event.getChannel().sendMessage(String.format("%sSuccessfully restricted command `%s` for role `%s`", EmoteReference.CORRECT, commandDisallow, role.getName())).queue();
        };
        Role role = Utils.findRoleSelect(event, roleDisallow, consumer);
        if (role != null) {
            consumer.accept(role);
        }
    });
    registerOption("server:role:specific:allow", "Allows a role from executing an specific command", "Allows a role from executing an specific command\n" + "This command takes either the role name, id or mention and the command to disallow afterwards. If the role name contains spaces, wrap it in quotes \"like this\"\n" + "Example: `~>opts server role specific allow daily Member`", "Allows a role from executing an specific command", (event, args) -> {
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need the role and the command to allow!").queue();
            return;
        }
        String commandAllow = args[0];
        String roleAllow = args[1];
        Consumer<Role> consumer = role -> {
            if (role == null) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "That's not a valid role!").queue();
                return;
            }
            DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
            GuildData guildData = dbGuild.getData();
            if (!DefaultCommandProcessor.REGISTRY.commands().containsKey(commandAllow)) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "That command doesn't exist!").queue();
                return;
            }
            List l = guildData.getRoleSpecificDisabledCommands().computeIfAbsent(role.getId(), key -> new ArrayList<>());
            if (l.isEmpty() || !l.contains(commandAllow)) {
                event.getChannel().sendMessage(EmoteReference.THINKING + "This command wasn't disabled for this role?").queue();
                return;
            }
            guildData.getRoleSpecificDisabledCommands().get(role.getId()).remove(commandAllow);
            dbGuild.save();
            event.getChannel().sendMessage(String.format("%sSuccessfully un-restricted command `%s` for role `%s`", EmoteReference.CORRECT, commandAllow, role.getName())).queue();
        };
        Role role = Utils.findRoleSelect(event, roleAllow, consumer);
        if (role != null) {
            consumer.accept(role);
        }
    });
    registerOption("category:role:specific:disable", "Disables a role from executing commands in an specified category.", "Disables a role from executing commands in an specified category\n" + "This command takes the category name and the role to disable afterwards. If the role name contains spaces, wrap it in quotes \"like this\"\n" + "Example: `~>opts category role specific disable Currency Member`", "Disables a role from executing commands in an specified category.", (event, args) -> {
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify a category to disable and the role to.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        Category toDisable = Category.lookupFromString(args[0]);
        String roleName = args[1];
        Consumer<Role> consumer = role -> {
            if (toDisable == null) {
                AtomicInteger at = new AtomicInteger();
                event.getChannel().sendMessage(EmoteReference.ERROR + "You entered a invalid category. A list of valid categories to disable (case-insensitive) will be shown below" + "```md\n" + Category.getAllNames().stream().map(name -> "#" + at.incrementAndGet() + ". " + name).collect(Collectors.joining("\n")) + "```").queue();
                return;
            }
            guildData.getRoleSpecificDisabledCategories().computeIfAbsent(role.getId(), cat -> new ArrayList<>());
            if (guildData.getRoleSpecificDisabledCategories().get(role.getId()).contains(toDisable)) {
                event.getChannel().sendMessage(EmoteReference.WARNING + "This category is already disabled.").queue();
                return;
            }
            if (toDisable.toString().equals("Moderation")) {
                event.getChannel().sendMessage(EmoteReference.WARNING + "You cannot disable moderation since it contains this command.").queue();
                return;
            }
            guildData.getRoleSpecificDisabledCategories().get(role.getId()).add(toDisable);
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.CORRECT + "Disabled category `" + toDisable.toString() + "` for role " + role.getName()).queue();
        };
        Role role = Utils.findRoleSelect(event, roleName, consumer);
        if (role != null) {
            consumer.accept(role);
        }
    });
    registerOption("category:role:specific:enable", "Enables a role from executing commands in an specified category.", "Enables a role from executing commands in an specified category\n" + "This command takes the category name and the role to enable afterwards. If the role name contains spaces, wrap it in quotes \"like this\"\n" + "Example: `~>opts category role specific enable Currency Member`", "Enables a role from executing commands in an specified category.", (event, args) -> {
        if (args.length < 2) {
            event.getChannel().sendMessage(EmoteReference.ERROR + "You need to specify a category to disable and the channel where.").queue();
            return;
        }
        DBGuild dbGuild = MantaroData.db().getGuild(event.getGuild());
        GuildData guildData = dbGuild.getData();
        Category toEnable = Category.lookupFromString(args[0]);
        String roleName = args[1];
        Consumer<Role> consumer = role -> {
            if (toEnable == null) {
                AtomicInteger at = new AtomicInteger();
                event.getChannel().sendMessage(EmoteReference.ERROR + "You entered a invalid category. A list of valid categories to disable (case-insensitive) will be shown below" + "```md\n" + Category.getAllNames().stream().map(name -> "#" + at.incrementAndGet() + ". " + name).collect(Collectors.joining("\n")) + "```").queue();
                return;
            }
            if (role == null) {
                event.getChannel().sendMessage(EmoteReference.ERROR + "That's not a valid role!").queue();
                return;
            }
            List l = guildData.getRoleSpecificDisabledCategories().computeIfAbsent(role.getId(), cat -> new ArrayList<>());
            if (l.isEmpty() || !l.contains(toEnable)) {
                event.getChannel().sendMessage(EmoteReference.THINKING + "This category wasn't disabled?").queue();
                return;
            }
            guildData.getRoleSpecificDisabledCategories().get(role.getId()).remove(toEnable);
            dbGuild.save();
            event.getChannel().sendMessage(EmoteReference.CORRECT + "Enabled category `" + toEnable.toString() + "` for role " + role.getName()).queue();
        };
        Role role = Utils.findRoleSelect(event, roleName, consumer);
        if (role != null) {
            consumer.accept(role);
        }
    });
}
Also used : Role(net.dv8tion.jda.core.entities.Role) DefaultCommandProcessor(net.kodehawa.mantarobot.core.processor.DefaultCommandProcessor) TextChannel(net.dv8tion.jda.core.entities.TextChannel) Category(net.kodehawa.mantarobot.core.modules.commands.base.Category) Option(net.kodehawa.mantarobot.options.annotations.Option) Utils(net.kodehawa.mantarobot.utils.Utils) Set(java.util.Set) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) Consumer(java.util.function.Consumer) List(java.util.List) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ISnowflake(net.dv8tion.jda.core.entities.ISnowflake) GuildData(net.kodehawa.mantarobot.db.entities.helpers.GuildData) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) MantaroData(net.kodehawa.mantarobot.data.MantaroData) Subscribe(com.google.common.eventbus.Subscribe) OptionType(net.kodehawa.mantarobot.options.core.OptionType) OptionRegistryEvent(net.kodehawa.mantarobot.options.event.OptionRegistryEvent) OptionHandler(net.kodehawa.mantarobot.options.core.OptionHandler) GuildData(net.kodehawa.mantarobot.db.entities.helpers.GuildData) Category(net.kodehawa.mantarobot.core.modules.commands.base.Category) ArrayList(java.util.ArrayList) Role(net.dv8tion.jda.core.entities.Role) TextChannel(net.dv8tion.jda.core.entities.TextChannel) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ArrayList(java.util.ArrayList) List(java.util.List) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with Category

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

the class CommandRegistry method process.

// BEWARE OF INSTANCEOF CALLS
// I know there are better approaches to this, THIS IS JUST A WORKAROUND, DON'T TRY TO REPLICATE THIS.
public boolean process(GuildMessageReceivedEvent event, String cmdName, String content) {
    long start = System.currentTimeMillis();
    Command command = commands.get(cmdName);
    if (command == null) {
        command = commands.get(cmdName.toLowerCase());
        if (command == null)
            return false;
    }
    // Variable used in lambda expression should be final or effectively final...
    final Command cmd = command;
    if (MantaroData.db().getMantaroData().getBlackListedUsers().contains(event.getAuthor().getId())) {
        return false;
    }
    DBGuild dbg = MantaroData.db().getGuild(event.getGuild());
    GuildData data = dbg.getData();
    if (data.getDisabledCommands().contains(cmd instanceof AliasCommand ? ((AliasCommand) cmd).getOriginalName() : cmdName)) {
        return false;
    }
    List<String> channelDisabledCommands = data.getChannelSpecificDisabledCommands().get(event.getChannel().getId());
    if (channelDisabledCommands != null && channelDisabledCommands.contains(cmd instanceof AliasCommand ? ((AliasCommand) cmd).getOriginalName() : cmdName)) {
        return false;
    }
    if (data.getDisabledUsers().contains(event.getAuthor().getId()) && !isAdmin(event.getMember())) {
        return false;
    }
    if (data.getDisabledChannels().contains(event.getChannel().getId()) && (cmd instanceof AliasCommand ? ((AliasCommand) cmd).parentCategory() != Category.MODERATION : cmd.category() != Category.MODERATION)) {
        return false;
    }
    if (conf.isPremiumBot() && (cmd instanceof AliasCommand ? ((AliasCommand) cmd).parentCategory() == Category.CURRENCY : cmd.category() == Category.CURRENCY)) {
        return false;
    }
    if (data.getDisabledCategories().contains(cmd instanceof AliasCommand ? ((AliasCommand) cmd).parentCategory() : cmd.category())) {
        return false;
    }
    if (data.getChannelSpecificDisabledCategories().computeIfAbsent(event.getChannel().getId(), c -> new ArrayList<>()).contains(cmd instanceof AliasCommand ? ((AliasCommand) cmd).parentCategory() : cmd.category())) {
        return false;
    }
    if (!data.getDisabledRoles().isEmpty() && event.getMember().getRoles().stream().anyMatch(r -> data.getDisabledRoles().contains(r.getId())) && !isAdmin(event.getMember())) {
        return false;
    }
    HashMap<String, List<String>> roleSpecificDisabledCommands = data.getRoleSpecificDisabledCommands();
    if (event.getMember().getRoles().stream().anyMatch(r -> roleSpecificDisabledCommands.computeIfAbsent(r.getId(), s -> new ArrayList<>()).contains(cmd instanceof AliasCommand ? ((AliasCommand) cmd).getOriginalName() : cmdName)) && !isAdmin(event.getMember())) {
        return false;
    }
    HashMap<String, List<Category>> roleSpecificDisabledCategories = data.getRoleSpecificDisabledCategories();
    if (event.getMember().getRoles().stream().anyMatch(r -> roleSpecificDisabledCategories.computeIfAbsent(r.getId(), s -> new ArrayList<>()).contains(cmd instanceof AliasCommand ? ((AliasCommand) cmd).parentCategory() : cmd.category())) && !isAdmin(event.getMember())) {
        return false;
    }
    // If we are in the patreon bot, deny all requests from unknown guilds.
    if (conf.isPremiumBot() && !conf.isOwner(event.getAuthor()) && !dbg.isPremium()) {
        event.getChannel().sendMessage(EmoteReference.ERROR + "Seems like you're trying to use the Patreon bot when this guild is **not** marked as premium. " + "**If you think this is an error please contact Kodehawa#3457 or poke me on #donators in the support guild**").queue();
        return false;
    }
    if (!cmd.permission().test(event.getMember())) {
        event.getChannel().sendMessage(EmoteReference.STOP + "You have no permissions to trigger this command :(").queue();
        return false;
    }
    long end = System.currentTimeMillis();
    MantaroBot.getInstance().getStatsClient().increment("commands");
    log.debug("Command invoked: {}, by {}#{} with timestamp {}", cmdName, event.getAuthor().getName(), event.getAuthor().getDiscriminator(), new Date(System.currentTimeMillis()));
    cmd.run(event, cmdName, content);
    if (cmd.category() != null && cmd.category().name() != null && !cmd.category().name().isEmpty()) {
        MantaroBot.getInstance().getStatsClient().increment("command", "name:" + cmdName);
        MantaroBot.getInstance().getStatsClient().increment("category", "name:" + cmd.category().name().toLowerCase());
        CommandStatsManager.log(cmdName);
        CategoryStatsManager.log(cmd.category().name().toLowerCase());
    }
    MantaroBot.getInstance().getStatsClient().histogram("command_process_time", (end - start));
    return true;
}
Also used : SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) java.util(java.util) Command(net.kodehawa.mantarobot.core.modules.commands.base.Command) Member(net.dv8tion.jda.core.entities.Member) SimpleTreeCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleTreeCommand) Category(net.kodehawa.mantarobot.core.modules.commands.base.Category) CategoryStatsManager(net.kodehawa.mantarobot.commands.info.stats.manager.CategoryStatsManager) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) MantaroBot(net.kodehawa.mantarobot.MantaroBot) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) Slf4j(lombok.extern.slf4j.Slf4j) GuildMessageReceivedEvent(net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent) CommandPermission(net.kodehawa.mantarobot.core.modules.commands.base.CommandPermission) GuildData(net.kodehawa.mantarobot.db.entities.helpers.GuildData) EmoteReference(net.kodehawa.mantarobot.utils.commands.EmoteReference) MantaroData(net.kodehawa.mantarobot.data.MantaroData) Preconditions(com.google.common.base.Preconditions) CommandStatsManager(net.kodehawa.mantarobot.commands.info.stats.manager.CommandStatsManager) Config(net.kodehawa.mantarobot.data.Config) AliasCommand(net.kodehawa.mantarobot.core.modules.commands.AliasCommand) GuildData(net.kodehawa.mantarobot.db.entities.helpers.GuildData) AliasCommand(net.kodehawa.mantarobot.core.modules.commands.AliasCommand) DBGuild(net.kodehawa.mantarobot.db.entities.DBGuild) SubCommand(net.kodehawa.mantarobot.core.modules.commands.SubCommand) Command(net.kodehawa.mantarobot.core.modules.commands.base.Command) SimpleTreeCommand(net.kodehawa.mantarobot.core.modules.commands.SimpleTreeCommand) TreeCommand(net.kodehawa.mantarobot.core.modules.commands.TreeCommand) AliasCommand(net.kodehawa.mantarobot.core.modules.commands.AliasCommand)

Aggregations

Category (net.kodehawa.mantarobot.core.modules.commands.base.Category)3 MantaroData (net.kodehawa.mantarobot.data.MantaroData)3 DBGuild (net.kodehawa.mantarobot.db.entities.DBGuild)3 GuildData (net.kodehawa.mantarobot.db.entities.helpers.GuildData)3 EmoteReference (net.kodehawa.mantarobot.utils.commands.EmoteReference)3 Subscribe (com.google.common.eventbus.Subscribe)2 java.util (java.util)2 List (java.util.List)2 Collectors (java.util.stream.Collectors)2 GuildMessageReceivedEvent (net.dv8tion.jda.core.events.message.guild.GuildMessageReceivedEvent)2 MantaroBot (net.kodehawa.mantarobot.MantaroBot)2 DefaultCommandProcessor (net.kodehawa.mantarobot.core.processor.DefaultCommandProcessor)2 Utils (net.kodehawa.mantarobot.utils.Utils)2 Preconditions (com.google.common.base.Preconditions)1 java.awt (java.awt)1 ManagementFactory (java.lang.management.ManagementFactory)1 DateTimeFormatter (java.time.format.DateTimeFormatter)1 ArrayList (java.util.ArrayList)1 Set (java.util.Set)1 TimeUnit (java.util.concurrent.TimeUnit)1