Search in sources :

Example 1 with DebugMode

use of com.github.vaerys.guildtoggles.toggles.DebugMode in project DiscordSailv2 by Vaerys-Dawn.

the class SettingsStage method stepText.

@Override
public void stepText(CommandObject command) {
    StringHandler output = new StringHandler();
    output.append("Next step is to pick which settings you want to use.\n").append("There's a lot of settings in modules, and those will be set there.\n").append("Here's a list of the settings that aren't tied to any specific module.\n");
    // Get the settings and modules.
    List<GuildToggle> globalToggles = ToggleInit.getToggles(false);
    List<GuildToggle> modules = ToggleInit.getToggles(true);
    // Sort settings
    globalToggles.sort(Comparator.comparing(GuildToggle::name));
    // Init additional vars
    List<String> enabled = new ArrayList<>();
    List<String> disabled = new ArrayList<>();
    String format = "\t> **%s** - %s\n";
    // skip debug mode after it's defaulted to off:
    if (!new DebugMode().getDefault()) {
        globalToggles.removeIf(t -> t.name() == SAILType.DEBUG_MODE);
    }
    // Filter toggles that are not part of modules.
    List<SAILType> types = new LinkedList<>();
    modules.forEach(t -> types.addAll(t.settings.stream().map(s -> s.name()).collect(Collectors.toList())));
    ListIterator iterator = globalToggles.listIterator();
    while (iterator.hasNext()) {
        GuildToggle toggle = (GuildToggle) iterator.next();
        if (types.contains(toggle.name())) {
            // Is part of a module, remove from list
            iterator.remove();
        } else {
            // is not, get extra information...
            if (toggle.enabled(command.guild.config))
                enabled.add(toggle.name().toString());
            else
                disabled.add(toggle.name().toString());
            // append to list of things.
            output.appendFormatted(format, toggle.name().toString(), toggle.shortDesc(command));
        }
    }
    // Send message
    output.append("\nYou can switch settings on and off with **" + Command.get(Toggle.class).getCommand(command) + "** and get more info on each setting with **" + Command.get(HelpSettings.class).getCommand(command) + "**.");
    // Append additional enabled/disabled state info.
    XEmbedBuilder embed = new XEmbedBuilder(command);
    embed.withTitle("Global Settings");
    embed.appendField("Enabled", "```" + Utility.listFormatter(enabled, true) + "```", false);
    embed.appendField("Disabled", "```" + Utility.listFormatter(disabled, true) + "```", false);
    RequestHandler.sendEmbedMessage(output.toString(), embed, command.channel);
}
Also used : ToggleInit(com.github.vaerys.guildtoggles.ToggleInit) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) java.util(java.util) CommandObject(com.github.vaerys.commands.CommandObject) HelpSettings(com.github.vaerys.commands.help.HelpSettings) DebugMode(com.github.vaerys.guildtoggles.toggles.DebugMode) RequestHandler(com.github.vaerys.handlers.RequestHandler) SAILType(com.github.vaerys.enums.SAILType) Toggle(com.github.vaerys.commands.admin.Toggle) SetupHandler(com.github.vaerys.handlers.SetupHandler) Collectors(java.util.stream.Collectors) GuildToggle(com.github.vaerys.templates.GuildToggle) StringHandler(com.github.vaerys.handlers.StringHandler) Command(com.github.vaerys.templates.Command) Utility(com.github.vaerys.main.Utility) XEmbedBuilder(com.github.vaerys.objects.XEmbedBuilder) GuildToggle(com.github.vaerys.templates.GuildToggle) DebugMode(com.github.vaerys.guildtoggles.toggles.DebugMode) StringHandler(com.github.vaerys.handlers.StringHandler) SAILType(com.github.vaerys.enums.SAILType)

Aggregations

CommandObject (com.github.vaerys.commands.CommandObject)1 Toggle (com.github.vaerys.commands.admin.Toggle)1 HelpSettings (com.github.vaerys.commands.help.HelpSettings)1 SAILType (com.github.vaerys.enums.SAILType)1 ToggleInit (com.github.vaerys.guildtoggles.ToggleInit)1 DebugMode (com.github.vaerys.guildtoggles.toggles.DebugMode)1 RequestHandler (com.github.vaerys.handlers.RequestHandler)1 SetupHandler (com.github.vaerys.handlers.SetupHandler)1 StringHandler (com.github.vaerys.handlers.StringHandler)1 Utility (com.github.vaerys.main.Utility)1 XEmbedBuilder (com.github.vaerys.objects.XEmbedBuilder)1 Command (com.github.vaerys.templates.Command)1 GuildToggle (com.github.vaerys.templates.GuildToggle)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1