Class Command<T>

Type Parameters

  • T = unknown

Hierarchy

  • SlashCommandBuilder
    • Command

Constructors

  • Type Parameters

    • T = unknown

    Parameters

    • name: string
    • description: string

    Returns Command<T>

Properties

default_member_permissions: undefined | null | string

Set of permissions represented as a bit set for the command

default_permission: undefined | boolean

Whether the command is enabled by default when the app is added to a guild

Deprecated

This property is deprecated and will be removed in the future. You should use setDefaultMemberPermissions or setDMPermission instead.

description: string

The description of this slash command

description_localizations?: Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", null | string>>

The localized descriptions for this command

dm_permission: undefined | boolean

Indicates whether the command is available in DMs with the application, only for globally-scoped commands. By default, commands are visible.

handler: Handler<T> = ...
name: string

The name of this slash command

name_localizations?: Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", null | string>>

The localized names for this command

options: ToAPIApplicationCommandOptions[]

The options of this slash command

Methods

  • Adds an attachment option

    Parameters

    • input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds a boolean option

    Parameters

    • input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds a channel option

    Parameters

    • input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds an integer option

    Parameters

    • input: SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, "setAutocomplete"> | Omit<SlashCommandIntegerOption, "addChoices"> | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption | Omit<SlashCommandIntegerOption, "setAutocomplete"> | Omit<SlashCommandIntegerOption, "addChoices">)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds a mentionable option

    Parameters

    • input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds a number option

    Parameters

    • input: SlashCommandNumberOption | Omit<SlashCommandNumberOption, "setAutocomplete"> | Omit<SlashCommandNumberOption, "addChoices"> | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption | Omit<SlashCommandNumberOption, "setAutocomplete"> | Omit<SlashCommandNumberOption, "addChoices">)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds a role option

    Parameters

    • input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds a string option

    Parameters

    • input: SlashCommandStringOption | Omit<SlashCommandStringOption, "setAutocomplete"> | Omit<SlashCommandStringOption, "addChoices"> | ((builder: SlashCommandStringOption) => SlashCommandStringOption | Omit<SlashCommandStringOption, "setAutocomplete"> | Omit<SlashCommandStringOption, "addChoices">)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Adds a new subcommand to this command

    Parameters

    • input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)

      A function that returns a subcommand builder, or an already built builder

    Returns SlashCommandSubcommandsOnlyBuilder

  • Adds a new subcommand group to this command

    Parameters

    • input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)

      A function that returns a subcommand group builder, or an already built builder

    Returns SlashCommandSubcommandsOnlyBuilder

  • Adds a user option

    Parameters

    • input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)

      A function that returns an option builder, or an already built builder

    Returns Omit<Command<T>, "addSubcommand" | "addSubcommandGroup">

  • Parameters

    • interaction: CommandInteraction<CacheType>

    Returns boolean

  • Sets if the command is available in DMs with the application, only for globally-scoped commands. By default, commands are visible.

    See

    https://discord.com/developers/docs/interactions/application-commands#permissions

    Parameters

    • enabled: undefined | null | boolean

      If the command should be enabled in DMs

    Returns Command<T>

  • Sets the default permissions a member should have in order to run the command.

    Note: You can set this to '0' to disable the command by default.

    See

    https://discord.com/developers/docs/interactions/application-commands#permissions

    Parameters

    • permissions: undefined | null | string | number | bigint

      The permissions bit field to set

    Returns Command<T>

  • Sets whether the command is enabled by default when the application is added to a guild.

    Note: If set to false, you will have to later PUT the permissions for this command.

    See

    https://discord.com/developers/docs/interactions/application-commands#permissions

    Deprecated

    Use setDefaultMemberPermissions or setDMPermission instead.

    Parameters

    • value: boolean

      Whether or not to enable this command by default

    Returns Command<T>

  • Sets the description

    Parameters

    • description: string

      The description

    Returns Command<T>

  • Sets a description localization

    Parameters

    • locale: "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi"

      The locale to set a description for

    • localizedDescription: null | string

      The localized description for the given locale

    Returns Command<T>

  • Sets the description localizations

    Parameters

    • localizedDescriptions: null | Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", null | string>>

      The dictionary of localized descriptions to set

    Returns Command<T>

  • Sets the name

    Parameters

    • name: string

      The name

    Returns Command<T>

  • Sets a name localization

    Parameters

    • locale: "en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi"

      The locale to set a description for

    • localizedName: null | string

      The localized description for the given locale

    Returns Command<T>

  • Sets the name localizations

    Parameters

    • localizedNames: null | Partial<Record<"en-US" | "en-GB" | "bg" | "zh-CN" | "zh-TW" | "hr" | "cs" | "da" | "nl" | "fi" | "fr" | "de" | "el" | "hi" | "hu" | "it" | "ja" | "ko" | "lt" | "no" | "pl" | "pt-BR" | "ro" | "ru" | "es-ES" | "sv-SE" | "th" | "tr" | "uk" | "vi", null | string>>

      The dictionary of localized descriptions to set

    Returns Command<T>

  • Returns the final data that should be sent to Discord.

    Note: Calling this function will validate required properties based on their conditions.

    Returns RESTPostAPIApplicationCommandsJSONBody

Generated using TypeDoc