Search in sources :

Example 1 with HelpModules

use of com.github.vaerys.commands.help.HelpModules in project DiscordSailv2 by Vaerys-Dawn.

the class ModulesStage method stepText.

@Override
public void stepText(CommandObject command) {
    StringHandler output = new StringHandler();
    List<GuildToggle> modules = ToggleInit.getToggles(true);
    output.append("First things first. Obviously.\n");
    output.append("You're going to want to choose which modules you would like to use on your server.\n\n");
    output.append("**Here's a list of modules I have for you to choose from:**\n");
    String moduleItemFormat = "\t> **%s** - %s\n";
    modules.sort(Comparator.comparing(GuildToggle::toString));
    for (GuildToggle module : modules) {
        output.appendFormatted(moduleItemFormat, module.name(), module.shortDesc(command));
    }
    String toggleReminder = "\nYou can toggle a module on and off with the `%s` command.\nIf you want more detailed information about the module, you can use `%s`";
    output.appendFormatted(toggleReminder, new Module().getUsage(command), new HelpModules().getUsage(command));
    // RequestHandler.sendMessage(output.toString(), command.user.getDmChannel());
    XEmbedBuilder embed = new XEmbedBuilder(command);
    StringHandler enabled = new StringHandler();
    StringHandler disabled = new StringHandler();
    for (GuildToggle m : modules) {
        if (m.enabled(command.guild.config)) {
            enabled.append(m.name() + "\n");
        } else {
            disabled.append(m.name() + "\n");
        }
    }
    embed.withTitle("Here's the current list of enabled and disabled modules");
    embed.appendField("Enabled Modules", enabled.toString(), true);
    embed.appendField("Disabled Modules", disabled.toString(), true);
    // embed.send(command.user.getDmChannel());
    RequestHandler.sendEmbedMessage(output.toString(), embed, command.channel);
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) GuildToggle(com.github.vaerys.templates.GuildToggle) HelpModules(com.github.vaerys.commands.help.HelpModules) StringHandler(com.github.vaerys.handlers.StringHandler) Module(com.github.vaerys.commands.admin.Module)

Example 2 with HelpModules

use of com.github.vaerys.commands.help.HelpModules in project DiscordSailv2 by Vaerys-Dawn.

the class Toggle method getContent.

public String getContent(String args, CommandObject command, boolean isModule) {
    StringBuilder builder = new StringBuilder();
    if (!args.isEmpty()) {
        GuildToggle toggle = ToggleInit.getGuildToggle(args, isModule);
        if (toggle == null) {
            if (isModule) {
                builder.append("> Could not find Module \"" + args + "\".\n");
            } else {
                builder.append("> Could not find Setting \"" + args + "\".\n");
            }
        } else {
            toggle.toggle(command.guild.config);
            command.guild.loadCommandData();
            String mode = toggle.enabled(command.guild.config) ? "enabled" : "disabled";
            String type = toggle.isModule() ? "module" : "setting";
            String helpCommand = toggle.isModule() ? new HelpModules().getUsage(command) : new HelpSettings().getUsage(command);
            return "> **" + toggle.name() + "** is now **" + mode + "**.\n\n" + "To see more info about what this " + type + " " + mode + " you can run **" + helpCommand + "**.";
        }
    }
    XEmbedBuilder embedBuilder = new XEmbedBuilder(command);
    String modifier = isModule ? "Module" : "Setting";
    String title;
    title = "> Here are all of the available " + modifier + "s:\n";
    List<SAILType> typesActive = new LinkedList<>();
    List<SAILType> typesDeactivated = new LinkedList<>();
    for (GuildToggle t : command.guild.toggles) {
        if (t.isModule() == isModule) {
            if (t.enabled(command.guild.config))
                typesActive.add(t.name());
            else
                typesDeactivated.add(t.name());
        }
    }
    Collections.sort(typesActive);
    Collections.sort(typesDeactivated);
    embedBuilder.withTitle(title);
    StringHandler desc = new StringHandler();
    desc.append("**Activated**\n```\n" + spacer + Utility.listEnumFormatter(typesActive, true) + "```\n" + "**Deactivated**\n```\n" + spacer + Utility.listEnumFormatter(typesDeactivated, true) + "```\n");
    desc.append("The Command **");
    if (isModule) {
        desc.append(new HelpModules().getUsage(command));
    } else {
        desc.append(new HelpSettings().getUsage(command));
    }
    desc.append("** Can give you extra information about each of the above.\n\n");
    desc.append(missingArgs(command));
    embedBuilder.withDescription(desc.toString());
    RequestHandler.sendEmbedMessage("", embedBuilder, command.channel.get());
    return null;
}
Also used : XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) SAILType(com.github.vaerys.enums.SAILType) GuildToggle(com.github.vaerys.templates.GuildToggle) HelpModules(com.github.vaerys.commands.help.HelpModules) StringHandler(com.github.vaerys.handlers.StringHandler) HelpSettings(com.github.vaerys.commands.help.HelpSettings) LinkedList(java.util.LinkedList)

Aggregations

HelpModules (com.github.vaerys.commands.help.HelpModules)2 StringHandler (com.github.vaerys.handlers.StringHandler)2 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)2 GuildToggle (com.github.vaerys.templates.GuildToggle)2 Module (com.github.vaerys.commands.admin.Module)1 HelpSettings (com.github.vaerys.commands.help.HelpSettings)1 SAILType (com.github.vaerys.enums.SAILType)1 LinkedList (java.util.LinkedList)1