mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 03:53:29 +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.
|
* 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>}
|
* @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
|
return this.client.api
|
||||||
.channels(this.channel.id)
|
.channels(this.channel.id)
|
||||||
.pins(this.id)
|
.pins(this.id)
|
||||||
.put()
|
.put(options)
|
||||||
.then(() => this);
|
.then(() => this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unpins this message from the channel's pinned messages.
|
* 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>}
|
* @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
|
return this.client.api
|
||||||
.channels(this.channel.id)
|
.channels(this.channel.id)
|
||||||
.pins(this.id)
|
.pins(this.id)
|
||||||
.delete()
|
.delete(options)
|
||||||
.then(() => this);
|
.then(() => this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
@@ -958,7 +958,7 @@ declare module 'discord.js' {
|
|||||||
public equals(message: Message, rawData: object): boolean;
|
public equals(message: Message, rawData: object): boolean;
|
||||||
public fetchWebhook(): Promise<Webhook>;
|
public fetchWebhook(): Promise<Webhook>;
|
||||||
public fetch(): Promise<Message>;
|
public fetch(): Promise<Message>;
|
||||||
public pin(): Promise<Message>;
|
public pin(options?: { reason?: string }): Promise<Message>;
|
||||||
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
|
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;
|
||||||
public reply(
|
public reply(
|
||||||
content?: StringResolvable,
|
content?: StringResolvable,
|
||||||
@@ -983,7 +983,7 @@ declare module 'discord.js' {
|
|||||||
public suppressEmbeds(suppress?: boolean): Promise<Message>;
|
public suppressEmbeds(suppress?: boolean): Promise<Message>;
|
||||||
public toJSON(): object;
|
public toJSON(): object;
|
||||||
public toString(): string;
|
public toString(): string;
|
||||||
public unpin(): Promise<Message>;
|
public unpin(options?: { reason?: string }): Promise<Message>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class MessageAttachment {
|
export class MessageAttachment {
|
||||||
|
|||||||
Reference in New Issue
Block a user