Class Command

  • Direct Known Subclasses:
    GlobalCommand, ServerCommand

    public class Command
    extends java.lang.Object
    A class that represents a command
    • Constructor Detail

      • Command

        public Command​(java.lang.String name,
                       java.lang.String description)
        Default constructor
        Parameters:
        name - the name of the command Its length must between 1 and 32 Can contain only: - word characters - numbers - '-' characters
        description - the description of the command Its length must between 1 and 100
    • Method Detail

      • addArgument

        public void addArgument​(Argument argument)
        Adds an argument to the command
        Parameters:
        argument - the argument
      • addArgument

        public void addArgument​(Argument... arguments)
        Adds arguments to the command
        Parameters:
        arguments - a list of argument
      • addConcatenator

        public void addConcatenator​(Concatenator concatenator,
                                    Argument... arguments)
        Adds a concatenator to the command Every argument in the list must belong to this command, otherwise the concatenation won't proceed
        Parameters:
        concatenator - the concatenator
        arguments - the list of arguments
      • addPermissions

        public void addPermissions​(org.javacord.api.entity.permission.PermissionType... permissionTypes)
        Adds permissions that will be applied on the command Users will need these permissions in the specific channel to use the command
        Parameters:
        permissionTypes - a list of PermissionType
      • setOnlyForAdministrators

        public void setOnlyForAdministrators()
        Sets the command available only for administrators by default
      • setNsfw

        public void setNsfw()
        Sets the command age-restricted NOTE: this cannot be updated for now, so it only takes effect at the creation of the command
      • setOnAction

        public void setOnAction​(CommandActionEventListener listener)
        Sets the action listener
        Parameters:
        listener - the listener
      • getName

        public java.lang.String getName()
        Returns:
        the command's name
      • getDescription

        public java.lang.String getDescription()
        Returns:
        the command's description
      • getArguments

        public java.util.List<Argument> getArguments()
        Returns:
        the list of the arguments
      • getConcatenators

        public java.util.Map<Concatenator,​java.util.LinkedList<Argument>> getConcatenators()
        Returns:
        the map of concatenators
      • getDefaultPermissions

        public java.util.Set<org.javacord.api.entity.permission.PermissionType> getDefaultPermissions()
      • isOnlyForAdministrators

        public boolean isOnlyForAdministrators()
      • isNsfw

        public boolean isNsfw()
      • getActionListener

        public java.util.Optional<CommandActionEventListener> getActionListener()
        Gets the action listener
        Returns:
        Optional.empty() when action listener is not specified, otherwise Optional.of(Object) with the listener