From bcb7c721dc8529f48c829e176a26f42e379cc012 Mon Sep 17 00:00:00 2001 From: Johnson Chen Date: Sun, 13 Sep 2020 20:07:56 +1000 Subject: [PATCH] feat(Message): add support for crossposting (#4105) Co-authored-by: Advaith Co-authored-by: Joe <56809242+Jo3-L@users.noreply.github.com> Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com> Co-authored-by: Noel --- src/structures/Message.js | 16 ++++++++++++++++ typings/index.d.ts | 1 + 2 files changed, 17 insertions(+) diff --git a/src/structures/Message.js b/src/structures/Message.js index 642cefb60..22a0de773 100644 --- a/src/structures/Message.js +++ b/src/structures/Message.js @@ -448,6 +448,22 @@ class Message extends Base { }); } + /** + * Publishes a message in an announcement channel to all channels following it. + * @returns {Promise} + * @example + * // Crosspost a message + * if (message.channel.type === 'news') { + * message.crosspost() + * .then(() => console.log('Crossposted message')) + * .catch(console.error); + * } + */ + async crosspost() { + await this.client.api.channels(this.channel.id).messages(this.id).crosspost.post(); + return this; + } + /** * Pins this message to the channel's pinned messages. * @param {Object} [options] Options for pinning diff --git a/typings/index.d.ts b/typings/index.d.ts index 6e9514f50..c24023dfa 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -1023,6 +1023,7 @@ declare module 'discord.js' { public edit(content: StringResolvable, options: MessageEditOptions | MessageEmbed): Promise; public equals(message: Message, rawData: object): boolean; public fetchWebhook(): Promise; + public crosspost(): Promise; public fetch(force?: boolean): Promise; public pin(options?: { reason?: string }): Promise; public react(emoji: EmojiIdentifierResolvable): Promise;