Annotation Interface JDACommand
Method
s that will act as
Command
s 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
Modifier and TypeClassDescriptionstatic @interface
A helper annotation to assist in location of Category instance.static @interface
A value wrapper for what would beCommand#cooldown
andCommand#cooldownScope
.static @interface
A helper annotation to assist in location of methods that will generate intoCommand
s. -
Optional Element Summary
Modifier and TypeOptional ElementDescriptionThe arguments string for the command.net.dv8tion.jda.api.Permission[]
ThePermissions
the bot must have on a guild to use this command.TheJDACommand.Category
for this command.String[]
The names of any methods representing child commands for this command.TheJDACommand.Cooldown
for the command.boolean
Whether or not the command is only usable in a guild.The help string for a command.boolean
Whether or not this command should remain hidden in the help builder.String[]
The name and aliases of the command.boolean
Whether or not the command is owner only.The name of a role required to use this command.net.dv8tion.jda.api.Permission[]
ThePermissions
the user must have on a guild to use this command.boolean
Whether 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:
true
if the command can only be used in a guild,false
otherwise.
- 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:
true
if the command is owner only,false
otherwise.
- Default:
false
-
arguments
String argumentsThe arguments string for the command.- Returns:
- The arguments string for the command.
- Default:
""
-
cooldown
JDACommand.Cooldown cooldownTheJDACommand.Cooldown
for the command.This holds both metadata for both the
Command#cooldown
andCommand#cooldownScope
.- Returns:
- The
@Cooldown
for the command.
- Default:
@com.jagrosh.jdautilities.command.annotation.JDACommand.Cooldown(0)
-
botPermissions
net.dv8tion.jda.api.Permission[] botPermissionsThePermissions
the 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[] userPermissionsThePermissions
the 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:
true
if this command uses topic tags,false
otherwise.
- 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:
true
if this command should remain hidden,false
otherwise.
- Default:
false
-
category
JDACommand.Category categoryTheJDACommand.Category
for this command.
This holds data to properly locate a static field representing this command'sCategory
.- Returns:
- The
@Category
for this command.
- Default:
@com.jagrosh.jdautilities.command.annotation.JDACommand.Category(name="null", location=com.jagrosh.jdautilities.command.annotation.JDACommand.Category.class)
-