Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Message): add crosspostable property #4903

Merged
merged 9 commits into from
Nov 1, 2020
Merged
16 changes: 16 additions & 0 deletions src/structures/Message.js
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,22 @@ 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.flags.has(MessageFlags.FLAGS.IS_CROSSPOST) &&
HarmoGlace marked this conversation as resolved.
Show resolved Hide resolved
this.author.id === this.client.user.id &&
HarmoGlace marked this conversation as resolved.
Show resolved Hide resolved
this.type === 'DEFAULT' &&
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.SEND_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 @@ -3017,6 +3017,7 @@ declare module 'discord.js' {
| 'attachments'
| 'channel'
| 'deletable'
| 'crosspostable'
| 'editable'
| 'mentions'
| 'pinnable'
Expand All @@ -3028,6 +3029,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