Class CommandHandler


  • public class CommandHandler
    extends java.lang.Object
    The main class of the API
    • Constructor Detail

      • CommandHandler

        public CommandHandler()
    • Method Detail

      • setApi

        public static void setApi​(org.javacord.api.DiscordApi api)
        Initiates the command listener
        Parameters:
        api - is the instance of the Discord api
      • registerCommand

        public static void registerCommand​(ServerCommand command,
                                           org.javacord.api.entity.server.Server... servers)
        Registers the command for the listener on the specified servers and sets up permissions with discord's default permission system
        Parameters:
        command - the command
        servers - the list of the servers where the command will be registered
      • registerCommand

        public static void registerCommand​(GlobalCommand command)
        Registers command globally That means the command will be available in all the servers where the bot on, and also can be available in dms Sets up permissions with discord's default permission system
        Parameters:
        command - the command to register
      • getCommands

        public static java.util.List<Command> getCommands()
        Returns:
        the list of the commands
      • getCommands

        public static java.util.List<Command> getCommands​(org.javacord.api.entity.server.Server server)
        Parameters:
        server - server
        Returns:
        the list of the commands on the specified server
      • isCommandExist

        public static boolean isCommandExist​(java.lang.String cmd)
        Determines that a command with the given name is already exist or not
        Parameters:
        cmd - the command's name
        Returns:
        exist or not
      • isCommandExist

        public static boolean isCommandExist​(org.javacord.api.entity.server.Server server,
                                             java.lang.String cmd)
        Determines that a command with the given name is already exist or not on the specified server
        Parameters:
        server - server
        cmd - the command's name
        Returns:
        exist or not
      • getApi

        public static org.javacord.api.DiscordApi getApi()
        Returns:
        the discord api