/** @module CommandInteraction */ import Interaction from "./Interaction"; import Member from "./Member"; import Message from "./Message"; import User from "./User"; import type Guild from "./Guild"; import Permission from "./Permission"; import type PrivateChannel from "./PrivateChannel"; import { type InteractionTypes } from "../Constants"; import type { ApplicationCommandInteractionData, InteractionContent, ModalData, RawApplicationCommandInteraction } from "../types/interactions"; import type Client from "../Client"; import type { AnyGuildTextChannel, AnyTextChannelWithoutGroup } from "../types/channels"; import type { JSONCommandInteraction } from "../types/json"; import type { Uncached } from "../types/shared"; /** Represents a command interaction. */ export default class CommandInteraction extends Interaction { private _cachedChannel; private _cachedGuild?; /** The permissions the bot has in the channel this interaction was sent from, if this interaction is sent from a guild. */ appPermissions: T extends AnyGuildTextChannel ? Permission : Permission | undefined; /** The ID of the channel this interaction was sent from. */ channelID: string; /** The data associated with the interaction. */ data: ApplicationCommandInteractionData; /** The id of the guild this interaction was sent from, if applicable. */ guildID: T extends AnyGuildTextChannel ? 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 AnyGuildTextChannel ? string : string | 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 AnyGuildTextChannel ? Member : Member | undefined; /** The permissions of the member associated with the invoking user, if this interaction is sent from a guild. */ memberPermissions: T extends AnyGuildTextChannel ? Permission : Permission | undefined; type: InteractionTypes.APPLICATION_COMMAND; /** The user that invoked this interaction. */ user: User; constructor(data: RawApplicationCommandInteraction, client: Client); /** The channel this interaction was sent from. */ get channel(): T extends AnyTextChannelWithoutGroup ? 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 AnyGuildTextChannel ? Guild : Guild | null; /** * Create a followup message. * @param options The options for creating the followup message. */ createFollowup(options: InteractionContent): Promise>; /** * Create a message through this interaction. This is an initial response, and more than one initial response cannot be used. Use `createFollowup`. * @param options The options for the message. */ createMessage(options: InteractionContent): Promise; /** * Respond to this interaction with a modal. This is an initial response, and more than one initial response cannot be used. * @param options The options for the modal. */ createModal(options: ModalData): Promise; /** * Defer this interaction. This is an initial response, and more than one initial response cannot be used. * @param flags The [flags](https://discord.com/developers/docs/resources/channel#message-object-message-flags) to respond with. */ defer(flags?: number): Promise; /** * Delete a follow-up message. * @param messageID The ID of the message. */ deleteFollowup(messageID: string): Promise; /** * Delete the original interaction response. */ deleteOriginal(): Promise; /** * Edit a followup message. * @param messageID The ID of the message. * @param options The options for editing the followup message. */ editFollowup(messageID: string, options: InteractionContent): Promise>; /** * Edit the original interaction response. * @param options The options for editing the original message. */ editOriginal(options: InteractionContent): Promise>; /** * Get a followup message. * @param messageID The ID of the message. */ getFollowup(messageID: string): Promise>; /** * Get the original interaction response. */ getOriginal(): Promise>; /** 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 CommandInteraction; /** 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 CommandInteraction; toJSON(): JSONCommandInteraction; }