use of ml.duncte123.skybot.objects.pairs.LongLongPair in project SkyBot by duncte123.
the class ShardInfoCommand method getConnectedVoiceChannels.
private LongLongPair getConnectedVoiceChannels(ShardManager shardManager) {
final AtomicLong connectedVC = new AtomicLong();
final AtomicLong listeningVC = new AtomicLong();
shardManager.getShardCache().forEach((jda) -> {
final LongLongPair shardStats = getConnectedVoiceChannels(jda);
connectedVC.addAndGet(shardStats.getFirst());
listeningVC.addAndGet(shardStats.getSecond());
});
return new LongLongPair(connectedVC.get(), listeningVC.get());
}
use of ml.duncte123.skybot.objects.pairs.LongLongPair in project SkyBot by duncte123.
the class ShardInfoCommand method embedTable.
private void embedTable(CommandContext ctx) {
final EmbedBuilder embedBuilder = new EmbedBuilder();
final int currentShard = ctx.getJDA().getShardInfo().getShardId();
final ShardManager shardManager = ctx.getJDA().getShardManager();
final ShardCacheView shardCache = shardManager.getShardCache();
final List<JDA> shards = new ArrayList<>(shardCache.asList());
Collections.reverse(shards);
for (final JDA shard : shards) {
final StringBuilder valueBuilder = new StringBuilder();
final LongLongPair channelStats = getConnectedVoiceChannels(shard);
valueBuilder.append("**Status:** ").append(getShardStatus(shard)).append("\n**Ping:** ").append(shard.getGatewayPing()).append("\n**Guilds:** ").append(shard.getGuildCache().size()).append("\n**VCs:** ").append(channelStats.getFirst()).append(" / ").append(channelStats.getSecond());
final int shardId = shard.getShardInfo().getShardId();
embedBuilder.addField(String.format("Shard #%s%s", shardId, shardId == currentShard ? " (current)" : ""), valueBuilder.toString(), true);
}
final long connectedShards = shardCache.applyStream((s) -> s.filter((shard) -> shard.getStatus() == JDA.Status.CONNECTED).count());
final String avgPing = new DecimalFormat("###").format(shardManager.getAverageGatewayPing());
final long guilds = shardManager.getGuildCache().size();
final LongLongPair channelStats = getConnectedVoiceChannels(shardManager);
embedBuilder.addField("Total/Average", String.format("**Connected:** %s\n**Ping:** %s\n**Guilds:** %s\n**VCs:** %s / %s", connectedShards, avgPing, guilds, channelStats.getFirst(), channelStats.getSecond()), false);
sendEmbed(ctx, embedBuilder);
}
use of ml.duncte123.skybot.objects.pairs.LongLongPair in project SkyBot by duncte123.
the class ShardInfoCommand method asciiInfo.
private void asciiInfo(CommandContext ctx) {
final List<String> headers = new ArrayList<>();
headers.add("ID");
headers.add("Status");
headers.add("Ping");
headers.add("Guilds");
headers.add("VCs");
List<List<String>> table = new ArrayList<>();
final int currentShard = ctx.getJDA().getShardInfo().getShardId();
final ShardManager shardManager = ctx.getJDA().getShardManager();
final List<JDA> shards = new ArrayList<>(shardManager.getShards());
Collections.reverse(shards);
for (final JDA shard : shards) {
final List<String> row = new ArrayList<>();
final int shardId = shard.getShardInfo().getShardId();
row.add(shardId + (currentShard == shardId ? " (current)" : ""));
row.add(getShardStatus(shard));
row.add(String.valueOf(shard.getGatewayPing()));
row.add(String.valueOf(shard.getGuildCache().size()));
final LongLongPair channelStats = getConnectedVoiceChannels(shard);
row.add(channelStats.getFirst() + " / " + channelStats.getSecond());
table.add(row);
if (table.size() == 20) {
MessageUtils.sendMsg(ctx, makeAsciiTable(headers, table, shardManager));
table = new ArrayList<>();
}
}
if (!table.isEmpty()) {
MessageUtils.sendMsg(ctx, makeAsciiTable(headers, table, shardManager));
}
}
use of ml.duncte123.skybot.objects.pairs.LongLongPair in project SkyBot by DuncteBot.
the class ShardInfoCommand method getConnectedVoiceChannels.
private LongLongPair getConnectedVoiceChannels(ShardManager shardManager) {
final AtomicLong connectedVC = new AtomicLong();
final AtomicLong listeningVC = new AtomicLong();
shardManager.getShardCache().forEach((jda) -> {
final LongLongPair shardStats = getConnectedVoiceChannels(jda);
connectedVC.addAndGet(shardStats.getFirst());
listeningVC.addAndGet(shardStats.getSecond());
});
return new LongLongPair(connectedVC.get(), listeningVC.get());
}
use of ml.duncte123.skybot.objects.pairs.LongLongPair in project SkyBot by DuncteBot.
the class ShardInfoCommand method asciiInfo.
private void asciiInfo(CommandContext ctx) {
final List<String> headers = new ArrayList<>();
headers.add("ID");
headers.add("Status");
headers.add("Ping");
headers.add("Guilds");
headers.add("VCs");
List<List<String>> table = new ArrayList<>();
final int currentShard = ctx.getJDA().getShardInfo().getShardId();
final ShardManager shardManager = ctx.getJDA().getShardManager();
final List<JDA> shards = new ArrayList<>(shardManager.getShards());
Collections.reverse(shards);
for (final JDA shard : shards) {
final List<String> row = new ArrayList<>();
final int shardId = shard.getShardInfo().getShardId();
row.add(shardId + (currentShard == shardId ? " (current)" : ""));
row.add(getShardStatus(shard));
row.add(String.valueOf(shard.getGatewayPing()));
row.add(String.valueOf(shard.getGuildCache().size()));
final LongLongPair channelStats = getConnectedVoiceChannels(shard);
row.add(channelStats.getFirst() + " / " + channelStats.getSecond());
table.add(row);
if (table.size() == 20) {
MessageUtils.sendMsg(ctx, makeAsciiTable(headers, table, shardManager));
table = new ArrayList<>();
}
}
if (!table.isEmpty()) {
MessageUtils.sendMsg(ctx, makeAsciiTable(headers, table, shardManager));
}
}
Aggregations