@Retention(value=RUNTIME)
@Target(value=METHOD)
public @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!");
}
}
JDACommand.Module
Modifier and Type | Optional Element and Description |
---|---|
java.lang.String |
arguments
The arguments string for the command.
|
net.dv8tion.jda.core.Permission[] |
botPermissions
The
Permissions the bot must have
on a guild to use this command. |
JDACommand.Category |
category
The
JDACommand.Category for this command. |
java.lang.String[] |
children
The names of any methods representing child commands for this command.
|
JDACommand.Cooldown |
cooldown
The
JDACommand.Cooldown for the command. |
boolean |
guildOnly
Whether or not the command is only usable in a guild.
|
java.lang.String |
help
The help string for a command.
|
boolean |
isHidden
Whether or not this command should remain hidden in the help builder.
|
java.lang.String[] |
name
The name and aliases of the command.
|
boolean |
ownerCommand
Whether or not the command is owner only.
|
java.lang.String |
requiredRole
The name of a role required to use this command.
|
net.dv8tion.jda.core.Permission[] |
userPermissions
The
Permissions the user must have
on a guild to use this command. |
boolean |
useTopicTags
Whether or not this command uses topic tags.
|
public abstract java.lang.String[] name
The first index is the name, and following indices are aliases.
public abstract java.lang.String help
public abstract boolean guildOnly
true
.true
if the command can only be used in a guild,
false
otherwise.public abstract java.lang.String requiredRole
public abstract boolean ownerCommand
true
.true
if the command is owner only, false
otherwise.public abstract java.lang.String arguments
public abstract JDACommand.Cooldown cooldown
JDACommand.Cooldown
for the command.
This holds both metadata for both the
Command#cooldown
and Command#cooldownScope
.
@Cooldown
for the command.public abstract net.dv8tion.jda.core.Permission[] botPermissions
Permissions
the bot must have
on a guild to use this command.public abstract net.dv8tion.jda.core.Permission[] userPermissions
Permissions
the user must have
on a guild to use this command.public abstract boolean useTopicTags
true
.
For more information on topic tags, see
Command#usesTopicTags
true
if this command uses topic tags, false
otherwise.public abstract java.lang.String[] children
public abstract boolean isHidden
true
if this command should remain hidden, false
otherwise.public abstract JDACommand.Category category
JDACommand.Category
for this command.
Category
.@Category
for this command.