mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
fix(Message): update pinnable to use PinMessages (#11202)
* fix(Message): update `pinnable` to use `PinMessages` * refactor: use bitwise OR Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> * fix: check if in voice based channel for pinnable * Update packages/discord.js/src/structures/Message.js * Update packages/discord.js/src/structures/Message.js Co-authored-by: Almeida <github@almeidx.dev> * Update packages/discord.js/src/structures/Message.js Co-authored-by: Almeida <github@almeidx.dev> --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com> Co-authored-by: Almeida <github@almeidx.dev>
This commit is contained in:
@@ -799,12 +799,15 @@ class Message extends Base {
|
||||
*/
|
||||
get pinnable() {
|
||||
const { channel } = this;
|
||||
return Boolean(
|
||||
!this.system &&
|
||||
(!this.guild ||
|
||||
(channel?.viewable &&
|
||||
channel?.permissionsFor(this.client.user)?.has(PermissionFlagsBits.ManageMessages, false))),
|
||||
);
|
||||
|
||||
if (this.system) return false;
|
||||
if (!this.guild) return true;
|
||||
if (!channel || channel.isVoiceBased() || !channel.viewable) return false;
|
||||
|
||||
const permissions = channel.permissionsFor(this.client.user);
|
||||
if (!permissions) return false;
|
||||
|
||||
return permissions.has(PermissionFlagsBits.ReadMessageHistory | PermissionFlagsBits.PinMessages);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user