Interface Command
-
public interface Command
Represents a bot command.
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description reactor.core.publisher.Mono<Void>
execute(Context ctx)
Executes the commandstatic Command
forkedFrom(Command other, java.util.function.Function<Context,reactor.core.publisher.Mono<Void>> executeFunc)
Creates a new Command instance which action is the provided function, and other attributes (alias, error actions, allowed channels, permission level, etc) are inherited from the given base command.Set<String>
getAliases()
Gets the aliases for this command.EnumSet<discord4j.core.object.entity.Channel.Type>
getChannelTypesAllowed()
Gets the type of channels this command is allowed for use in.String
getDescription()
Gets the description of the command.Map<Class<? extends Throwable>,java.util.function.BiConsumer<Throwable,Context>>
getErrorActions()
Allows to define an action to execute according to the type of error emitted when executing this command.String
getLongDescription()
Gets the long description of the command.PermissionLevel
getPermissionLevel()
Gets the permission level required to execute this command.Set<Command>
getSubcommands()
Gets the subcommands.String
getSyntax()
Gets the syntax of the command.
-
-
-
Method Detail
-
execute
reactor.core.publisher.Mono<Void> execute(Context ctx)
Executes the command- Parameters:
ctx
- the context- Returns:
- a Mono that completes empty when the command is successful, and emits an error when something goes wrong.
-
getDescription
String getDescription()
Gets the description of the command. The description is shown in the help command list.- Returns:
- the description
-
getLongDescription
String getLongDescription()
Gets the long description of the command. The description is shown in the detailed help page of the command.- Returns:
- the description
-
getSyntax
String getSyntax()
Gets the syntax of the command. The syntax is shown in the help command, and explains which arguments can be passed to the command.- Returns:
- the syntax
-
getPermissionLevel
PermissionLevel getPermissionLevel()
Gets the permission level required to execute this command.- Returns:
- the permission level
-
getChannelTypesAllowed
EnumSet<discord4j.core.object.entity.Channel.Type> getChannelTypesAllowed()
Gets the type of channels this command is allowed for use in.- Returns:
- the set of allowed type of channels
-
getErrorActions
Map<Class<? extends Throwable>,java.util.function.BiConsumer<Throwable,Context>> getErrorActions()
Allows to define an action to execute according to the type of error emitted when executing this command.- Returns:
- a Map that associates a Throwable type to an executable action.
-
forkedFrom
static Command forkedFrom(Command other, java.util.function.Function<Context,reactor.core.publisher.Mono<Void>> executeFunc)
Creates a new Command instance which action is the provided function, and other attributes (alias, error actions, allowed channels, permission level, etc) are inherited from the given base command.- Parameters:
other
- the base commandexecuteFunc
- the action of the new command- Returns:
- a new Command
-
-