Class RoleJavacord

  • All Implemented Interfaces:
    Restriction<Message>

    public abstract class RoleJavacord
    extends Object
    implements Restriction<Message>
    A restriction that allows a command for certain roles and is evaluated by the Javacord command handler. To use it, create a trivial subclass of this class and make it a discoverable CDI bean, for example by annotating it with @ApplicationScoped.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected RoleJavacord​(boolean exact, long roleId)
      Constructs a new role restriction for checking the role ID.
      protected RoleJavacord​(boolean exact, String roleName)
      Constructs a new role restriction for checking the role name case-sensitively against a fixed name.
      protected RoleJavacord​(boolean exact, String roleName, boolean caseSensitive)
      Constructs a new role restriction for checking the role name against a fixed name.
      protected RoleJavacord​(boolean exact, Pattern rolePattern)
      Constructs a new role restriction for checking the role name against a regular expression for an exact role match.
      protected RoleJavacord​(long roleId)
      Constructs a new role restriction for checking the role ID for an exact role match.
      protected RoleJavacord​(String roleName)
      Constructs a new role restriction for checking the role name case-sensitively against a fixed name for an exact role match.
      protected RoleJavacord​(String roleName, boolean caseSensitive)
      Constructs a new role restriction for checking the role name against a fixed name for an exact role match.
      protected RoleJavacord​(Pattern rolePattern)
      Constructs a new role restriction for checking the role name against a regular expression for an exact role match.
    • Constructor Detail

      • RoleJavacord

        protected RoleJavacord​(long roleId)
        Constructs a new role restriction for checking the role ID for an exact role match.
        Parameters:
        roleId - the ID of the role for which a command should be allowed
      • RoleJavacord

        protected RoleJavacord​(String roleName)
        Constructs a new role restriction for checking the role name case-sensitively against a fixed name for an exact role match.
        Parameters:
        roleName - the case-sensitive name of the role for which a command should be allowed
      • RoleJavacord

        protected RoleJavacord​(String roleName,
                               boolean caseSensitive)
        Constructs a new role restriction for checking the role name against a fixed name for an exact role match.
        Parameters:
        roleName - the name of the role for which a command should be allowed
        caseSensitive - whether the name should be matched case-sensitively or not
      • RoleJavacord

        protected RoleJavacord​(Pattern rolePattern)
        Constructs a new role restriction for checking the role name against a regular expression for an exact role match.
        Parameters:
        rolePattern - the pattern against which the role name is matched to determine for whom a command should be allowed
      • RoleJavacord

        protected RoleJavacord​(boolean exact,
                               long roleId)
        Constructs a new role restriction for checking the role ID.
        Parameters:
        exact - whether the role needs to be matched exactly or whether a higher role would also be sufficient
        roleId - the ID of the role for which a command should be allowed
      • RoleJavacord

        protected RoleJavacord​(boolean exact,
                               String roleName)
        Constructs a new role restriction for checking the role name case-sensitively against a fixed name.
        Parameters:
        exact - whether the role needs to be matched exactly or whether a higher role would also be sufficient
        roleName - the case-sensitive name of the role for which a command should be allowed
      • RoleJavacord

        protected RoleJavacord​(boolean exact,
                               String roleName,
                               boolean caseSensitive)
        Constructs a new role restriction for checking the role name against a fixed name.
        Parameters:
        exact - whether the role needs to be matched exactly or whether a higher role would also be sufficient
        roleName - the name of the role for which a command should be allowed
        caseSensitive - whether the name should be matched case-sensitively or not
      • RoleJavacord

        protected RoleJavacord​(boolean exact,
                               Pattern rolePattern)
        Constructs a new role restriction for checking the role name against a regular expression for an exact role match.
        Parameters:
        exact - whether the role needs to be matched exactly or whether a higher role would also be sufficient
        rolePattern - the pattern against which the role name is matched to determine for whom a command should be allowed
    • Method Detail

      • allowCommand

        public boolean allowCommand​(CommandContext<? extends Message> commandContext)
        Description copied from interface: Restriction
        Returns whether a command caused by the given command context should be allowed by this restriction or not.
        Specified by:
        allowCommand in interface Restriction<Message>
        Parameters:
        commandContext - the command context, usually fully populated
        Returns:
        whether a command caused by the given command context should be allowed by this restriction or not