Class Command

java.lang.Object
com.reign.kat.lib.command.Command
Direct Known Subclasses:
ButtonTestCommand, ClearPlaylistCommand, CommandExceptionTestCommand, DebugParentCommand, HelpCommand, JoinCommand, KillCommand, LeaveCommand, LevelCommand, LoopCommand, LyricsCommand, MoveCommand, NowPlayingCommand, ParentCommand, PlayCommand, PlayNextCommand, PrefixCommand, QueueCommand, RemoveCommand, SeekCommand, ShuffleCommand, SkipCommand, SlapCommand, TestCommand, TimingCommand, VoiceRecogDebugCommand, VoiceStateCommand

public abstract class Command extends Object
  • Field Details

    • log

      protected static final org.slf4j.Logger log
    • name

      public final String name
      Name of the Command
    • requiredPermission

      protected PermissionGroupType requiredPermission
      Required permission to run the command
    • requiredDiscordPermission

      protected int requiredDiscordPermission
      Required Discord permission to run the command
    • converters

      public final ArrayList<Converter<?>> converters
      List of argument Converters, parsed on command execution
    • precommands

      List of pre commands which are ran before command execution
  • Constructor Details

  • Method Details

    • addConverter

      public void addConverter(Converter<?> converter)
      Add a Converter to the command
    • addPreCommand

      public void addPreCommand(BiFunction<Context,CommandParameters,PreCommandResult> precommand)
      Add a Pre command to the command
    • updateSlashData

      public net.dv8tion.jda.api.interactions.commands.build.CommandData updateSlashData()
    • registerSubcommand

      public void registerSubcommand(Command command)
    • getSubcommand

      public Command getSubcommand(String alias)
    • getAliases

      public HashSet<String> getAliases()
    • getPrimaryAlias

      public String getPrimaryAlias()
    • getName

      public String getName()
    • getDescription

      public String getDescription()
    • setShowTyping

      public void setShowTyping(boolean status)
    • isShowTyping

      public boolean isShowTyping()
    • getRequiredCount

      public int getRequiredCount()
    • getSignature

      public String getSignature()
      Returns the argument signature for the command.
      For example, the command
      !kick UserID opt:reason

      would build a signature string of:-
      kick <user:User> [reason: String]
      Returns:
      String signature
    • setRequiredPermissionGroup

      public void setRequiredPermissionGroup(PermissionGroupType permission)
      Set the required permission type a user must have to execute the command.
      Parameters:
      permission - PermissionGroupType to limit execution to (and above).
    • setRequiredDiscordPermission

      public void setRequiredDiscordPermission(int permBitfield)
      Set the required Discord permissions a user must have to execute the command. Examples: MANAGE_MESSAGES, ADMINISTRATOR`.
      It may be better to use setRequiredPermissionGroup instead, unless the command action would require a Discord permission - a command to delete messages, for example.
      Parameters:
      permBitfield - DiscordPermission bitfield of permissions.
    • isPrivileged

      public boolean isPrivileged(net.dv8tion.jda.api.entities.Member member, net.dv8tion.jda.api.entities.channel.concrete.TextChannel channel)
    • execute

      public abstract void execute(Context ctx, CommandParameters args) throws Exception
      Throws:
      Exception
    • executeCommands

      public void executeCommands(Context ctx, List<String> args) throws Exception
      Calls the parent command before calling a subcommand
      Parameters:
      ctx - Context of the command
      args - string args to convert into Converters
      Throws:
      Exception
    • invokeCommand

      public void invokeCommand(Context c, CommandParameters args) throws Exception
      Throws:
      Exception
    • hasChildren

      public boolean hasChildren()