From f1312f779981caaad364b938c2e4848ee2884169 Mon Sep 17 00:00:00 2001 From: Starman <30315137+Starman3787@users.noreply.github.com> Date: Mon, 4 Nov 2024 13:32:32 +0000 Subject: [PATCH] add options field --- src/structures/Interaction.js | 21 +++++++++++++++++++++ test/structures/Interaction.js | 11 +++++++++++ 2 files changed, 32 insertions(+) diff --git a/src/structures/Interaction.js b/src/structures/Interaction.js index 9e5a03fa..9cd15fb6 100644 --- a/src/structures/Interaction.js +++ b/src/structures/Interaction.js @@ -18,6 +18,7 @@ class Interaction { #_channel_id; #token; #member; + #options; /** * Creates the structure for an interaction. * @param {Client} client The client instance. @@ -82,6 +83,13 @@ class Interaction { * @private */ this.#token = data.token; + + /** + * The options provided with the interaction. + * @type {Array} + * @private + */ + this.#options = data.data.options; } /** @@ -154,6 +162,16 @@ class Interaction { return this.#member; } + /** + * The options provided with the interaction. + * @type {Array} + * @readonly + * @public + */ + get options() { + return this.#options; + } + /** * Prompts a user to enter text using a modal. * @param {Object} options Modal options. @@ -357,6 +375,9 @@ class Interaction { channel_id: this.channelId, member: this.member.toJSON(format), type: this.type, + data: { + options: this.options, + }, }; } } diff --git a/test/structures/Interaction.js b/test/structures/Interaction.js index 1c7e2dd5..f4e7c8e2 100644 --- a/test/structures/Interaction.js +++ b/test/structures/Interaction.js @@ -26,6 +26,7 @@ describe("Interaction", function () { expect(interaction).to.have.property("guildId"); expect(interaction).to.have.property("channelId"); expect(interaction).to.have.property("member"); + expect(interaction).to.have.property("options"); expect(interaction).to.have.property("guild"); expect(interaction).to.have.property("channel"); expect(interaction).to.have.property("textPrompt"); @@ -103,6 +104,16 @@ describe("Interaction", function () { }); }); + context("check options", function () { + it("should have the correct options", function () { + const client = TEST_CLIENTS.ALL_CACHES_ENABLED(); + TEST_GUILDS.ALL_CACHES_ENABLED(client); + TEST_CHANNELS.TEXT_CHANNEL_ALL_CACHES_ENABLED(client); + const interaction = new Interaction(client, TEST_DATA.INTERACTION); + expect(interaction.options).to.deep.equal([]); + }); + }); + context("check textPrompt", function () { it("should be a function", function () { const client = TEST_CLIENTS.ALL_CACHES_ENABLED();