Interface CommandDispatcher

  • All Known Implementing Classes:
    AbstractCommandDispatcher
    Functional Interface:
    This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

    @FunctionalInterface
    public interface CommandDispatcher
    This represents a command dispatcher. Implementing this allows for custom command resolution logic (for example, making certain providers available only on certain guilds, etc).
    See Also:
    CommandProvider
    • Method Detail

      • dispatch

        Publisher<? extends Command<?>> dispatch​(discord4j.core.event.domain.message.MessageCreateEvent event,
                                                 Set<CommandProvider<?>> providers,
                                                 CommandErrorHandler errorHandler)
        Called to handle the logic of invoking a command based on an event. This is expected to do two things:
        1. Determine whether a command should be triggered. This can be due to any arbitrary criteria (existence of a prefix, a specific use sending the message, etc).
        2. Generate hints to allow for naive argument parsing by command providers. These hints are not necessarily binding, but providers are expected to at least consider them. The hints are composed of the command that the message author is attempting to execute (single word) and a set of string indices denoting the subsequence of the message string which contains the command's arguments.
        Parameters:
        event - The event for command execution.
        providers - The CommandProviders this dispatcher should consider for dispatching.
        errorHandler - The error handler to pass to command.
        Returns:
        A flux which emits executed command.
        See Also:
        CommandProvider.provide(discord4j.core.event.domain.message.MessageCreateEvent, String, int, int)