diff --git a/lib/rest/Endpoints.js b/lib/rest/Endpoints.js index 6eade7a13..69f6c77c7 100644 --- a/lib/rest/Endpoints.js +++ b/lib/rest/Endpoints.js @@ -68,8 +68,8 @@ module.exports.GUILD_WELCOME_SCREEN = (guildID) module.exports.GUILD_WIDGET = (guildID) => `/guilds/${guildID}/widget`; module.exports.GUILD_VOICE_STATE = (guildID, user) => `/guilds/${guildID}/voice-states/${user}`; module.exports.GUILDS = "/guilds"; -module.exports.INTERACTION_RESPONSE = (interactID, interactToken) => `/interactions/${interactID}/${interactToken}/callback`; -module.exports.GET_INTERACTION_RESPONSE = (appID, interactToken, msgID) => `/webhooks/${appID}/${interactToken}/messages/${msgID}`;//@original or message id +module.exports.INTERACTION_RESPOND = (interactID, interactToken) => `/interactions/${interactID}/${interactToken}/callback`; +module.exports.INTERACTION_RESPONSE = (appID, interactToken, msgID) => `/webhooks/${appID}/${interactToken}/messages/${msgID}`;//@original or message id module.exports.CREATE_FOLLOW_INTERACTION_RESPONSE = (appID, interactToken) => `/webhooks/${appID}/${interactToken}`; module.exports.INVITE = (inviteID) => `/invite/${inviteID}`; module.exports.OAUTH2_APPLICATION = (appID) => `/oauth2/applications/${appID}`; diff --git a/lib/structures/Interaction.js b/lib/structures/Interaction.js index 2733bd977..131695d85 100644 --- a/lib/structures/Interaction.js +++ b/lib/structures/Interaction.js @@ -96,7 +96,7 @@ class Interaction extends Base { if(typeof content == "string") { content = {content: content}; } - return this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPONSE(this.id, this.token), true, { + return this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(this.id, this.token), true, { type: 4, data: { content: content.content, @@ -114,7 +114,7 @@ class Interaction extends Base { */ async defer(flags) { - return this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPONSE(this.id, this.token), true, { + return this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(this.id, this.token), true, { type: 5, data: { flags: flags || 0, @@ -122,6 +122,36 @@ class Interaction extends Base { }) } + async deferUpdate(flags) { + return this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(this.id, this.token), true, { + type: 5, + data: { + flags: flags || 0, + } + }) + } + + /** + * Respond to the interaction + * @arg {String} [message] the id of the message to edit, or "@original" for the original response + * @returns {Promise} + */ + + async editResponse(message, content) { + if(typeof content == "string") { + content = {content: content}; + } + return this._client.requestHandler.request("PATCH", Endpoints.INTERACTION_RESPONSE(this.id, this.token, message), true, { + type: 5, + data: { + content: content.content, + embeds: content.embeds || [], + allowed_mentions: content.allowed_mentions || null, + //flags: content.flags || 0, + } + }) + } + }