diff --git a/src/structures/ModalResponse.js b/src/structures/ModalResponse.js index ecb8db63..67191608 100644 --- a/src/structures/ModalResponse.js +++ b/src/structures/ModalResponse.js @@ -10,6 +10,7 @@ import util from "util"; */ class ModalResponse extends Interaction { #values; + #custom_id; /** * Creates a modal submitted interaction structure. * @param {Client} client The client instance. @@ -23,6 +24,13 @@ class ModalResponse extends Interaction { if (typeof data !== "object") throw new TypeError("GLUON: Data must be an object"); + /** + * The custom id of the button. + * @type {String} + * @private + */ + this.#custom_id = data.data.custom_id; + /** * The entered modal values. * @type {Array} @@ -31,6 +39,16 @@ class ModalResponse extends Interaction { this.#values = data.data.components[0].components; } + /** + * The custom id of the modal. + * @type {String} + * @readonly + * @public + */ + get customId() { + return this.#custom_id; + } + /** * The entered modal values. * @type {Array} @@ -72,6 +90,7 @@ class ModalResponse extends Interaction { return { ...super.toJSON(format), values: this.values, + custom_id: this.customId, }; } case TO_JSON_TYPES_ENUM.DISCORD_FORMAT: @@ -79,6 +98,7 @@ class ModalResponse extends Interaction { return { ...super.toJSON(format), data: { + custom_id: this.customId, components: [ { components: this.values, diff --git a/src/testData.js b/src/testData.js index 8ea4b01a..c18684b2 100644 --- a/src/testData.js +++ b/src/testData.js @@ -736,6 +736,7 @@ export const TEST_DATA = { id: "123451189012345678", type: 5, data: { + custom_id: "test", components: [ { type: 1, diff --git a/test/structures/ModalResponse.js b/test/structures/ModalResponse.js index 08314d34..e86d7e45 100644 --- a/test/structures/ModalResponse.js +++ b/test/structures/ModalResponse.js @@ -20,6 +20,7 @@ describe("ModalResponse", function () { expect(modalResponse).to.have.property("guildId"); expect(modalResponse).to.have.property("channelId"); expect(modalResponse).to.have.property("member"); + expect(modalResponse).to.have.property("customId"); expect(modalResponse).to.have.property("values"); expect(modalResponse).to.have.property("guild"); expect(modalResponse).to.have.property("channel"); @@ -101,6 +102,7 @@ describe("ModalResponse", function () { TEST_DATA.MODAL_RESPONSE.data.components[0].components, }, ], + custom_id: TEST_DATA.MODAL_RESPONSE.data.custom_id, }, }); }); @@ -137,6 +139,7 @@ describe("ModalResponse", function () { }, type: TEST_DATA.MODAL_RESPONSE.type, values: TEST_DATA.MODAL_RESPONSE.data.components[0].components, + custom_id: TEST_DATA.MODAL_RESPONSE.data.custom_id, }); expect( modalResponse.toJSON(TO_JSON_TYPES_ENUM.DISCORD_FORMAT), @@ -171,6 +174,7 @@ describe("ModalResponse", function () { TEST_DATA.MODAL_RESPONSE.data.components[0].components, }, ], + custom_id: "test", }, }); });