Skip to content

Commit

Permalink
editResponse test
Browse files Browse the repository at this point in the history
  • Loading branch information
JustCat80 committed May 30, 2021
1 parent b4d3928 commit 1f4f175
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/rest/Endpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down
34 changes: 32 additions & 2 deletions lib/structures/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -114,14 +114,44 @@ 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,
}
})
}

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,
}
})
}

}


Expand Down

0 comments on commit 1f4f175

Please sign in to comment.