public final class CommandHandler
extends java.lang.Object
| Modifier and Type | Method and Description |
|---|---|
CommandConfig |
findCommandAndGetConfig(java.lang.String name)
Useful for custom command inspection implementation.
|
java.util.Set<java.lang.String> |
getAllCommandNamesAndAliases()
Useful for custom command inspection implementation.
|
java.awt.Color |
getCommandListColor() |
java.lang.String |
getCommandsPrefix() |
java.awt.Color |
getErrorColor() |
java.awt.Color |
getInspectCommandColor() |
net.dv8tion.jda.api.JDA |
getJda() |
java.util.List<CommandConfig> |
getVisibleCommandConfigList()
Useful for custom command list implementation.
|
boolean |
isCommandListEnabled() |
boolean |
isInspectCommandEnabled() |
<T extends AbstractCommand> |
registerCommand(java.lang.Class<T> aClass)
Convenience method, equals to
registerCommand(Class, Function, CommandConfig) with
2nd and 3rd parameters of null. |
<T extends AbstractCommand> |
registerCommand(java.lang.Class<T> aClass,
CommandConfig config)
Convenience method, equals to
registerCommand(Class, Function, CommandConfig) with
2nd parameter of null. |
<T extends AbstractCommand> |
registerCommand(java.lang.Class<T> aClass,
java.util.function.Function<CommandHandler,T> supplier)
Convenience method, equals to
registerCommand(Class, Function, CommandConfig) with
3rd parameter of null. |
<T extends AbstractCommand> |
registerCommand(@NotNull java.lang.Class<T> aClass,
java.util.function.Function<CommandHandler,T> function,
CommandConfig config)
Registers a command to be handled.
Command annotation could be used alternatively, it is usually more convenient.Unlike using annotation to register, using the method provides an option to use a different from the AbstractCommand super class constructor for the command class. |
void |
start()
Initializes and starts listening for messages.
|
public void start()
public <T extends AbstractCommand> void registerCommand(@NotNull @NotNull java.lang.Class<T> aClass, java.util.function.Function<CommandHandler,T> function, CommandConfig config)
Command annotation could be used alternatively, it is usually more convenient.AbstractCommand super class constructor for the command class. T - subclass of AbstractCommandaClass - class of the commandfunction - a function to provide instances of the command with different from the
AbstractCommand super class constructor. A reference to
CommandHandler is given for super() call inside of the constructor.
If the parameter is null, a constructor with single parameter of
CommandHandler is expectedconfig - configuration of the command. If the parameter is null, the configuration
CommandConfig object is expected to be annotated with Config
inside of the command's classCommand,
Config,
CommandConfigBuilderpublic <T extends AbstractCommand> void registerCommand(java.lang.Class<T> aClass, java.util.function.Function<CommandHandler,T> supplier)
registerCommand(Class, Function, CommandConfig) with
3rd parameter of null.public <T extends AbstractCommand> void registerCommand(java.lang.Class<T> aClass, CommandConfig config)
registerCommand(Class, Function, CommandConfig) with
2nd parameter of null.public <T extends AbstractCommand> void registerCommand(java.lang.Class<T> aClass)
registerCommand(Class, Function, CommandConfig) with
2nd and 3rd parameters of null.public java.util.List<CommandConfig> getVisibleCommandConfigList()
CommandConfig with CommandListType.LISTEDpublic java.util.Set<java.lang.String> getAllCommandNamesAndAliases()
CmdInspectCommandpublic CommandConfig findCommandAndGetConfig(java.lang.String name)
CmdInspectCommandpublic net.dv8tion.jda.api.JDA getJda()
public java.lang.String getCommandsPrefix()
public java.awt.Color getCommandListColor()
public java.awt.Color getErrorColor()
public java.awt.Color getInspectCommandColor()
public boolean isCommandListEnabled()
public boolean isInspectCommandEnabled()