Skip to content

Commit bcb7c72

Browse files
CyberiumShadowadvaith1jo3-lvaporoxxiCrawl
authored
feat(Message): add support for crossposting (#4105)
Co-authored-by: Advaith <advaithj1@gmail.com> 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 <icrawltogo@gmail.com>
1 parent 0da65be commit bcb7c72

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

src/structures/Message.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,22 @@ class Message extends Base {
448448
});
449449
}
450450

451+
/**
452+
* Publishes a message in an announcement channel to all channels following it.
453+
* @returns {Promise<Message>}
454+
* @example
455+
* // Crosspost a message
456+
* if (message.channel.type === 'news') {
457+
* message.crosspost()
458+
* .then(() => console.log('Crossposted message'))
459+
* .catch(console.error);
460+
* }
461+
*/
462+
async crosspost() {
463+
await this.client.api.channels(this.channel.id).messages(this.id).crosspost.post();
464+
return this;
465+
}
466+
451467
/**
452468
* Pins this message to the channel's pinned messages.
453469
* @param {Object} [options] Options for pinning

typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,6 +1023,7 @@ declare module 'discord.js' {
10231023
public edit(content: StringResolvable, options: MessageEditOptions | MessageEmbed): Promise<Message>;
10241024
public equals(message: Message, rawData: object): boolean;
10251025
public fetchWebhook(): Promise<Webhook>;
1026+
public crosspost(): Promise<Message>;
10261027
public fetch(force?: boolean): Promise<Message>;
10271028
public pin(options?: { reason?: string }): Promise<Message>;
10281029
public react(emoji: EmojiIdentifierResolvable): Promise<MessageReaction>;

0 commit comments

Comments
 (0)