dev shard test command.

This commit is contained in:
NovaFox161
2018-01-18 11:26:25 -06:00
parent d05a417a47
commit 31ea10e2eb

View File

@@ -78,6 +78,7 @@ public class DevCommand implements ICommand {
ci.getSubCommands().put("reload", "Logs out and then logs in every shard.");
ci.getSubCommands().put("shutdown", "Shuts down the bot application.");
ci.getSubCommands().put("eval", "Evaluates the given code.");
ci.getSubCommands().put("testShards", "Tests to make sure all shards respond.");
return ci;
}
@@ -133,6 +134,8 @@ public class DevCommand implements ICommand {
case "eval":
moduleEval(event);
break;
case "testshards":
moduleTestShards(event);
default:
Message.sendMessage("Invalid sub command! Use `!help dev` to view valid sub commands!", event);
break;
@@ -333,6 +336,17 @@ public class DevCommand implements ICommand {
ApplicationHandler.exitApplication();
}
private void moduleTestShards(MessageReceivedEvent event) {
Message.sendMessage("Testing shard responses...", event);
StringBuilder r = new StringBuilder();
for (IShard s : Main.client.getShards()) {
r.append(s.getInfo()[0]).append(": ").append(s.isReady()).append("\n");
}
Message.sendMessage(r.toString(), event);
}
private long botPercent(IGuild g) {
return g.getUsers().stream().filter(IUser::isBot).count() * 100 / g.getTotalMemberCount();
}