Search in sources :

Example 11 with Context

use of fredboat.messaging.internal.Context in project FredBoat by Frederikam.

the class NodeAdminCommand method show.

private void show(@Nonnull CommandContext context) {
    String name = context.args[1];
    List<LavalinkSocket> nodes = Launcher.getBotController().getAudioConnectionFacade().getLavalink().getNodes().stream().filter(ll -> ll.getName().equals(name)).collect(Collectors.toList());
    if (nodes.isEmpty()) {
        context.reply("No such node: " + name + ", showing a list of all nodes instead");
        list(context);
        return;
    }
    RemoteStats stats = nodes.get(0).getStats();
    String out = "No stats have been received from this node! Is the node down?";
    if (stats != null) {
        out = TextUtils.asCodeBlock(stats.getAsJson().toString(4), "json");
    }
    context.reply(out);
}
Also used : LavalinkSocket(lavalink.client.io.LavalinkSocket) Launcher(fredboat.main.Launcher) RemoteStats(lavalink.client.io.RemoteStats) URISyntaxException(java.net.URISyntaxException) Command(fredboat.commandmeta.abs.Command) ICommandRestricted(fredboat.commandmeta.abs.ICommandRestricted) CommandContext(fredboat.commandmeta.abs.CommandContext) PermissionLevel(fredboat.definitions.PermissionLevel) TextUtils(fredboat.util.TextUtils) LavalinkLoadBalancer(lavalink.client.io.LavalinkLoadBalancer) Collectors(java.util.stream.Collectors) ArrayList(java.util.ArrayList) List(java.util.List) LavalinkSocket(lavalink.client.io.LavalinkSocket) Context(fredboat.messaging.internal.Context) Lavalink(lavalink.client.io.Lavalink) HelpCommand(fredboat.command.info.HelpCommand) URI(java.net.URI) Nonnull(javax.annotation.Nonnull) PermsUtil(fredboat.perms.PermsUtil) RemoteStats(lavalink.client.io.RemoteStats)

Aggregations

Command (fredboat.commandmeta.abs.Command)11 CommandContext (fredboat.commandmeta.abs.CommandContext)11 Context (fredboat.messaging.internal.Context)11 TextUtils (fredboat.util.TextUtils)11 Nonnull (javax.annotation.Nonnull)11 CentralMessaging (fredboat.messaging.CentralMessaging)8 PermissionLevel (fredboat.definitions.PermissionLevel)6 HelpCommand (fredboat.command.info.HelpCommand)5 ICommandRestricted (fredboat.commandmeta.abs.ICommandRestricted)5 Launcher (fredboat.main.Launcher)5 Collectors (java.util.stream.Collectors)5 PermsUtil (fredboat.perms.PermsUtil)4 Permission (net.dv8tion.jda.core.Permission)4 Guild (net.dv8tion.jda.core.entities.Guild)4 GuildPlayer (fredboat.audio.player.GuildPlayer)3 CommandInitializer (fredboat.commandmeta.CommandInitializer)3 CommandRegistry (fredboat.commandmeta.CommandRegistry)3 IInfoCommand (fredboat.commandmeta.abs.IInfoCommand)3 IModerationCommand (fredboat.commandmeta.abs.IModerationCommand)3 Module (fredboat.definitions.Module)3