Represents the payload for creating or updating a Discord application command. This class encapsulates all the parameters needed to define a command and provides necessary validation for the fields.

Constructors

  • Creates a new CommandPayload instance.

    Parameters

    • Optionaldata: {
          default_member_permissions?: string;
          default_permission?: boolean;
          description?: string;
          description_localizations?: {
              [key: string]: string;
          };
          name: string;
          name_localizations?: {
              [key: string]: string;
          };
          nsfw?: boolean;
          options?: any[];
          type?: number;
      }

      Optional initial data to set in the payload.

      • Optionaldefault_member_permissions?: string
      • Optionaldefault_permission?: boolean
      • Optionaldescription?: string
      • Optionaldescription_localizations?: {
            [key: string]: string;
        }
        • [key: string]: string
      • name: string
      • Optionalname_localizations?: {
            [key: string]: string;
        }
        • [key: string]: string
      • Optionalnsfw?: boolean
      • Optionaloptions?: any[]
      • Optionaltype?: number

    Returns CommandPayload

Accessors

  • get defaultMemberPermissions(): string
  • Gets the default member permissions for the command.

    Returns string

    A string representing the default member permissions as a bit set.

  • set defaultMemberPermissions(value): void
  • Sets the default member permissions for the command. The permissions are represented as a bitwise string.

    Parameters

    • value: string

      A string representing the default permissions as a bit set.

    Returns void

  • get defaultPermission(): boolean
  • Gets whether the command is enabled by default.

    Returns boolean

    True if the command is enabled by default, false otherwise.

  • set defaultPermission(value): void
  • Sets whether the command is enabled by default.

    Parameters

    • value: boolean

      True if the command should be enabled by default, false otherwise.

    Returns void

  • get description(): string
  • Gets the description of the command.

    Returns string

    The description of the command.

  • set description(value): void
  • Sets the description of the command. The description must be between 1 and 100 characters for CHAT_INPUT commands.

    Parameters

    • value: string

      The description of the command.

    Returns void

    Error if the description is not within the allowed length (1-100 characters).

  • get descriptionLocalizations(): {
        [key: string]: string;
    }
  • Gets the localization dictionary for the command's description.

    Returns {
        [key: string]: string;
    }

    A dictionary of localized descriptions with locale keys.

    • [key: string]: string
  • set descriptionLocalizations(value): void
  • Sets the localization dictionary for the command's description.

    Parameters

    • value: {
          [key: string]: string;
      }

      A dictionary with locale keys and localized description strings.

      • [key: string]: string

    Returns void

  • get name(): string
  • Gets the name of the command.

    Returns string

    The name of the command.

  • set name(value): void
  • Sets the name of the command. The name must be between 1 and 32 characters.

    Parameters

    • value: string

      The name of the command.

    Returns void

    Error if the name is not within the allowed length (1-32 characters).

  • get nameLocalizations(): {
        [key: string]: string;
    }
  • Gets the localization dictionary for the command's name.

    Returns {
        [key: string]: string;
    }

    A dictionary of localized names with locale keys.

    • [key: string]: string
  • set nameLocalizations(value): void
  • Sets the localization dictionary for the command's name.

    Parameters

    • value: {
          [key: string]: string;
      }

      A dictionary with locale keys and localized name strings.

      • [key: string]: string

    Returns void

  • get nsfw(): boolean
  • Gets whether the command is age-restricted (NSFW).

    Returns boolean

    True if the command is NSFW, false otherwise.

  • set nsfw(value): void
  • Sets whether the command is age-restricted (NSFW).

    Parameters

    • value: boolean

      True if the command should be marked as NSFW, false otherwise.

    Returns void

  • get options(): any[]
  • Gets the options for the command.

    Returns any[]

    An array of command options.

  • set options(value): void
  • Sets the options for the command. Options are the parameters for the command, and the maximum number allowed is 25.

    Parameters

    • value: any[]

      An array of command options.

    Returns void

    Error if more than 25 options are provided.

  • get type(): number
  • Gets the type of the command.

    Returns number

    The type of the command.

  • set type(value): void
  • Sets the type of the command. The type determines whether the command is a CHAT_INPUT, USER, or MESSAGE command.

    Parameters

    • value: number

      The command type as a number.

    Returns void

Methods

  • Converts the command payload to a JSON-serializable object. This method ensures that only the defined fields are included in the output.

    Returns any

    A JSON-serializable representation of the command payload.