Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
editResponse test
Browse files Browse the repository at this point in the history
JustCat80 committed May 30, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent b4d3928 commit 1f4f175
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
@@ -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}`;
34 changes: 32 additions & 2 deletions lib/structures/Interaction.js
Original file line number Diff line number Diff line change
@@ -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,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,
}
})
}

}


0 comments on commit 1f4f175

Please sign in to comment.