mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 08:03:30 +01:00
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:
@@ -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])
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user