@@ -9,6 +9,7 @@ const BaseGuildVoiceChannel = require('../structures/BaseGuildVoiceChannel');
|
||||
const { GuildMember } = require('../structures/GuildMember');
|
||||
const { Role } = require('../structures/Role');
|
||||
const { Events, Opcodes } = require('../util/Constants');
|
||||
const { PartialTypes } = require('../util/Constants');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const SnowflakeUtil = require('../util/SnowflakeUtil');
|
||||
|
||||
@@ -119,6 +120,20 @@ class GuildMemberManager extends CachedManager {
|
||||
return data instanceof Buffer ? (options.fetchWhenExisting === false ? null : this.fetch(userId)) : this._add(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* The client user as a GuildMember of this guild
|
||||
* @type {?GuildMember}
|
||||
* @readonly
|
||||
*/
|
||||
get me() {
|
||||
return (
|
||||
this.resolve(this.client.user.id) ??
|
||||
(this.client.options.partials.includes(PartialTypes.GUILD_MEMBER)
|
||||
? this._add({ user: { id: this.client.user.id } }, true)
|
||||
: null)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used to fetch a single member from a guild.
|
||||
* @typedef {BaseFetchOptions} FetchMemberOptions
|
||||
@@ -179,9 +194,9 @@ class GuildMemberManager extends CachedManager {
|
||||
if (!options || (!options?.query && !options?.user)) {
|
||||
// Check Permissions
|
||||
if (
|
||||
this.guild.me.permissions.has('KICK_MEMBERS') ||
|
||||
this.guild.me.permissions.has('BAN_MEMBERS') ||
|
||||
this.guild.me.permissions.has('MANAGE_ROLES')
|
||||
this.guild.members.me.permissions.has('KICK_MEMBERS') ||
|
||||
this.guild.members.me.permissions.has('BAN_MEMBERS') ||
|
||||
this.guild.members.me.permissions.has('MANAGE_ROLES')
|
||||
) {
|
||||
return this._fetchMany();
|
||||
} else {
|
||||
@@ -205,6 +220,15 @@ class GuildMemberManager extends CachedManager {
|
||||
return this._fetchMany(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches the client user as a GuildMember of the guild.
|
||||
* @param {BaseFetchOptions} [options] The options for fetching the member
|
||||
* @returns {Promise<GuildMember>}
|
||||
*/
|
||||
fetchMe(options) {
|
||||
return this.fetch({ ...options, user: this.client.user.id });
|
||||
}
|
||||
|
||||
/**
|
||||
* Options used for searching guild members.
|
||||
* @typedef {Object} GuildSearchMembersOptions
|
||||
|
||||
Reference in New Issue
Block a user