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AAQ;QACJ,OAAO,IAAI,CAAC,kBAAkB,EAAE,IAAI,IAAI,CAAC,aAAa,KAAK,aAAa,CAAC,MAAM,CAAC;IACpF,CAAC;IAED;;OAEG;IACH,YAAY;QACR,OAAO,IAAI,CAAC,kBAAkB,EAAE,IAAI;YAChC,aAAa,CAAC,YAAY;YAC1B,aAAa,CAAC,UAAU;YACxB,aAAa,CAAC,UAAU;YACxB,aAAa,CAAC,iBAAiB;YAC/B,aAAa,CAAC,aAAa;SAC9B,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACnC,CAAC;IAED;;OAEG;IACH,cAAc;QACV,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,8BAA8B,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,aAAa;QACT,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,WAAW,CAAC;IACrD,CAAC;IAED;;OAEG;IACH,iBAAiB;QACb,OAAO,IAAI,CAAC,IAAI,KAAK,eAAe,CAAC,IAAI,CAAC;IAC9C,CAAC;CAEJ","sourcesContent":["import type { ComponentBuilder, EmbedBuilder, ModalBuilder } from \"@discordjs/builders\";\nimport { DiscordSnowflake } from \"@sapphire/snowflake\";\nimport { APIAllowedMentions, APIButtonComponent, APIEmbed, APIInteraction, APIModalInteractionResponseCallbackData, APISelectMenuComponent, ApplicationCommandType, ComponentType, InteractionType, LocaleString } from \"discord-api-types/v10\";\nimport { PartialChannel, Permissions } from \"../index.mjs\";\nimport { InteractionGuildMember } from \"../payloads/Member.mjs\";\nimport User from \"../payloads/User.mjs\";\nimport type ApplicationCommandInteraction from \"./ApplicationCommandInteraction.mjs\";\nimport type AutocompleteInteraction from \"./AutocompleteInteraction.mjs\";\nimport type ButtonInteraction from \"./ButtonComponentInteraction.mjs\";\nimport type ChatInputInteraction from \"./ChatInputInteraction.mjs\";\nimport type MessageCommandInteraction from \"./MessageCommandInteraction.mjs\";\nimport type MessageComponentInteraction from \"./MessageComponentInteraction.mjs\";\nimport type ModalSubmitInteraction from \"./ModalSubmitInteraction.mjs\";\nimport type SelectMenuInteraction from \"./SelectMenuComponentInteraction.mjs\";\nimport type UserCommandInteraction from \"./UserCommandInteraction.mjs\";\nimport type PingInteraction from \"./PingInteraction.mjs\";\nimport AttachmentBuilder from \"../basic/AttachmentBuilder.mjs\";\n\n\nexport default class BaseInteraction {\n    /** ID of the interaction */\n    id: string;\n    /** A continuation token for responding to the interaction */\n    token: string;\n    /** ID of the application this interaction is for */\n    applicationId: string;\n    /** The channel it was sent from */\n    channel?: PartialChannel;\n    /** The guild it was sent from */\n    guildId?: string;\n    /** Guild member data for the invoking user, including permissions */\n    member?: InteractionGuildMember;\n    /** User object for the invoking user */\n    user: User;\n    /** The user id for the invoking user */\n    userId: string;\n    /** The type of interaction */\n    type: InteractionType;\n    /** Set of permissions the app or bot has within the channel the interaction was sent from */\n    applicationPermissions?: Permissions;\n    /** The guild's preferred locale */\n    guildLocale?: LocaleString;\n\n    constructor(interaction: APIInteraction) {\n\n        this.id = interaction.id;\n        this.token = interaction.token;\n\n        this.applicationId = interaction.application_id;\n        this.applicationPermissions = new Permissions(interaction.app_permissions ?? \"0\");\n\n        this.channel = interaction.channel;\n        this.guildId = interaction.guild_id;\n        this.user = new User(interaction.user || interaction.member!.user);\n        this.userId = this.user.id;\n        if (interaction.member && this.guildId) this.member = new InteractionGuildMember(interaction.member, this.guildId);\n        this.type = interaction.type;\n\n        this.guildLocale = interaction.guild_locale;\n\n    }\n\n    /** The webhook url for this interaction */\n    get webhookUrl(): string {\n        return `https://discord.com/api/v10/webhooks/${this.applicationId}/${this.token}`;\n    }\n\n    /** The time the interaction was made */\n    get createdAt(): Date {\n        return new Date(DiscordSnowflake.timestampFrom(this.id));\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link ApplicationCommandInteraction}.\n     */\n    isApplicationCommand(): this is ApplicationCommandInteraction {\n        return this.type === InteractionType.ApplicationCommand;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link ChatInputInteraction}.\n     */\n    isChatInputCommand(): this is ChatInputInteraction {\n        return this.isApplicationCommand() && this.commandType === ApplicationCommandType.ChatInput;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link UserCommandInteraction}.\n     */\n    isUserCommand(): this is UserCommandInteraction {\n        return this.isApplicationCommand() && this.commandType === ApplicationCommandType.User;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link MessageCommandInteraction}.\n     */\n    isMessageCommand(): this is MessageCommandInteraction {\n        return this.isApplicationCommand() && this.commandType === ApplicationCommandType.Message;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link MessageComponentInteraction}.\n     */\n    isMessageComponent(): this is MessageComponentInteraction {\n        return this.type === InteractionType.MessageComponent;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link ButtonInteraction}.\n     */\n    isButton(): this is ButtonInteraction {\n        return this.isMessageComponent() && this.componentType === ComponentType.Button;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link SelectMenuInteraction}.\n     */\n    isSelectMenu(): this is SelectMenuInteraction {\n        return this.isMessageComponent() && [\n            ComponentType.StringSelect,\n            ComponentType.UserSelect,\n            ComponentType.RoleSelect,\n            ComponentType.MentionableSelect,\n            ComponentType.ChannelSelect,\n        ].includes(this.componentType);\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link AutocompleteInteraction}.\n     */\n    isAutocomplete(): this is AutocompleteInteraction {\n        return this.type === InteractionType.ApplicationCommandAutocomplete;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link ModalSubmitInteraction}.\n     */\n    isModalSubmit(): this is ModalSubmitInteraction {\n        return this.type === InteractionType.ModalSubmit;\n    }\n\n    /**\n     * Indicates whether this interaction is a {@link PingInteraction}.\n     */\n    isPingInteraction(): this is PingInteraction {\n        return this.type === InteractionType.Ping;\n    }\n\n}\n\nexport type InteractionResponseData = {\n    /** The content of a message */\n    content?: string,\n    /** The embeds of a message */\n    embeds?: (APIEmbed | EmbedBuilder)[],\n    /** The components of a message */\n    components?: (APIButtonComponent | APISelectMenuComponent | ComponentBuilder)[]\n    /** Is the message ephemeral? */\n    ephemeral?: boolean,\n    /** Who can be mentioned? */\n    allowed_mentions?: APIAllowedMentions,\n    /** The attachments to send */\n    attachments?: AttachmentBuilder[]\n};\n\nexport type InteractionModalResponseData = APIModalInteractionResponseCallbackData | ModalBuilder;\n"]}