Skip to content

Commit

Permalink
Update Interaction.js
Browse files Browse the repository at this point in the history
  • Loading branch information
JustCat80 committed May 29, 2021
1 parent b00c738 commit de0d435
Showing 1 changed file with 42 additions and 6 deletions.
48 changes: 42 additions & 6 deletions lib/structures/Interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,52 @@ class Interaction extends Base {

/**
* Acknowledges the interaction without replying.
* @returns {Promise<boolean>}
* @returns {Promise<Boolean | Error>}
*/
async acknowledge() {

this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPONSE(this.id, this.token), true, {
type: 6
});
type: Constants.InteractionResponseType.PONG
}).then(() => {return true}).catch(err => {return err});
}

/**
* Delete the message
* @arg {String | Object} content A string or object. If an object is passed:
* @arg {Object} [content.allowedMentions] A list of mentions to allow (overrides default)
* @arg {Boolean} [content.allowedMentions.everyone] Whether or not to allow @everyone/@here.
* @arg {Boolean | Array<String>} [content.allowedMentions.roles] Whether or not to allow all role mentions, or an array of specific role mentions to allow.
* @arg {Boolean | Array<String>} [content.allowedMentions.users] Whether or not to allow all user mentions, or an array of specific user mentions to allow.
* @arg {String} content.content A content string
* @arg {Object} [content.embed] An embed object. See [the official Discord API documentation entry](https://discord.com/developers/docs/resources/channel#embed-object) for object structure
* @arg {Boolean} [content.tts] Set the message TTS flag
* @arg {Boolean} [content.flags] 64 for Ephemeral
* @returns {Promise}
*/

async createMessage(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 && !file) {
return Promise.reject(new Error("No content, file, or embed"));
}

} else if(!file) {
return Promise.reject(new Error("No content, file, or embed"));
}
return await this._client.requestHandler.request("POST", Endpoints.INTERACTION_RESPONSE(this.id, this.token), true, {
type: 4,
content: content.content,
embeds: content.embeds || [],
allowed_mentions: content.allowed_mentions || null,
flags: content.flags || 0,
})
}

//return false;
}
}


Expand Down

0 comments on commit de0d435

Please sign in to comment.