mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-18 20:43:30 +01:00
fix(xxxable): follow more properly with discord behavior (#6551)
Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -497,11 +497,7 @@ class GuildChannel extends Channel {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get deletable() {
|
get deletable() {
|
||||||
return (
|
return this.manageable && this.guild.rulesChannelId !== this.id && this.guild.publicUpdatesChannelId !== this.id;
|
||||||
this.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS, false) &&
|
|
||||||
this.guild.rulesChannelId !== this.id &&
|
|
||||||
this.guild.publicUpdatesChannelId !== this.id
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -548,7 +548,7 @@ class Message extends Base {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get editable() {
|
get editable() {
|
||||||
return this.author.id === this.client.user.id;
|
return Boolean(this.author.id === this.client.user.id && !this.deleted && (!this.guild || this.channel?.viewable));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -557,10 +557,19 @@ class Message extends Base {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get deletable() {
|
get deletable() {
|
||||||
|
if (this.deleted) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!this.guild) {
|
||||||
|
return this.author.id === this.client.user.id;
|
||||||
|
}
|
||||||
|
// DMChannel does not have viewable property, so check viewable after proved that message is on a guild.
|
||||||
|
if (!this.channel?.viewable) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
return Boolean(
|
return Boolean(
|
||||||
!this.deleted &&
|
this.author.id === this.client.user.id ||
|
||||||
(this.author.id === this.client.user.id ||
|
this.channel.permissionsFor(this.client.user)?.has(Permissions.FLAGS.MANAGE_MESSAGES, false),
|
||||||
this.channel.permissionsFor?.(this.client.user)?.has(Permissions.FLAGS.MANAGE_MESSAGES)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -572,7 +581,10 @@ class Message extends Base {
|
|||||||
get pinnable() {
|
get pinnable() {
|
||||||
return Boolean(
|
return Boolean(
|
||||||
!this.system &&
|
!this.system &&
|
||||||
(!this.guild || this.channel.permissionsFor(this.client.user)?.has(Permissions.FLAGS.MANAGE_MESSAGES, false)),
|
!this.deleted &&
|
||||||
|
(!this.guild ||
|
||||||
|
(this.channel?.viewable &&
|
||||||
|
this.channel.permissionsFor(this.client.user)?.has(Permissions.FLAGS.MANAGE_MESSAGES, false))),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -595,14 +607,16 @@ class Message extends Base {
|
|||||||
* @readonly
|
* @readonly
|
||||||
*/
|
*/
|
||||||
get crosspostable() {
|
get crosspostable() {
|
||||||
return (
|
const bitfield =
|
||||||
this.channel.type === 'GUILD_NEWS' &&
|
Permissions.FLAGS.SEND_MESSAGES |
|
||||||
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
(this.author.id === this.client.user.id ? Permissions.defaultBit : Permissions.FLAGS.MANAGE_MESSAGES);
|
||||||
this.type === 'DEFAULT' &&
|
return Boolean(
|
||||||
this.channel.viewable &&
|
this.channel?.type === 'GUILD_NEWS' &&
|
||||||
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.SEND_MESSAGES) &&
|
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
||||||
(this.author.id === this.client.user.id ||
|
this.type === 'DEFAULT' &&
|
||||||
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_MESSAGES))
|
this.channel.viewable &&
|
||||||
|
this.channel.permissionsFor(this.client.user)?.has(bitfield, false) &&
|
||||||
|
!this.deleted,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,15 +8,6 @@ const Permissions = require('../util/Permissions');
|
|||||||
* @extends {BaseGuildVoiceChannel}
|
* @extends {BaseGuildVoiceChannel}
|
||||||
*/
|
*/
|
||||||
class VoiceChannel extends BaseGuildVoiceChannel {
|
class VoiceChannel extends BaseGuildVoiceChannel {
|
||||||
/**
|
|
||||||
* Whether the channel is deletable by the client user
|
|
||||||
* @type {boolean}
|
|
||||||
* @readonly
|
|
||||||
*/
|
|
||||||
get deletable() {
|
|
||||||
return super.deletable && this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Whether the channel is editable by the client user
|
* Whether the channel is editable by the client user
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
@@ -24,7 +15,7 @@ class VoiceChannel extends BaseGuildVoiceChannel {
|
|||||||
* @deprecated Use {@link VoiceChannel#manageable} instead
|
* @deprecated Use {@link VoiceChannel#manageable} instead
|
||||||
*/
|
*/
|
||||||
get editable() {
|
get editable() {
|
||||||
return this.manageable && this.permissionsFor(this.client.user).has(Permissions.FLAGS.CONNECT, false);
|
return this.manageable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user