mirror of
https://github.com/danbulant/discord.js
synced 2026-07-05 11:10:38 +00:00
feat(Message): add crosspostable property (#4903)
Co-authored-by: Advaith <advaithj1@gmail.com> Co-authored-by: Alex Hîncu <teesealz@gmail.com>
This commit is contained in:
parent
efd7849ed0
commit
b8fd3f65d9
2 changed files with 19 additions and 0 deletions
|
|
@ -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.
|
* Options that can be passed into editMessage.
|
||||||
* @typedef {Object} MessageEditOptions
|
* @typedef {Object} MessageEditOptions
|
||||||
|
|
|
||||||
2
typings/index.d.ts
vendored
2
typings/index.d.ts
vendored
|
|
@ -3018,6 +3018,7 @@ declare module 'discord.js' {
|
||||||
| 'attachments'
|
| 'attachments'
|
||||||
| 'channel'
|
| 'channel'
|
||||||
| 'deletable'
|
| 'deletable'
|
||||||
|
| 'crosspostable'
|
||||||
| 'editable'
|
| 'editable'
|
||||||
| 'mentions'
|
| 'mentions'
|
||||||
| 'pinnable'
|
| 'pinnable'
|
||||||
|
|
@ -3029,6 +3030,7 @@ declare module 'discord.js' {
|
||||||
attachments: Message['attachments'];
|
attachments: Message['attachments'];
|
||||||
channel: Message['channel'];
|
channel: Message['channel'];
|
||||||
readonly deletable: boolean;
|
readonly deletable: boolean;
|
||||||
|
readonly crosspostable: boolean;
|
||||||
readonly editable: boolean;
|
readonly editable: boolean;
|
||||||
readonly edits: Message['edits'];
|
readonly edits: Message['edits'];
|
||||||
embeds: Message['embeds'];
|
embeds: Message['embeds'];
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue