Downgrade to v13
[vi] cảm giác đau khổ
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
'use strict';
|
||||
|
||||
const { PermissionFlagsBits } = require('discord-api-types/v9');
|
||||
const process = require('node:process');
|
||||
const Base = require('./Base');
|
||||
const VoiceState = require('./VoiceState');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const { Error } = require('../errors');
|
||||
const GuildMemberRoleManager = require('../managers/GuildMemberRoleManager');
|
||||
const PermissionsBitField = require('../util/PermissionsBitField');
|
||||
const Permissions = require('../util/Permissions');
|
||||
|
||||
/**
|
||||
* @type {WeakSet<GuildMember>}
|
||||
* @private
|
||||
* @internal
|
||||
*/
|
||||
const deletedGuildMembers = new WeakSet();
|
||||
let deprecationEmittedForDeleted = false;
|
||||
|
||||
/**
|
||||
* Represents a member of a guild on Discord.
|
||||
@@ -43,9 +51,9 @@ class GuildMember extends Base {
|
||||
|
||||
/**
|
||||
* Whether this member has yet to pass the guild's membership gate
|
||||
* @type {?boolean}
|
||||
* @type {boolean}
|
||||
*/
|
||||
this.pending = null;
|
||||
this.pending = false;
|
||||
|
||||
/**
|
||||
* The timestamp this member's timeout will be removed
|
||||
@@ -76,18 +84,12 @@ class GuildMember extends Base {
|
||||
} else if (typeof this.avatar !== 'string') {
|
||||
this.avatar = null;
|
||||
}
|
||||
if ('joined_at' in data) this.joinedTimestamp = Date.parse(data.joined_at);
|
||||
if ('joined_at' in data) this.joinedTimestamp = new Date(data.joined_at).getTime();
|
||||
if ('premium_since' in data) {
|
||||
this.premiumSinceTimestamp = data.premium_since ? Date.parse(data.premium_since) : null;
|
||||
this.premiumSinceTimestamp = data.premium_since ? new Date(data.premium_since).getTime() : null;
|
||||
}
|
||||
if ('roles' in data) this._roles = data.roles;
|
||||
|
||||
if ('pending' in data) {
|
||||
this.pending = data.pending;
|
||||
} else if (!this.partial) {
|
||||
// See https://github.com/discordjs/discord.js/issues/6546 for more info.
|
||||
this.pending ??= false;
|
||||
}
|
||||
this.pending = data.pending ?? false;
|
||||
|
||||
if ('communication_disabled_until' in data) {
|
||||
this.communicationDisabledUntilTimestamp =
|
||||
@@ -101,6 +103,36 @@ class GuildMember extends Base {
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether or not the structure has been deleted
|
||||
* @type {boolean}
|
||||
* @deprecated This will be removed in the next major version, see https://github.com/discordjs/discord.js/issues/7091
|
||||
*/
|
||||
get deleted() {
|
||||
if (!deprecationEmittedForDeleted) {
|
||||
deprecationEmittedForDeleted = true;
|
||||
process.emitWarning(
|
||||
'GuildMember#deleted is deprecated, see https://github.com/discordjs/discord.js/issues/7091.',
|
||||
'DeprecationWarning',
|
||||
);
|
||||
}
|
||||
|
||||
return deletedGuildMembers.has(this);
|
||||
}
|
||||
|
||||
set deleted(value) {
|
||||
if (!deprecationEmittedForDeleted) {
|
||||
deprecationEmittedForDeleted = true;
|
||||
process.emitWarning(
|
||||
'GuildMember#deleted is deprecated, see https://github.com/discordjs/discord.js/issues/7091.',
|
||||
'DeprecationWarning',
|
||||
);
|
||||
}
|
||||
|
||||
if (value) deletedGuildMembers.add(this);
|
||||
else deletedGuildMembers.delete(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether this GuildMember is a partial
|
||||
* @type {boolean}
|
||||
@@ -130,11 +162,12 @@ class GuildMember extends Base {
|
||||
|
||||
/**
|
||||
* A link to the member's guild avatar.
|
||||
* @param {ImageURLOptions} [options={}] Options for the image URL
|
||||
* @param {ImageURLOptions} [options={}] Options for the Image URL
|
||||
* @returns {?string}
|
||||
*/
|
||||
avatarURL(options = {}) {
|
||||
return this.avatar && this.client.rest.cdn.guildMemberAvatar(this.guild.id, this.id, this.avatar, options);
|
||||
avatarURL({ format, size, dynamic } = {}) {
|
||||
if (!this.avatar) return null;
|
||||
return this.client.rest.cdn.GuildMemberAvatar(this.guild.id, this.id, this.avatar, format, size, dynamic);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -153,7 +186,7 @@ class GuildMember extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get joinedAt() {
|
||||
return this.joinedTimestamp && new Date(this.joinedTimestamp);
|
||||
return this.joinedTimestamp ? new Date(this.joinedTimestamp) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -171,7 +204,7 @@ class GuildMember extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get premiumSince() {
|
||||
return this.premiumSinceTimestamp && new Date(this.premiumSinceTimestamp);
|
||||
return this.premiumSinceTimestamp ? new Date(this.premiumSinceTimestamp) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -221,12 +254,12 @@ class GuildMember extends Base {
|
||||
|
||||
/**
|
||||
* The overall set of permissions for this member, taking only roles and owner status into account
|
||||
* @type {Readonly<PermissionsBitField>}
|
||||
* @type {Readonly<Permissions>}
|
||||
* @readonly
|
||||
*/
|
||||
get permissions() {
|
||||
if (this.user.id === this.guild.ownerId) return new PermissionsBitField(PermissionsBitField.All).freeze();
|
||||
return new PermissionsBitField(this.roles.cache.map(role => role.permissions)).freeze();
|
||||
if (this.user.id === this.guild.ownerId) return new Permissions(Permissions.ALL).freeze();
|
||||
return new Permissions(this.roles.cache.map(role => role.permissions)).freeze();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -249,8 +282,7 @@ class GuildMember extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get kickable() {
|
||||
if (!this.guild.me) throw new Error('GUILD_UNCACHED_ME');
|
||||
return this.manageable && this.guild.me.permissions.has(PermissionFlagsBits.KickMembers);
|
||||
return this.manageable && this.guild.me.permissions.has(Permissions.FLAGS.KICK_MEMBERS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,8 +291,7 @@ class GuildMember extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get bannable() {
|
||||
if (!this.guild.me) throw new Error('GUILD_UNCACHED_ME');
|
||||
return this.manageable && this.guild.me.permissions.has(PermissionFlagsBits.BanMembers);
|
||||
return this.manageable && this.guild.me.permissions.has(Permissions.FLAGS.BAN_MEMBERS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -269,11 +300,7 @@ class GuildMember extends Base {
|
||||
* @readonly
|
||||
*/
|
||||
get moderatable() {
|
||||
return (
|
||||
!this.permissions.has(PermissionFlagsBits.Administrator) &&
|
||||
this.manageable &&
|
||||
(this.guild.me?.permissions.has(PermissionFlagsBits.ModerateMembers) ?? false)
|
||||
);
|
||||
return this.manageable && (this.guild.me?.permissions.has(Permissions.FLAGS.MODERATE_MEMBERS) ?? false);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -288,7 +315,7 @@ class GuildMember extends Base {
|
||||
* Returns `channel.permissionsFor(guildMember)`. Returns permissions for a member in a guild channel,
|
||||
* taking into account roles and permission overwrites.
|
||||
* @param {GuildChannelResolvable} channel The guild channel to use as context
|
||||
* @returns {Readonly<PermissionsBitField>}
|
||||
* @returns {Readonly<Permissions>}
|
||||
*/
|
||||
permissionsIn(channel) {
|
||||
channel = this.guild.channels.resolve(channel);
|
||||
@@ -348,7 +375,7 @@ class GuildMember extends Base {
|
||||
* @returns {Promise<GuildMember>}
|
||||
* @example
|
||||
* // ban a guild member
|
||||
* guildMember.ban({ deleteMessageDays: 7, reason: 'They deserved it' })
|
||||
* guildMember.ban({ days: 7, reason: 'They deserved it' })
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
@@ -451,6 +478,7 @@ class GuildMember extends Base {
|
||||
TextBasedChannel.applyToClass(GuildMember);
|
||||
|
||||
exports.GuildMember = GuildMember;
|
||||
exports.deletedGuildMembers = deletedGuildMembers;
|
||||
|
||||
/**
|
||||
* @external APIGuildMember
|
||||
|
||||
Reference in New Issue
Block a user