Interface CommandKernel
-
public interface CommandKernel
The kernel for all bot commands. Command instances are stored, managed and executed here.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
closeReplyMenu(String identifier)
Closes a reply menu using its identifier.Set<Command>
getCommands()
Gets an unmodifiable set of all commands available in the kernel.Map<String,Set<Command>>
getCommandsGroupedByPlugins()
Gets an unmodifiable map of all commands available in the kernel, grouped by plugin names.reactor.core.publisher.Mono<Void>
invokeCommand(Command cmd, Context ctx)
Invokes a command with the specified context.String
openReplyMenu(Context ctx, discord4j.core.object.entity.Message msg, Map<String,java.util.function.Function<Context,reactor.core.publisher.Mono<Void>>> menuItems, boolean deleteOnReply, boolean deleteOnTimeout)
Opens a new reply menu with the given items.Optional<reactor.util.function.Tuple2<Command,List<String>>>
parseCommandLine(String commandLine)
Reads the command line and retrieves the corresponding Command instance.Optional<reactor.util.function.Tuple2<Command,List<String>>>
parseCommandLine(List<String> commandLine)
Reads the command line and retrieves the corresponding Command instance.
-
-
-
Method Detail
-
parseCommandLine
Optional<reactor.util.function.Tuple2<Command,List<String>>> parseCommandLine(String commandLine)
Reads the command line and retrieves the corresponding Command instance. Arguments passed to the command are also returned as a list.- Parameters:
commandLine
- the command line- Returns:
- the command with its arguments, if present
-
parseCommandLine
Optional<reactor.util.function.Tuple2<Command,List<String>>> parseCommandLine(List<String> commandLine)
Reads the command line and retrieves the corresponding Command instance. Arguments passed to the command are also returned as a list.- Parameters:
commandLine
- the command line as a list of string containing the command name as first element and arguments then- Returns:
- the command with its arguments, if present
-
getCommands
Set<Command> getCommands()
Gets an unmodifiable set of all commands available in the kernel.- Returns:
- a Set of Command
-
getCommandsGroupedByPlugins
Map<String,Set<Command>> getCommandsGroupedByPlugins()
Gets an unmodifiable map of all commands available in the kernel, grouped by plugin names.- Returns:
- a Map of String, Command
-
invokeCommand
reactor.core.publisher.Mono<Void> invokeCommand(Command cmd, Context ctx)
Invokes a command with the specified context.- Parameters:
cmd
- the command to invokectx
- the context of the command- Returns:
- a Mono that completes when the command has terminated. Any errors that may occur when running the command are transmitted through this Mono.
-
openReplyMenu
String openReplyMenu(Context ctx, discord4j.core.object.entity.Message msg, Map<String,java.util.function.Function<Context,reactor.core.publisher.Mono<Void>>> menuItems, boolean deleteOnReply, boolean deleteOnTimeout)
Opens a new reply menu with the given items.- Parameters:
ctx
- the context of the command this reply menu was opened frommsg
- The message containing the menumenuItems
- the menu itemsdeleteOnReply
- Whether to deletemsg
when the user has given a valid replydeleteOnTimeout
- Whether to deletemsg
when the user doesn't reply and the menu times out.- Returns:
- the identifier of the opened reply, or an empty string if the menu could not be opened.
-
closeReplyMenu
void closeReplyMenu(String identifier)
Closes a reply menu using its identifier.- Parameters:
identifier
- the identifier of the reply menu to close
-
-