Skip to content

Commit

Permalink
add options field
Browse files Browse the repository at this point in the history
  • Loading branch information
Starman3787 committed Nov 4, 2024
1 parent 10bb4ef commit f1312f7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/structures/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class Interaction {
#_channel_id;
#token;
#member;
#options;
/**
* Creates the structure for an interaction.
* @param {Client} client The client instance.
Expand Down Expand Up @@ -82,6 +83,13 @@ class Interaction {
* @private
*/
this.#token = data.token;

/**
* The options provided with the interaction.
* @type {Array<Object>}
* @private
*/
this.#options = data.data.options;
}

/**
Expand Down Expand Up @@ -154,6 +162,16 @@ class Interaction {
return this.#member;
}

/**
* The options provided with the interaction.
* @type {Array<Object>}
* @readonly
* @public
*/
get options() {
return this.#options;
}

/**
* Prompts a user to enter text using a modal.
* @param {Object} options Modal options.
Expand Down Expand Up @@ -357,6 +375,9 @@ class Interaction {
channel_id: this.channelId,
member: this.member.toJSON(format),
type: this.type,
data: {
options: this.options,
},
};
}
}
Expand Down
11 changes: 11 additions & 0 deletions test/structures/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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();
Expand Down

0 comments on commit f1312f7

Please sign in to comment.