Interface CommandKernel


  • public interface CommandKernel
    The kernel for all bot commands. Command instances are stored, managed and executed here.
    • Method Detail

      • parseCommandLine

        Optional<reactor.util.function.Tuple2<Command,​List<String>>> parseCommandLine​(String commandLine)
        Reads the command line and retrieves the corresponding Command instance. Arguments passed to the command are also returned as a list.
        Parameters:
        commandLine - the command line
        Returns:
        the command with its arguments, if present
      • parseCommandLine

        Optional<reactor.util.function.Tuple2<Command,​List<String>>> parseCommandLine​(List<String> commandLine)
        Reads the command line and retrieves the corresponding Command instance. Arguments passed to the command are also returned as a list.
        Parameters:
        commandLine - the command line as a list of string containing the command name as first element and arguments then
        Returns:
        the command with its arguments, if present
      • getCommands

        Set<Command> getCommands()
        Gets an unmodifiable set of all commands available in the kernel.
        Returns:
        a Set of Command
      • getCommandsGroupedByPlugins

        Map<String,​Set<Command>> getCommandsGroupedByPlugins()
        Gets an unmodifiable map of all commands available in the kernel, grouped by plugin names.
        Returns:
        a Map of String, Command
      • invokeCommand

        reactor.core.publisher.Mono<Void> invokeCommand​(Command cmd,
                                                        Context ctx)
        Invokes a command with the specified context.
        Parameters:
        cmd - the command to invoke
        ctx - the context of the command
        Returns:
        a Mono that completes when the command has terminated. Any errors that may occur when running the command are transmitted through this Mono.
      • openReplyMenu

        String openReplyMenu​(Context ctx,
                             discord4j.core.object.entity.Message msg,
                             Map<String,​java.util.function.Function<Context,​reactor.core.publisher.Mono<Void>>> menuItems,
                             boolean deleteOnReply,
                             boolean deleteOnTimeout)
        Opens a new reply menu with the given items.
        Parameters:
        ctx - the context of the command this reply menu was opened from
        msg - The message containing the menu
        menuItems - the menu items
        deleteOnReply - Whether to delete msg when the user has given a valid reply
        deleteOnTimeout - Whether to delete msg when the user doesn't reply and the menu times out.
        Returns:
        the identifier of the opened reply, or an empty string if the menu could not be opened.
      • closeReplyMenu

        void closeReplyMenu​(String identifier)
        Closes a reply menu using its identifier.
        Parameters:
        identifier - the identifier of the reply menu to close