Hierarchy

  • SlashCommandBuilder
    • GradioBot

Constructors

Properties

bot: undefined | Client<boolean>
commands: CommandsAdapter
default_member_permissions: undefined | null | string

The set of permissions represented as a bit set for the command.

default_permission: undefined | boolean

Whether this command is enabled by default when the application is added to a guild.

description: string

The description of this command.

description_localizations?: Partial<Record<
    | "id"
    | "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"
    | "es-419"
    | "sv-SE"
    | "th"
    | "tr"
    | "uk"
    | "vi", null | string>>

The description localizations of this command.

dm_permission: undefined | boolean

Indicates whether the command is available in direct messages with the application.

By default, commands are visible. This property is only for global commands.

gr: Client
name: string

The name of this command.

name_localizations?: Partial<Record<
    | "id"
    | "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"
    | "es-419"
    | "sv-SE"
    | "th"
    | "tr"
    | "uk"
    | "vi", null | string>>

The name localizations of this command.

nsfw: undefined | boolean

Whether this command is NSFW.

options: ToAPIApplicationCommandOptions[]

The options of this 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 SlashCommandOptionsOnlyBuilder

  • Adds a boolean option.

    Parameters

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

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

    Returns SlashCommandOptionsOnlyBuilder

  • Adds a channel option.

    Parameters

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

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

    Returns SlashCommandOptionsOnlyBuilder

  • Adds an integer option.

    Parameters

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

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

    Returns SlashCommandOptionsOnlyBuilder

  • Adds a mentionable option.

    Parameters

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

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

    Returns SlashCommandOptionsOnlyBuilder

  • Adds a number option.

    Parameters

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

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

    Returns SlashCommandOptionsOnlyBuilder

  • Adds a role option.

    Parameters

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

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

    Returns SlashCommandOptionsOnlyBuilder

  • Adds a string option.

    Parameters

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

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

    Returns SlashCommandOptionsOnlyBuilder

  • 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 SlashCommandOptionsOnlyBuilder

  • Handles and responds to the given ChatInputCommandInteraction.

    Parameters

    • interaction: ChatInputCommandInteraction<CacheType>

      The ChatInputCommandInteraction.

    Returns Promise<boolean>

    A boolean indicating whether the interaction was handled by this function.

  • Parses the given ChatInputCommandInteraction.

    Parameters

    • interaction: ChatInputCommandInteraction<CacheType>

      The ChatInputCommandInteraction to parse.

    Returns {
        data: Record<string, unknown> | unknown[];
        route: string;
    }

    The route and payload to send to the Gradio endpoint.

    • data: Record<string, unknown> | unknown[]
    • route: string
  • Parameters

    • id: undefined | string = process.env.BOT_ID
    • token: undefined | string = process.env.BOT_TOKEN

    Returns Promise<void>

  • Sets if the command is available in direct messages with the application.

    Parameters

    • enabled: undefined | null | boolean

      Whether the command should be enabled in direct messages

    Returns this

    By default, commands are visible. This method is only for global commands.

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

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

    Parameters

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

      The permissions bit field to set

    Returns this

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

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

  • Sets the description of this command.

    Parameters

    • description: string

      The description to use

    Returns this

  • Sets a description localization for this command.

    Parameters

    • locale:
          | "id"
          | "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"
          | "es-419"
          | "sv-SE"
          | "th"
          | "tr"
          | "uk"
          | "vi"

      The locale to set

    • localizedDescription: null | string

      The localized description for the given locale

    Returns this

  • Sets the description localizations for this command.

    Parameters

    • localizedDescriptions: null | Partial<Record<
          | "id"
          | "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"
          | "es-419"
          | "sv-SE"
          | "th"
          | "tr"
          | "uk"
          | "vi", null | string>>

      The object of localized descriptions to set

    Returns this

  • Sets whether this command is NSFW.

    Parameters

    • Optionalnsfw: boolean

      Whether this command is NSFW

    Returns this

  • Sets the name of this command.

    Parameters

    • name: string

      The name to use

    Returns this

  • Sets a name localization for this command.

    Parameters

    • locale:
          | "id"
          | "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"
          | "es-419"
          | "sv-SE"
          | "th"
          | "tr"
          | "uk"
          | "vi"

      The locale to set

    • localizedName: null | string

      The localized name for the given locale

    Returns this

  • Sets the name localizations for this command.

    Parameters

    • localizedNames: null | Partial<Record<
          | "id"
          | "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"
          | "es-419"
          | "sv-SE"
          | "th"
          | "tr"
          | "uk"
          | "vi", null | string>>

      The object of localized names to set

    Returns this

  • Serializes this builder to API-compatible JSON data.

    Returns RESTPostAPIChatInputApplicationCommandsJSONBody

    This method runs validations on the data before serializing it. As such, it may throw an error if the data is invalid.

  • Creates a new instance of GradioBot from a Gradio Client instance, Hugging Face Space, or a Gradio server URL.

    Parameters

    • gr: string | Client

      The Gradio Client instance, Hugging Face Spaces, or the Gradio server URL.

    • Optionalbot: Client<boolean>

      The Discord Client instance used to register and respond to commands.

    • Optionaloptions: AdaptOptions

      The options for adapting the Gradio API.

    Returns Promise<GradioBot>

""