mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +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
|
||||
*/
|
||||
get deletable() {
|
||||
return (
|
||||
this.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS, false) &&
|
||||
this.guild.rulesChannelId !== this.id &&
|
||||
this.guild.publicUpdatesChannelId !== this.id
|
||||
);
|
||||
return this.manageable && this.guild.rulesChannelId !== this.id && this.guild.publicUpdatesChannelId !== this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -548,7 +548,7 @@ class Message extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
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
|
||||
*/
|
||||
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(
|
||||
!this.deleted &&
|
||||
(this.author.id === this.client.user.id ||
|
||||
this.channel.permissionsFor?.(this.client.user)?.has(Permissions.FLAGS.MANAGE_MESSAGES)),
|
||||
this.author.id === this.client.user.id ||
|
||||
this.channel.permissionsFor(this.client.user)?.has(Permissions.FLAGS.MANAGE_MESSAGES, false),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -572,7 +581,10 @@ class Message extends Base {
|
||||
get pinnable() {
|
||||
return Boolean(
|
||||
!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
|
||||
*/
|
||||
get crosspostable() {
|
||||
return (
|
||||
this.channel.type === 'GUILD_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))
|
||||
const bitfield =
|
||||
Permissions.FLAGS.SEND_MESSAGES |
|
||||
(this.author.id === this.client.user.id ? Permissions.defaultBit : Permissions.FLAGS.MANAGE_MESSAGES);
|
||||
return Boolean(
|
||||
this.channel?.type === 'GUILD_NEWS' &&
|
||||
!this.flags.has(MessageFlags.FLAGS.CROSSPOSTED) &&
|
||||
this.type === 'DEFAULT' &&
|
||||
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}
|
||||
*/
|
||||
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
|
||||
* @type {boolean}
|
||||
@@ -24,7 +15,7 @@ class VoiceChannel extends BaseGuildVoiceChannel {
|
||||
* @deprecated Use {@link VoiceChannel#manageable} instead
|
||||
*/
|
||||
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