refactor: Move me and add fetchMe() (#9029)

This commit is contained in:
Jiralite
2023-01-10 09:49:43 +00:00
committed by GitHub
parent f0d42644df
commit b01c81dd72
14 changed files with 78 additions and 32 deletions

View File

@@ -25,7 +25,6 @@ const VoiceStateManager = require('../managers/VoiceStateManager');
const {
ChannelTypes,
DefaultMessageNotificationLevels,
PartialTypes,
VerificationLevels,
ExplicitContentFilterLevels,
Status,
@@ -39,6 +38,7 @@ const Util = require('../util/Util');
let deprecationEmittedForSetChannelPositions = false;
let deprecationEmittedForSetRolePositions = false;
let deprecationEmittedForDeleted = false;
let deprecationEmittedForMe = false;
/**
* @type {WeakSet<Guild>}
@@ -590,15 +590,16 @@ class Guild extends AnonymousGuild {
/**
* The client user as a GuildMember of this guild
* @type {?GuildMember}
* @deprecated Use {@link GuildMemberManager#me} instead.
* @readonly
*/
get me() {
return (
this.members.resolve(this.client.user.id) ??
(this.client.options.partials.includes(PartialTypes.GUILD_MEMBER)
? this.members._add({ user: { id: this.client.user.id } }, true)
: null)
);
if (!deprecationEmittedForMe) {
process.emitWarning('Guild#me is deprecated. Use Guild#members#me instead.', 'DeprecationWarning');
deprecationEmittedForMe = true;
}
return this.members.me;
}
/**