use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class LoggingSetupStage method stepText.
@Override
public void stepText(CommandObject command) {
// check if logging is enabled, otherwise skip:
if (!command.guild.config.moduleLogging) {
logger.trace("module " + new ModuleLogging().name() + " is not enabled. Skipping step");
SetupHandler.setSetupStage(command, SetupStage.getNextStage(command.guild.config.setupStage));
}
// do some message initialization
StringHandler output = new StringHandler();
output.append("We are moving on to setting up modules. The first one that needs to be configured is the Logging module");
output.append("\nThis module can be used to extend and enhance the basic Audit Log used by Discord.");
output.append("\n\nFirst part of this, I will need a couple of channels to use. One for general logging, and one for admin logging.");
output.append("\n*Admin Logging* is messages and events related to server configuration and user moderation.");
output.append("\n*General Logging* is all of the logging that doesn't fit under admin logging, such as new member joins, message edits and deletes, general command usage, etc.");
output.append("\n\nI am going to quickly scan your channels to see if I can find potential channels you might want to use...");
if (!checkForGeneralLog(command)) {
output.append("\nThere weren't any channels that I could see for general logging, checking if you have any for admin logging...");
if (!checkForAdminLog(command)) {
output.append("\nI didn't find any channels that could be used. You'll have to tell me which ones you want me to use");
} else {
// will ask for general channel thingers only...
}
}
RequestHandler.sendMessage(output.toString(), command.channel);
}
use of com.github.vaerys.handlers.StringHandler in project DiscordSailv2 by Vaerys-Dawn.
the class BotStats method execute.
@Override
public String execute(String args, CommandObject command) {
List<Double> cpuUsage = TimerHandler.cpuUsage;
long freeMemory = Runtime.getRuntime().freeMemory();
long totalMemory = Runtime.getRuntime().totalMemory();
long usedMemory = totalMemory - freeMemory;
long userCount = command.client.get().getUsers().size();
double usage = cpuUsage.stream().mapToDouble(value -> value).sum() / cpuUsage.size();
// and make it look pretty
NumberFormat nf = NumberFormat.getInstance();
long ping = command.client.get().getShards().get(0).getResponseTime();
double mb = 1048576.0;
XEmbedBuilder builder = new XEmbedBuilder(command);
builder.withTitle(command.client.bot.username);
builder.withTimestamp(command.client.bot.get().getCreationDate());
builder.withFooterText("Creation Date");
StringHandler handler = new StringHandler();
handler.append("**Total Servers**: ").append(command.client.get().getGuilds().size());
handler.append(indent + "**Total Users**: " + userCount);
handler.append("\n**Total Active Threads**: ").append(Thread.activeCount());
handler.append("\n**CPU Usage**: ").append(nf.format(usage * 100)).append("%");
handler.append("\n**Memory Usage**: ");
nf.setMaximumFractionDigits(1);
handler.append(nf.format(totalMemory / mb)).append("MB total\t");
handler.append(nf.format(usedMemory / mb)).append("MB used\t");
handler.append(nf.format(freeMemory / mb)).append("MB free");
handler.append("\n**Ping**: ").append(nf.format(ping)).append("ms");
builder.withDesc(handler.toString());
builder.withThumbnail(command.client.bot.getAvatarURL());
builder.send(command.channel);
return null;
}
use of com.github.vaerys.handlers.StringHandler 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;
}
Aggregations