fix(Message): update pinnable to check for migrated guilds (#11189)

* fix(Message): update `pinnable` to check for migrated guilds

* refactor: requested changes

* refactor: no checkAdmin and clean up the mess
This commit is contained in:
Danial Raza
2025-10-24 17:05:12 +02:00
committed by GitHub
parent 104ad754f3
commit ee988e3e75

View File

@@ -781,11 +781,17 @@ 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?.viewable) return false;
const permissions = channel?.permissionsFor(this.client.user);
if (!permissions) return false;
return (
permissions.has([PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.PinMessages]) ||
permissions.has([PermissionFlagsBits.ReadMessageHistory, PermissionFlagsBits.ManageMessages])
);
}