use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class LoggingSetupStage method checkForGeneralLog.
private boolean checkForGeneralLog(CommandObject command) {
IChannel channel = null;
StringHandler output = new StringHandler();
for (String s : serverLogChannelNames) {
List<IChannel> genLogChannel = command.guild.get().getChannelsByName(s);
if (genLogChannel.size() == 1) {
channel = genLogChannel.get(0);
break;
} else if (genLogChannel.size() > 1) {
output.append("I found multiple valid channels...").append("\nPick a channel from the list below: ```");
String format = "\n%s [%s]";
for (IChannel c : genLogChannel) {
output.appendFormatted(format, c.getName(), c.getLongID());
}
output.append("\n```").append("Respond with the ID of the channel you want to use.");
// handle this some special way
}
}
if (channel == null)
return false;
output.append("Do you want to use " + channel.getName() + " as the general log channel?");
RequestHandler.sendMessage(output.toString(), command.channel);
return true;
}
use of com.github.vaerys.handlers.StringHandler 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);
}
use of com.github.vaerys.handlers.StringHandler 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);
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class Utility method formatTimestamp.
public static String formatTimestamp(ZonedDateTime time) {
StringHandler content = new StringHandler();
content.append(time.getYear());
content.append("/").append(time.getMonthValue());
content.append("/").append(time.getDayOfMonth());
content.append(" - ").append(time.getHour());
content.append(":").append(time.getMinute());
content.append(":").append(time.getSecond());
return content.toString();
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class Utility method enumToString.
public static String enumToString(Enum<?> e) {
String enumValue = e.toString();
enumValue = enumValue.toLowerCase();
enumValue = enumValue.replace("_", " ");
String[] words = enumValue.split(" ");
StringHandler fixedEnum = new StringHandler();
for (String s : words) {
if (fixedEnum.toString().length() != 0) {
fixedEnum.append(" ");
}
fixedEnum.append(StringUtils.capitalize(s));
}
return fixedEnum.toString();
}
Aggregations