Skip to content

Commit

Permalink
feat(Message): add crosspostable property (#4903)
Browse files Browse the repository at this point in the history
Co-authored-by: Advaith <advaithj1@gmail.com>
Co-authored-by: Alex Hîncu <teesealz@gmail.com>
  • Loading branch information
3 people authored Nov 1, 2020
1 parent efd7849 commit b8fd3f6
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,23 @@ class Message extends Base {
);
}

/**
* Whether the message is crosspostable by the client user
* @type {boolean}
* @readonly
*/
get crosspostable() {
return (
this.channel.type === 'news' &&
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
this.type === 'DEFAULT' &&
this.channel.viewable &&
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.SEND_MESSAGES) &&
(this.author.id === this.client.user.id ||
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_MESSAGES))
);
}

/**
* Options that can be passed into editMessage.
* @typedef {Object} MessageEditOptions
Expand Down
2 changes: 2 additions & 0 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3018,6 +3018,7 @@ declare module 'discord.js' {
| 'attachments'
| 'channel'
| 'deletable'
| 'crosspostable'
| 'editable'
| 'mentions'
| 'pinnable'
Expand All @@ -3029,6 +3030,7 @@ declare module 'discord.js' {
attachments: Message['attachments'];
channel: Message['channel'];
readonly deletable: boolean;
readonly crosspostable: boolean;
readonly editable: boolean;
readonly edits: Message['edits'];
embeds: Message['embeds'];
Expand Down

0 comments on commit b8fd3f6

Please sign in to comment.