feat(Message): support pin and unpin with reason (#4586)

Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
Souji
2020-07-17 10:13:30 +02:00
committed by GitHub
parent f9f3661090
commit c79ac4d9fc
2 changed files with 20 additions and 6 deletions

View File

@@ -428,25 +428,39 @@ class Message extends Base {
/**
* Pins this message to the channel's pinned messages.
* @param {Object} [options] Options for pinning
* @param {string} [options.reason] Reason for pinning
* @returns {Promise<Message>}
* @example
* // Pin a message with a reason
* message.pin({ reason: 'important' })
* .then(console.log)
* .catch(console.error)
*/
pin() {
pin(options) {
return this.client.api
.channels(this.channel.id)
.pins(this.id)
.put()
.put(options)
.then(() => this);
}
/**
* Unpins this message from the channel's pinned messages.
* @param {Object} [options] Options for unpinning
* @param {string} [options.reason] Reason for unpinning
* @returns {Promise<Message>}
* @example
* // Unpin a message with a reason
* message.unpin({ reason: 'no longer relevant' })
* .then(console.log)
* .catch(console.error)
*/
unpin() {
unpin(options) {
return this.client.api
.channels(this.channel.id)
.pins(this.id)
.delete()
.delete(options)
.then(() => this);
}