Class SlashCommand


public abstract class SlashCommand extends BaseCommandRequirements
Represents a single Slash Command.
Since:
v1.5
See Also:
  • Method Details

    • execute

      public void execute(net.dv8tion.jda.api.events.interaction.command.SlashCommandInteractionEvent event)
      Method that should be overridden for all Slash Commands that should be executed.
      
       public class PingCommand extends SlashCommand {
      
           public PingCommand() {
               setCommandData(Commands.slash("ping", "Ping!"));
           }
      
          @Override
          public void execute(SlashCommandInteractionEvent event) {
       		event.reply("Pong!").queue();
          }
      
       }
       
      Since:
      v1.5
    • getSlashCommandData

      public final net.dv8tion.jda.api.interactions.commands.build.SlashCommandData getSlashCommandData()
    • setSlashCommandData

      public final void setSlashCommandData(net.dv8tion.jda.api.interactions.commands.build.SlashCommandData commandData)
      Sets this commands' SlashCommandData.
      Parameters:
      commandData - The SlashCommandData which should be used for this command.
    • getSubcommands

      public final Set<SlashCommand.Subcommand> getSubcommands()
    • addSubcommands

      public final void addSubcommands(SlashCommand.Subcommand... classes)
      Sets all Subcommands that belong to this "base" command.
      Parameters:
      classes - The classes (must extend SlashCommand.Subcommand) which should be registered as subcommands.
    • getSubcommandGroups

      public final Map<net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData,Set<SlashCommand.Subcommand>> getSubcommandGroups()
    • addSubcommandGroups

      public final void addSubcommandGroups(Map<net.dv8tion.jda.api.interactions.commands.build.SubcommandGroupData,Set<SlashCommand.Subcommand>> groups)
      Sets all Subcommand Groups that belong to this "base" command.
      Parameters:
      groups - A map of the SubcommandGroupData and their corresponding SlashCommand.Subcommands.