Annotation Interface JDACommand
Methods that will act as
Commands when added to a Client
using CommandClientBuilder#addAnnotatedModule() serving as metadata "constructors" for what
would be a class extending Command of the same functionality and settings.
The primary issue that command systems face when trying to implement "annotated command"
systems is that reflection is a powerful but also costly tool and requires much more overhead
than most other types systems.
To circumvent this, classes annotated with this are put through an AnnotatedModuleCompiler.
where they will be converted to Commands using CommandBuilder.
Classes that wish to be contain methods to be used as commands must be annotated with
@Module.
Following that, any methods of said class annotated with this annotation (whose names
are also given as parameters of the @Module annotation) will be registered to the
module and "compiled" through the AnnotatedModuleCompiler provided in CommandClientBuilder.
@JDACommand.Module(value = "example")
public class AnnotatedModuleCmd {
@JDACommand(
name = {"example", "test", "demo"},
help = "gives an example of what commands do"
)
public void example(CommandEvent) {
event.reply("Hey look! This would be the bot's reply if this was a command!");
}
}- Since:
- 1.7
- Author:
- Kaidan Gustave
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceA helper annotation to assist in location of Category instance.static @interfaceA value wrapper for what would beCommand#cooldownandCommand#cooldownScope.static @interfaceA helper annotation to assist in location of methods that will generate intoCommands. -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionThe arguments string for the command.net.dv8tion.jda.api.Permission[]ThePermissionsthe bot must have on a guild to use this command.TheJDACommand.Categoryfor this command.String[]The names of any methods representing child commands for this command.TheJDACommand.Cooldownfor the command.booleanWhether or not the command is only usable in a guild.The help string for a command.booleanWhether or not this command should remain hidden in the help builder.String[]The name and aliases of the command.booleanWhether or not the command is owner only.The name of a role required to use this command.net.dv8tion.jda.api.Permission[]ThePermissionsthe user must have on a guild to use this command.booleanWhether or not this command uses topic tags.
-
Element Details
-
name
String[] nameThe name and aliases of the command.The first index is the name, and following indices are aliases.
- Returns:
- An array of strings, the first one being the name of the command, and following ones being aliases.
- Default:
{"null"}
-
help
String helpThe help string for a command.- Returns:
- The help string for a command.
- Default:
"no help available"
-
guildOnly
boolean guildOnlyWhether or not the command is only usable in a guild.
Defaulttrue.- Returns:
trueif the command can only be used in a guild,falseotherwise.
- Default:
true
-
requiredRole
String requiredRoleThe name of a role required to use this command.- Returns:
- The name of a role required to use this command.
- Default:
""
-
ownerCommand
boolean ownerCommandWhether or not the command is owner only.
Defaulttrue.- Returns:
trueif the command is owner only,falseotherwise.
- Default:
false
-
arguments
String argumentsThe arguments string for the command.- Returns:
- The arguments string for the command.
- Default:
""
-
cooldown
JDACommand.Cooldown cooldownTheJDACommand.Cooldownfor the command.This holds both metadata for both the
Command#cooldownandCommand#cooldownScope.- Returns:
- The
@Cooldownfor the command.
- Default:
@com.jagrosh.jdautilities.command.annotation.JDACommand.Cooldown(0)
-
botPermissions
net.dv8tion.jda.api.Permission[] botPermissionsThePermissionsthe bot must have on a guild to use this command.- Returns:
- The required permissions the bot must have to use this command.
- Default:
{}
-
userPermissions
net.dv8tion.jda.api.Permission[] userPermissionsThePermissionsthe user must have on a guild to use this command.- Returns:
- The required permissions a user must have to use this command.
- Default:
{}
-
useTopicTags
boolean useTopicTagsWhether or not this command uses topic tags.
Defaulttrue.For more information on topic tags, see
Command#usesTopicTags- Returns:
trueif this command uses topic tags,falseotherwise.
- Default:
true
-
children
String[] childrenThe names of any methods representing child commands for this command.- Returns:
- The names of any methods representing child commands.
- Default:
{}
-
isHidden
boolean isHiddenWhether or not this command should remain hidden in the help builder.- Returns:
trueif this command should remain hidden,falseotherwise.
- Default:
false
-
category
JDACommand.Category categoryTheJDACommand.Categoryfor this command.
This holds data to properly locate a static field representing this command'sCategory.- Returns:
- The
@Categoryfor this command.
- Default:
@com.jagrosh.jdautilities.command.annotation.JDACommand.Category(name="null", location=com.jagrosh.jdautilities.command.annotation.JDACommand.Category.class)
-