refactor: Move me and add fetchMe() (fix)

This commit is contained in:
March 7th 2023-01-11 18:03:13 +07:00
parent bacb672045
commit 83f4181ec7
3 changed files with 3 additions and 3 deletions

View File

@ -55,7 +55,7 @@ class GuildEmoji extends BaseGuildEmoji {
* @readonly * @readonly
*/ */
get deletable() { get deletable() {
if (!this.guild.me) throw new Error('GUILD_UNCACHED_ME'); if (!this.guild.members.me) throw new Error('GUILD_UNCACHED_ME');
return !this.managed && this.guild.members.me.permissions.has(Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS); return !this.managed && this.guild.members.me.permissions.has(Permissions.FLAGS.MANAGE_EMOJIS_AND_STICKERS);
} }

View File

@ -333,7 +333,7 @@ class GuildMember extends Base {
if (this.user.id === this.guild.ownerId) return false; if (this.user.id === this.guild.ownerId) return false;
if (this.user.id === this.client.user.id) return false; if (this.user.id === this.client.user.id) return false;
if (this.client.user.id === this.guild.ownerId) return true; if (this.client.user.id === this.guild.ownerId) return true;
if (!this.guild.me) throw new Error('GUILD_UNCACHED_ME'); if (!this.guild.members.me) throw new Error('GUILD_UNCACHED_ME');
return this.guild.members.me.roles.highest.comparePositionTo(this.roles.highest) > 0; return this.guild.members.me.roles.highest.comparePositionTo(this.roles.highest) > 0;
} }

View File

@ -242,7 +242,7 @@ class Invite extends Base {
get deletable() { get deletable() {
const guild = this.guild; const guild = this.guild;
if (!guild || !this.client.guilds.cache.has(guild.id)) return false; if (!guild || !this.client.guilds.cache.has(guild.id)) return false;
if (!guild.me) throw new Error('GUILD_UNCACHED_ME'); if (!guild.members.me) throw new Error('GUILD_UNCACHED_ME');
return ( return (
this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS, false) || this.channel.permissionsFor(this.client.user).has(Permissions.FLAGS.MANAGE_CHANNELS, false) ||
guild.members.me.permissions.has(Permissions.FLAGS.MANAGE_GUILD) guild.members.me.permissions.has(Permissions.FLAGS.MANAGE_GUILD)