Annotation Interface TextCommand


@Retention(RUNTIME) @Target(METHOD) public @interface TextCommand
Marks a method as a text command handler. The method must accept a single parameter of type CommandContext.

Example:

@TextCommand("hello")
public void hello(CommandContext ctx) {
    ctx.reply("Hello, " + ctx.getUser().getName() + "!");
}

With Aliases:

@TextCommand(value = "help", aliases = {"h", "?"})
public void help(CommandContext ctx) {
    ctx.reply("Available commands: ...");
}

With Permissions:

@TextCommand(value = "kick", permissions = {Permission.KICK_MEMBERS})
public void kick(CommandContext ctx) {
    // Only users with KICK_MEMBERS can use this
}
  • Element Details

    • value

      String value
      Returns:
      the primary name of the command that users will type to invoke it
    • aliases

      String[] aliases
      Returns:
      array of alternative names that can be used to invoke the command
      Default:
      {}
    • description

      String description
      Returns:
      the description of the command, used for help messages and command listings
      Default:
      ""
    • usage

      String usage
      Returns:
      the usage syntax of the command, used to show users how to properly invoke it
      Default:
      ""
    • permissions

      net.dv8tion.jda.api.Permission[] permissions
      Returns:
      array of required permissions that users must have to execute the command
      Default:
      {}