mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
feat(Message): support pin and unpin with reason (#4586)
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user