Class CommandProvider

    • Constructor Detail

      • CommandProvider

        public CommandProvider()
    • Method Detail

      • add

        public void add​(Command command)
        Adds a command to this provider.
        Parameters:
        command - the command to add
      • provideFromEvent

        public reactor.core.publisher.Mono<ExecutableCommand> provideFromEvent​(Bot bot,
                                                                               String prefix,
                                                                               discord4j.core.event.domain.message.MessageCreateEvent event,
                                                                               discord4j.core.object.entity.channel.MessageChannel channel)
        Provides a command based on a MessageCreateEvent. The event must come with a message body containing a prefix and the alias of one of the commands provided by this provider. If it matches with a provided command, arguments and flags are parsed, and everything is wrapped in an ExecutableCommand which is returned. If the event does not match with any command, an empty Optional is returned.
        Parameters:
        bot - the bot instance
        prefix - the guild-specific bot prefix
        event - the MessageCreateEvent to process
        channel - the channel where the event happened
        Returns:
        an ExecutableCommand if the event results in a command to be triggered, an empty Optional otherwise.
      • getCommandByAlias

        public Optional<Command> getCommandByAlias​(String alias)
        Gets a command instance corresponding to the given alias.
        Parameters:
        alias - the alias of the command
        Returns:
        the corresponding command instance, if present
      • getErrorHandler

        public CommandErrorHandler getErrorHandler()
        Gets the error handler assigned to this provider.
        Returns:
        the error handler
      • setErrorHandler

        public void setErrorHandler​(CommandErrorHandler errorHandler)
        Sets a custom command handler. If this method is not called, a default handler will be used.
        Parameters:
        errorHandler - the error handler to set
      • getPermissionChecker

        public PermissionChecker getPermissionChecker()
        Gets the permission checker assigned to this provider.
        Returns:
        the permission checker
      • setPermissionChecker

        public void setPermissionChecker​(PermissionChecker permissionChecker)
        Sets a custom permission checker. If this method is not called, an empty permission checker will be used.
        Parameters:
        permissionChecker - the permission checker to set
      • getProvidedCommands

        public Set<Command> getProvidedCommands()
        Gets all provided commands.
        Returns:
        an unmodifiable Set containing all commands provided by this provider