Skip to content

Commit

Permalink
Changed some docs, added .edit
Browse files Browse the repository at this point in the history
  • Loading branch information
JustCat80 committed May 30, 2021
1 parent 25e75ff commit 7be7a07
Showing 1 changed file with 37 additions and 9 deletions.
46 changes: 37 additions & 9 deletions lib/structures/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Interaction extends Base {
}

/**
* Acknowledges the interaction without replying.
* Acknowledges the interaction without replying. (Message Component only)
* @returns {Promise}
*/
async acknowledge() {
Expand Down Expand Up @@ -176,22 +176,18 @@ class Interaction extends Base {
}

/**
* Defer message update
* @arg {Boolean} [flags] 64 for Ephemeral
* Defer message update (Message Component only)
* @returns {Promise}
*/

async deferUpdate(flags) {
async deferUpdate() {
return this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(this.id, this.token), true, {
type: Constants.InteractionResponseType.DEFERRED_UPDATE_MESSAGE,
data: {
flags: flags || 0,
}
})
}

/**
* Respond to the interaction
* Edit a past response to the interaction
* @arg {String} messageId the id of the message to edit, or "@original" for the original response
* @arg {String | Object} content What to edit the message with
* @returns {Promise}
Expand All @@ -213,10 +209,42 @@ class Interaction extends Base {
}
}
return this._client.requestHandler.request("PATCH", Endpoints.WEBHOOK_MESSAGE(this.applicationId, this.token, messageId), true, {
content: content.content,
embeds: content.embeds || [],
allowed_mentions: content.allowed_mentions || null,
flags: flags || 0,
})
}

/**
* Edit the interaction Message (Message Component only)
* @arg {String} messageId the id of the message to edit, or "@original" for the original response
* @arg {String | Object} content What to edit the message with
* @returns {Promise}
*/

async edit(content) {
if(content !== undefined) {
if(typeof content !== "object" || content === null) {
content = {
content: "" + content
};
} else if(content.content !== undefined && typeof content.content !== "string") {
content.content = "" + content.content;
} else if(content.content === undefined && !content.embed && content.flags === undefined) {
return Promise.reject(new Error("No content, embed or flags"));
}
if(content.content !== undefined || content.embed || content.allowedMentions) {
content.allowed_mentions = this._client._formatAllowedMentions(content.allowedMentions);
}
}
return this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPOND(this.applicationId, this.token), true, {
type: Constants.InteractionResponseType.UPDATE_MESSAGE,
data: {
content: content.content,
embeds: content.embeds || [],
allowed_mentions: content.allowed_mentions || null,
flags: flags || 0,
}
})
}

Expand Down

0 comments on commit 7be7a07

Please sign in to comment.