UNPKG

oceanic.js

Version:

A NodeJS library for interfacing with Discord.

65 lines (64 loc) 5.07 kB
/** @module AutocompleteInteraction */ import Interaction from "./Interaction"; import type Member from "./Member"; import type User from "./User"; import type Guild from "./Guild"; import Permission from "./Permission"; import type PrivateChannel from "./PrivateChannel"; import type Entitlement from "./Entitlement"; import type TestEntitlement from "./TestEntitlement"; import { type InteractionTypes, type InteractionContextTypes } from "../Constants"; import type { AuthorizingIntegrationOwners, AutocompleteChoice, AutocompleteInteractionData, InteractionCallbackResponse, InteractionGuild, RawAutocompleteInteraction } from "../types/interactions"; import type Client from "../Client"; import type { AnyTextableGuildChannel, AnyInteractionChannel } from "../types/channels"; import type { JSONAutocompleteInteraction } from "../types/json"; import type { Uncached } from "../types/shared"; /** Represents an autocomplete interaction. */ export default class AutocompleteInteraction<T extends AnyInteractionChannel | Uncached = AnyInteractionChannel | Uncached> extends Interaction { private _cachedChannel; private _cachedGuild?; /** The permissions the bot has in the channel this interaction was sent from. If in a dm/group dm, this will contain `ATTACH_FILES`, `EMBED_LINKS`, and `MENTION_EVERYONE`. In addition, `USE_EXTERNAL_EMOJIS` will be included for DMs with the app's bot user. */ appPermissions: Permission; /** The maximum size limit per attachment. This will be 10MiB by default, unless the user that created this interaction has a Nitro subscription or the guild it was sent from has been boosted to level 2 or above. */ attachmentSizeLimit: number; /** Details about the authorizing user or server for the installation(s) relevant to the interaction. See [Discord's docs](https://discord.com/developers/docs/interactions/receiving-and-responding#interaction-object-authorizing-integration-owners-object) for more information. */ authorizingIntegrationOwners: AuthorizingIntegrationOwners; /** The ID of the channel this interaction was sent from. */ channelID: string; /** The context this interaction was sent from. */ context?: InteractionContextTypes; /** The data associated with the interaction. */ data: AutocompleteInteractionData; /** The entitlements for the user that created this interaction, and the guild it was created in. */ entitlements: Array<Entitlement | TestEntitlement>; /** The id of the guild this interaction was sent from, if applicable. */ guildID: T extends AnyTextableGuildChannel ? string : string | null; /** The preferred [locale](https://discord.com/developers/docs/reference#locales) of the guild this interaction was sent from, if applicable. */ guildLocale: T extends AnyTextableGuildChannel ? string : string | undefined; /** The partial guild this interaction was sent from, if applicable. */ guildPartial?: T extends AnyTextableGuildChannel ? InteractionGuild : InteractionGuild | undefined; /** The [locale](https://discord.com/developers/docs/reference#locales) of the invoking user. */ locale: string; /** The member associated with the invoking user, if this interaction is sent from a guild. */ member: T extends AnyTextableGuildChannel ? Member : Member | null; /** The permissions of the member associated with the invoking user, if this interaction is sent from a guild. */ memberPermissions: T extends AnyTextableGuildChannel ? Permission : Permission | null; type: InteractionTypes.APPLICATION_COMMAND_AUTOCOMPLETE; /** The user that invoked this interaction. */ user: User; constructor(data: RawAutocompleteInteraction, client: Client); /** The channel this interaction was sent from. */ get channel(): T extends AnyInteractionChannel ? T : undefined; /** The guild this interaction was sent from, if applicable. This will throw an error if the guild is not cached. */ get guild(): T extends AnyTextableGuildChannel ? Guild : Guild | null; /** Whether this interaction belongs to a cached guild channel. The only difference on using this method over a simple if statement is to easily update all the interaction properties typing definitions based on the channel it belongs to. */ inCachedGuildChannel(): this is AutocompleteInteraction<AnyTextableGuildChannel>; /** Whether this interaction belongs to a private channel (PrivateChannel or uncached). The only difference on using this method over a simple if statement is to easily update all the interaction properties typing definitions based on the channel it belongs to. */ inPrivateChannel(): this is AutocompleteInteraction<PrivateChannel | Uncached>; /** * Acknowledge this interaction with a set of choices. This is an initial response, and more than one initial response cannot be used. * @param choices The choices to send. */ result(choices: Array<AutocompleteChoice>): Promise<InteractionCallbackResponse<T>>; toJSON(): JSONAutocompleteInteraction; }