use of net.robinfriedli.aiode.command.widget.widgets.PermissionListPaginationWidget in project aiode by robinfriedli.
the class PermissionCommand method listPermissions.
private void listPermissions() {
CommandContext context = getContext();
Guild guild = context.getGuild();
GuildContext guildContext = context.getGuildContext();
SecurityManager securityManager = Aiode.get().getSecurityManager();
List<PermissionTarget> targets = Lists.newArrayList();
for (PermissionTarget.TargetType targetType : PermissionTarget.TargetType.values()) {
if (!targetType.isChildTargetOnly()) {
Set<? extends PermissionTarget> permissionTargetsInCategory = targetType.getAllPermissionTargetsInCategory();
permissionTargetsInCategory.stream().sorted(Comparator.comparingInt((ToIntFunction<PermissionTarget>) permissionTarget -> permissionTarget.getPermissionTypeCategory().getSorting()).thenComparing(PermissionTarget::getPermissionTargetIdentifier)).forEach(permissionTarget -> {
List<PermissionTarget> flattenedPermissionHierarchy = Lists.newArrayList();
LinkedList<List<PermissionTarget>> stack = new LinkedList<>();
stack.push(flattenedPermissionHierarchy);
flattenPermissionTargetHierarchy(permissionTarget, stack, securityManager, guild, true);
targets.addAll(flattenedPermissionHierarchy);
});
}
}
PermissionListPaginationWidget permissionListPaginationWidget = new PermissionListPaginationWidget(guildContext.getWidgetRegistry(), guild, context.getChannel(), targets, securityManager);
permissionListPaginationWidget.initialise();
}
Aggregations