Annotation Interface JDACommand


@Retention(RUNTIME) @Target(METHOD) public @interface JDACommand
An Annotation applicable to 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:
  • Element Details

    • name

      String[] name
      The 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 help
      The help string for a command.
      Returns:
      The help string for a command.
      Default:
      "no help available"
    • guildOnly

      boolean guildOnly
      Whether or not the command is only usable in a guild.
      Default true.
      Returns:
      true if the command can only be used in a guild, false otherwise.
      Default:
      true
    • requiredRole

      String requiredRole
      The name of a role required to use this command.
      Returns:
      The name of a role required to use this command.
      Default:
      ""
    • ownerCommand

      boolean ownerCommand
      Whether or not the command is owner only.
      Default true.
      Returns:
      true if the command is owner only, false otherwise.
      Default:
      false
    • arguments

      String arguments
      The arguments string for the command.
      Returns:
      The arguments string for the command.
      Default:
      ""
    • cooldown

      The JDACommand.Cooldown for the command.

      This holds both metadata for both the Command#cooldown and Command#cooldownScope.

      Returns:
      The @Cooldown for the command.
      Default:
      @com.jagrosh.jdautilities.command.annotation.JDACommand.Cooldown(0)
    • botPermissions

      net.dv8tion.jda.api.Permission[] botPermissions
      The Permissions 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[] userPermissions
      The Permissions 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 useTopicTags
      Whether or not this command uses topic tags.
      Default true.

      For more information on topic tags, see Command#usesTopicTags

      Returns:
      true if this command uses topic tags, false otherwise.
      Default:
      true
    • children

      String[] children
      The names of any methods representing child commands for this command.
      Returns:
      The names of any methods representing child commands.
      Default:
      {}
    • isHidden

      boolean isHidden
      Whether or not this command should remain hidden in the help builder.
      Returns:
      true if this command should remain hidden, false otherwise.
      Default:
      false
    • category

      The JDACommand.Category for this command.
      This holds data to properly locate a static field representing this command's Category.
      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)