use of fredboat.commandmeta.CommandRegistry in project FredBoat by Frederikam.
the class CommandsCommand method addModuleCommands.
private EmbedBuilder addModuleCommands(@Nonnull EmbedBuilder embedBuilder, @Nonnull CommandContext context, @Nonnull CommandRegistry module) {
List<Command> commands = module.getDeduplicatedCommands().stream().filter(command -> {
if (command instanceof ICommandRestricted) {
if (((ICommandRestricted) command).getMinimumPerms().getLevel() >= PermissionLevel.BOT_ADMIN.getLevel()) {
return PermsUtil.checkPerms(PermissionLevel.BOT_ADMIN, context.invoker);
}
}
return true;
}).collect(Collectors.toList());
String prefix = context.getPrefix();
if (commands.size() >= 6) {
// split the commands into three even columns
StringBuilder[] sbs = new StringBuilder[3];
sbs[0] = new StringBuilder();
sbs[1] = new StringBuilder();
sbs[2] = new StringBuilder();
int i = 0;
for (Command c : commands) {
if (c instanceof DestroyCommand) {
// dont want to publicly show this one
continue;
}
sbs[i++ % 3].append(prefix).append(c.name).append("\n");
}
return embedBuilder.addField(context.i18n(module.module.translationKey), sbs[0].toString(), true).addField("", sbs[1].toString(), true).addField("", sbs[2].toString(), true);
} else {
StringBuilder sb = new StringBuilder();
for (Command c : commands) {
sb.append(prefix).append(c.name).append("\n");
}
return embedBuilder.addField(context.i18n(module.module.translationKey), sb.toString(), true).addBlankField(true).addBlankField(true);
}
}
Aggregations