java.lang.Object
dev.sympho.modular_commands.api.permission.Groups

public final class Groups extends Object
Default group types and composition operations.
Since:
1.0
Version:
1.0
  • Field Details

    • EVERYONE

      public static final NamedGroup EVERYONE
      The group of all Discord users (matches everyone).
    • NOBODY

      public static final NamedGroup NOBODY
      The empty group (matches nobody).
    • ADMINS

      public static final NamedGroup ADMINS
      The group of server admins (matches users with the administrator permission).
    • SERVER_OWNER

      public static final NamedGroup SERVER_OWNER
      The group that only matches the server owner.
    • BOT_OWNER

      public static final NamedGroup BOT_OWNER
      The group that only matches the bot owner.
    • BOOSTER

      public static final NamedGroup BOOSTER
      The group that matches a booster in the invoking server.

      Note that, unlike groups like ADMINS or hasGuildPermissions(PermissionSet), this group will never match on a private channel, as usually the goal is paywalling a feature rather than limiting permissions.

  • Method Details

    • named

      public static NamedGroup named(Group group, String name)
      Adds a name to an existing group.
      Parameters:
      group - The group.
      name - The name.
      Returns:
      The given group with the name set to the given name.
    • remote

      public static Group remote(Group group, Mono<Snowflake> guild)
      Decorates a group so that membership is always checked in relation to the given guild, rather than the guild where the command was executed in.

      In other words, this overrides the guild parameter provided to the Group.belongs(Mono, Mono, User) method to the given guild, before delegating to the given group.

      This allows for permission checking on commands that always operate on some remote guild, and thus should be checked in relation to that guild.

      Parameters:
      group - The group.
      guild - The guild where group membership should be checked for. The issued value may change over time.
      Returns:
      The decorated group.
    • remote

      public static NamedGroup remote(NamedGroup group, Mono<Snowflake> guild)
      Decorates a group so that membership is always checked in relation to the given guild, rather than the guild where the command was executed in.

      In other words, this overrides the guild parameter provided to the Group.belongs(Mono, Mono, User) method to the given guild, before delegating to the given group.

      This allows for permission checking on commands that always operate on some remote guild, and thus should be checked in relation to that guild.

      The name of the group is passed through.

      Parameters:
      group - The group.
      guild - The guild where group membership should be checked for. The issued value may change over time.
      Returns:
      The decorated group.
      API Note:
      If the name of the group will be overriden, an explicit cast to the non-named variant may be used to avoid an unecessary wrapping layer: named(remote((Group) group, guild), "some name")
    • remote

      public static Group remote(Group group, Supplier<Snowflake> guild)
      Decorates a group so that membership is always checked in relation to the given guild, rather than the guild where the command was executed in.

      This allows for permission checking on commands that always operate on some remote guild, and thus should be checked in relation to that guild.

      Parameters:
      group - The group.
      guild - The guild where group membership should be checked for. The issued value may change over time.
      Returns:
      The decorated group.
    • remote

      public static NamedGroup remote(NamedGroup group, Supplier<Snowflake> guild)
      Decorates a group so that membership is always checked in relation to the given guild, rather than the guild where the command was executed in.

      This allows for permission checking on commands that always operate on some remote guild, and thus should be checked in relation to that guild.

      The name of the group is passed through.

      Parameters:
      group - The group.
      guild - The guild where group membership should be checked for. The issued value may change over time.
      Returns:
      The decorated group.
      API Note:
      If the name of the group will be overriden, an explicit cast to the non-named variant may be used to avoid an unecessary wrapping layer: named(remote((Group) group, guild), "some name")
    • remote

      public static Group remote(Group group, Snowflake guild)
      Decorates a group so that membership is always checked in relation to the given guild, rather than the guild where the command was executed in.

      This allows for permission checking on commands that always operate on some remote guild, and thus should be checked in relation to that guild.

      Parameters:
      group - The group.
      guild - The guild where group membership should be checked for.
      Returns:
      The decorated group.
    • remote

      public static NamedGroup remote(NamedGroup group, Snowflake guild)
      Decorates a group so that membership is always checked in relation to the given guild, rather than the guild where the command was executed in.

      This allows for permission checking on commands that always operate on some remote guild, and thus should be checked in relation to that guild.

      The name of the group is passed through.

      Parameters:
      group - The group.
      guild - The guild where group membership should be checked for.
      Returns:
      The decorated group.
      API Note:
      If the name of the group will be overriden, an explicit cast to the non-named variant may be used to avoid an unecessary wrapping layer: named(remote((Group) group, guild), "some name")
    • any

      public static Group any(Flux<Group> groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of any of the given groups.
      Parameters:
      groups - The groups to compose. The issued values may change over time (between subscriptions).
      Returns:
      The composed group.
    • any

      public static Group any(Stream<Group> groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of any of the given groups.
      Parameters:
      groups - The groups to compose.
      Returns:
      The composed group.
    • any

      public static Group any(Iterable<Group> groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of any of the given groups.
      Parameters:
      groups - The groups to compose.
      Returns:
      The composed group.
    • any

      public static Group any(Group... groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of any of the given groups.
      Parameters:
      groups - The groups to compose.
      Returns:
      The composed group.
    • all

      public static Group all(Flux<Group> groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of all of the given groups.
      Parameters:
      groups - The groups to compose. The issued values may change over time (between subscriptions).
      Returns:
      The composed group.
    • all

      public static Group all(Stream<Group> groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of all of the given groups.
      Parameters:
      groups - The groups to compose.
      Returns:
      The composed group.
    • all

      public static Group all(Iterable<Group> groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of all of the given groups.
      Parameters:
      groups - The groups to compose.
      Returns:
      The composed group.
    • all

      public static Group all(Group... groups)
      Composes multiple groups into a single group where a user is only a member if they are a member of all of the given groups.
      Parameters:
      groups - The groups to compose.
      Returns:
      The composed group.
    • isUser

      public static Group isUser(Mono<Snowflake> user)
      Creates a group composed of a single user.
      Parameters:
      user - The user. The issued value may change over time.
      Returns:
      The group.
    • isUser

      public static Group isUser(Supplier<Snowflake> user)
      Creates a group composed of a single user.
      Parameters:
      user - The user. The issued value may change over time.
      Returns:
      The group.
    • isUser

      public static Group isUser(Snowflake user)
      Creates a group composed of a single user.
      Parameters:
      user - The user.
      Returns:
      The group.
    • inWhitelist

      public static Group inWhitelist(Flux<Snowflake> users)
      Creates a group composed of a set of users.
      Parameters:
      users - The users that belong to the group. The issued values may vary over time (between subscriptions).
      Returns:
      The group.
    • inWhitelist

      public static Group inWhitelist(Mono<? extends Collection<Snowflake>> users)
      Creates a group composed of a set of users.
      Parameters:
      users - The users that belong to the group. The issued values may vary over time (between subscriptions).
      Returns:
      The group.
    • inWhitelist

      public static Group inWhitelist(Supplier<? extends Collection<Snowflake>> users)
      Creates a group composed of a set of users.
      Parameters:
      users - The users that belong to the group. The issued values may vary over time (between requests).
      Returns:
      The group.
    • inWhitelist

      public static Group inWhitelist(Collection<Snowflake> users)
      Creates a group composed of a set of users.
      Parameters:
      users - The users that belong to the group.
      Returns:
      The group.
    • inWhitelist

      public static Group inWhitelist(Snowflake... users)
      Creates a group composed of a set of users.
      Parameters:
      users - The users that belong to the group.
      Returns:
      The group.
    • hasRole

      public static Group hasRole(Mono<Snowflake> role)
      Creates a group defined as all users that have the given role.
      Parameters:
      role - The role. The issued value may vary over time.
      Returns:
      The group.
    • hasRole

      public static Group hasRole(Supplier<Snowflake> role)
      Creates a group defined as all users that have the given role.
      Parameters:
      role - The role. The issued value may vary over time.
      Returns:
      The group.
    • hasRole

      public static Group hasRole(Snowflake role)
      Creates a group defined as all users that have the given role.
      Parameters:
      role - The role.
      Returns:
      The group.
    • hasRolesAny

      public static Group hasRolesAny(Mono<? extends Collection<Snowflake>> roles)
      Creates a group defined as all users that have any of the given roles.
      Parameters:
      roles - The roles. The issued values may vary over time (between subscriptions).
      Returns:
      The group.
    • hasRolesAny

      public static Group hasRolesAny(Flux<Snowflake> roles)
      Creates a group defined as all users that have any of the given roles.
      Parameters:
      roles - The roles. The issued values may vary over time (between subscriptions).
      Returns:
      The group.
    • hasRolesAny

      public static Group hasRolesAny(Supplier<? extends Collection<Snowflake>> roles)
      Creates a group defined as all users that have any of the given roles.
      Parameters:
      roles - The roles. The issued values may vary over time.
      Returns:
      The group.
    • hasRolesAny

      public static Group hasRolesAny(Collection<Snowflake> roles)
      Creates a group defined as all users that have any of the given roles.
      Parameters:
      roles - The roles.
      Returns:
      The group.
    • hasRolesAny

      public static Group hasRolesAny(Snowflake... roles)
      Creates a group defined as all users that have any of the given roles.
      Parameters:
      roles - The roles.
      Returns:
      The group.
    • hasRolesAll

      public static Group hasRolesAll(Flux<Snowflake> roles)
      Creates a group defined as all users that have all of the given roles.
      Parameters:
      roles - The roles. The issued values may vary over time (between subscriptions).
      Returns:
      The group.
    • hasRolesAll

      public static Group hasRolesAll(Mono<? extends Collection<Snowflake>> roles)
      Creates a group defined as all users that have all of the given roles.
      Parameters:
      roles - The roles. The issued values may vary over time (between subscriptions).
      Returns:
      The group.
    • hasRolesAll

      public static Group hasRolesAll(Supplier<? extends Collection<Snowflake>> roles)
      Creates a group defined as all users that have all of the given roles.
      Parameters:
      roles - The roles. The issued values may vary over time.
      Returns:
      The group.
    • hasRolesAll

      public static Group hasRolesAll(Collection<Snowflake> roles)
      Creates a group defined as all users that have all of the given roles.
      Parameters:
      roles - The roles.
      Returns:
      The group.
    • hasRolesAll

      public static Group hasRolesAll(Snowflake... roles)
      Creates a group defined as all users that have all of the given roles.
      Parameters:
      roles - The roles.
      Returns:
      The group.
    • hasGuildPermissions

      public static Group hasGuildPermissions(Mono<discord4j.rest.util.PermissionSet> permissions)
      Creates a group defined as all users that have the given permissions in the guild.
      Parameters:
      permissions - The permissions. The issued value may vary over time.
      Returns:
      The group.
    • hasGuildPermissions

      public static Group hasGuildPermissions(Supplier<discord4j.rest.util.PermissionSet> permissions)
      Creates a group defined as all users that have the given permissions in the guild.
      Parameters:
      permissions - The permissions. The issued value may vary over time.
      Returns:
      The group.
    • hasGuildPermissions

      public static Group hasGuildPermissions(discord4j.rest.util.PermissionSet permissions)
      Creates a group defined as all users that have the given permissions in the guild.
      Parameters:
      permissions - The permissions.
      Returns:
      The group.
    • hasChannelPermissions

      public static Group hasChannelPermissions(Mono<discord4j.rest.util.PermissionSet> permissions)
      Creates a group defined as all users that have the given permissions in the channel.
      Parameters:
      permissions - The permissions. The issued value may vary over time.
      Returns:
      The group.
    • hasChannelPermissions

      public static Group hasChannelPermissions(Supplier<discord4j.rest.util.PermissionSet> permissions)
      Creates a group defined as all users that have the given permissions in the channel.
      Parameters:
      permissions - The permissions. The issued value may vary over time.
      Returns:
      The group.
    • hasChannelPermissions

      public static Group hasChannelPermissions(discord4j.rest.util.PermissionSet permissions)
      Creates a group defined as all users that have the given permissions in the channel.
      Parameters:
      permissions - The permissions.
      Returns:
      The group.