Hierarchy

  • Command
    • ContextCommand

Constructors

Properties

aliases: readonly string[]

The aliases for the piece.

applicationCommandRegistry: ApplicationCommandRegistry

The application command registry associated with this command.

3.0.0

chatInputCommand?: SlashCommandBuilder
contextMenuCommand?: ContextMenuCommandBuilder
description: string

A basic summary about the command

1.0.0

detailedDescription: DetailedDescriptionCommand

Longer version of command's summary and how to use it

1.0.0

enabled: boolean

Whether or not the piece is enabled.

fullCategory: readonly string[]

The full category for the command, can be overridden by setting the Command.Options.fullCategory option.

If Command.Options.fullCategory is not set, then:

  • If the command is loaded from the file system, then this is the command's location in file system relative to the commands folder. For example, if you have a command located at commands/General/Information/info.ts then this property will be ['General', 'Info'].
  • If the command is virtual, then this will be [].

2.0.0

location: PieceLocation

The location metadata for the piece's file.

name: string

The name of the piece.

options: CommandOptions

The raw options passed to this Piece

preconditions: PreconditionContainerArray

The preconditions to be run.

1.0.0

rawName: string

The raw name of the command as provided through file name or constructor options.

This is exactly what is set by the developer, completely unmodified internally by the framework. Unlike the name which gets lowercased for storing it uniquely in the CommandStore.

store: CommandStore

The store that contains the piece.

strategy: IUnorderedStrategy

The strategy to use for the lexer.

1.0.0

typing: boolean

If SapphireClient.typing is true, it can be overridden for a specific command using this property, set via its options. Otherwise, this property will be ignored.

true

Accessors

  • get category(): null | string
  • The main category for the command, if any.

    This getter retrieves the first value of Command.fullCategory, if it has at least one item, otherwise it returns null.

    Returns null | string

    You can set Command.Options.fullCategory to override the built-in category resolution.

  • get container(): Container
  • A reference to the Container object for ease of use.

    Returns Container

    container

  • get parentCategory(): null | string
  • The parent category for the command.

    This getter retrieves the last value of Command.fullCategory, if it has at least one item, otherwise it returns null.

    Returns null | string

    You can set Command.Options.fullCategory to override the built-in category resolution.

  • get subCategory(): null | string
  • The sub-category for the command, if any.

    This getter retrieves the second value of Command.fullCategory, if it has at least two items, otherwise it returns null.

    Returns null | string

    You can set Command.Options.fullCategory to override the built-in category resolution.

Methods

  • Executes the autocomplete logic.

    :::tip

    You may use this, or alternatively create an InteractionHandler interaction handler to handle autocomplete interactions. Keep in mind that commands take precedence over interaction handlers.

    :::

    Parameters

    Returns unknown

  • The message pre-parse method. This method can be overridden by plugins to define their own argument parser.

    Parameters

    • message: Message<boolean>

      The message that triggered the command.

    • parameters: string

      The raw parameters as a single string.

    • context: MessageCommandContext

      The command-context used in this execution.

    Returns Awaitable<Args>

  • Per-piece listener that is called when the piece is loaded into the store. Useful to set-up asynchronous initialization tasks.

    Returns unknown

  • Per-piece listener that is called when the piece is unloaded from the store. Useful to set-up clean-up tasks.

    Returns unknown

  • Appends the Cooldown precondition when Command.Options.cooldownLimit and Command.Options.cooldownDelay are both non-zero.

    Parameters

    • options: CommandOptions

      The command options given from the constructor.

    Returns void

  • Appends the NSFW precondition if Command.Options.nsfw is set to true.

    Parameters

    • options: CommandOptions

      The command options given from the constructor.

    Returns void

  • Appends the ClientPermissions precondition when Command.Options.requiredClientPermissions resolves to a non-zero bitfield.

    Parameters

    • options: CommandOptions

      The command options given from the constructor.

    Returns void

  • Appends the UserPermissions precondition when Command.Options.requiredUserPermissions resolves to a non-zero bitfield.

    Parameters

    • options: CommandOptions

      The command options given from the constructor.

    Returns void

  • Appends the RunIn precondition based on the values passed, defaulting to null, which doesn't add a precondition.

    Parameters

    • options: CommandOptions

      The command options given from the constructor.

    Returns void

  • Registers the application commands that should be handled by this command.

    Parameters

    • registry: ApplicationCommandRegistry

      This command's registry

    Returns Awaitable<void>

  • Reloads the piece by loading the same path in the store.

    Returns Promise<void>

  • Resolves the Command.Options.runIn option into a Command.RunInTypes array.

    Parameters

    • types: CommandRunInUnion

      The types to resolve.

    Returns null | readonly ChannelType[]

    The resolved types, or null if no types were resolved.

  • Type-guard that ensures the command supports handling autocomplete interactions by checking if the handler for it is present

    Returns this is AutocompleteCommand

  • Type-guard that ensures the command supports chat input commands by checking if the handler for it is present

    Returns this is ChatInputCommand

  • Type-guard that ensures the command supports context menu commands by checking if the handler for it is present

    Returns this is ContextMenuCommand

  • Type-guard that ensures the command supports message commands by checking if the handler for it is present

    Returns this is MessageCommand

  • Defines the JSON.stringify behavior of the command.

    Returns CommandJSON

  • Unloads and disables the piece.

    Returns Promise<void>

  • Parameters

    • types: CommandRunInUnion | CommandSpecificRunIn

    Returns types is CommandSpecificRunIn