Class AbstractCommandDispatcher

    • Constructor Detail

      • AbstractCommandDispatcher

        public AbstractCommandDispatcher()
    • Method Detail

      • dispatch

        public Publisher<? extends Command<?>> dispatch​(discord4j.core.event.domain.message.MessageCreateEvent event,
                                                        Set<CommandProvider<?>> providers,
                                                        CommandErrorHandler errorHandler)
        Description copied from interface: CommandDispatcher
        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.
        Specified by:
        dispatch in interface CommandDispatcher
        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)
      • getPrefixes

        protected abstract Publisher<String> getPrefixes​(discord4j.core.event.domain.message.MessageCreateEvent event)
        Requests to retrieve the prefixes for the supplied event.
        Parameters:
        event - The event to retrieve prefixes for.
        Returns:
        A Publisher that continually emits the prefixes for the supplied event.