Package discord4j.command
Class CommandBootstrapper
- java.lang.Object
-
- discord4j.command.CommandBootstrapper
-
public final class CommandBootstrapper extends Object
The (thread-safe) entry point for actually using command. To use, simply instantiate and callattach(DiscordClient)
.To register events, obtain the
CommandDispatcher
viagetDispatcher()
.
-
-
Constructor Summary
Constructors Constructor Description CommandBootstrapper(CommandDispatcher dispatcher)
Constructs the message listener for command.CommandBootstrapper(CommandDispatcher dispatcher, CommandErrorHandler errorHandler)
Constructs the message listener for command.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandBootstrapper
addProvider(CommandProvider<?> provider)
Called to add a command provider dynamically.CommandBootstrapper
addProviders(Collection<? extends CommandProvider<?>> providers)
Called to add command providers dynamically.reactor.core.publisher.Flux<? extends Command<?>>
attach(discord4j.core.DiscordClient client)
Attaches thisCommandBootstrapper
instance to theMessageCreateEvent
of the passed in client.CommandDispatcher
getDispatcher()
Gets theCommandDispatcher
being currently used.CommandErrorHandler
getErrorHandler()
Gets theCommandErrorHandler
being currently used.Set<CommandProvider<?>>
getProviders()
Gets the command providers registered with this dispatcher.CommandBootstrapper
removeProvider(CommandProvider<?> provider)
Called to drop a command provider dynamically.CommandBootstrapper
removeProviders(Collection<? extends CommandProvider<?>> providers)
Called to remove command providers dynamically.
-
-
-
Constructor Detail
-
CommandBootstrapper
public CommandBootstrapper(CommandDispatcher dispatcher, CommandErrorHandler errorHandler)
Constructs the message listener for command.- Parameters:
dispatcher
- The command dispatcher to be used to emit events from.errorHandler
- TheCommandErrorHandler
for the dispatcher.- See Also:
attach(DiscordClient)
-
CommandBootstrapper
public CommandBootstrapper(CommandDispatcher dispatcher)
Constructs the message listener for command.- See Also:
attach(DiscordClient)
-
-
Method Detail
-
attach
public reactor.core.publisher.Flux<? extends Command<?>> attach(discord4j.core.DiscordClient client)
Attaches thisCommandBootstrapper
instance to theMessageCreateEvent
of the passed in client.- Returns:
- A flux (that need not be subscribed to), which signals the completion of command executions.
-
getDispatcher
public CommandDispatcher getDispatcher()
Gets theCommandDispatcher
being currently used.- Returns:
- The current
CommandDispatcher
.
-
getErrorHandler
public CommandErrorHandler getErrorHandler()
Gets theCommandErrorHandler
being currently used.- Returns:
- The current
CommandErrorHandler
.
-
getProviders
public Set<CommandProvider<?>> getProviders()
Gets the command providers registered with this dispatcher.- Returns:
- The providers. It is expected that this returns an immutable copy of the internal backing set.
-
addProvider
public CommandBootstrapper addProvider(CommandProvider<?> provider)
Called to add a command provider dynamically.- Parameters:
provider
- The provider to add.- Returns:
- The current
CommandBootstrapper
instance for chaining.
-
removeProvider
public CommandBootstrapper removeProvider(CommandProvider<?> provider)
Called to drop a command provider dynamically.- Parameters:
provider
- The provider to remove.- Returns:
- The current
CommandBootstrapper
instance for chaining.
-
addProviders
public CommandBootstrapper addProviders(Collection<? extends CommandProvider<?>> providers)
Called to add command providers dynamically.- Parameters:
providers
- The providers to add.- Returns:
- The current
CommandBootstrapper
instance for chaining.
-
removeProviders
public CommandBootstrapper removeProviders(Collection<? extends CommandProvider<?>> providers)
Called to remove command providers dynamically.- Parameters:
providers
- The providers to remove.- Returns:
- The current
CommandBootstrapper
instance for chaining.
-
-