Skip to content

Commit

Permalink
refactor: name approach
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiralite committed Oct 11, 2024
1 parent 925398f commit 154b1d8
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/discord.js/src/managers/UserManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class UserManager extends CachedManager {
* Flags may still be retrieved via {@link UserManager#fetch}.</warn>
*/
async fetchFlags(user, options) {
emitDeprecationWarningForUserFetchFlags(true);
emitDeprecationWarningForUserFetchFlags(this.constructor.name);
return (await this.fetch(user, options)).flags;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/discord.js/src/structures/User.js
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ class User extends Base {
* Flags may still be retrieved via {@link User#fetch}.</warn>
*/
fetchFlags(force = false) {
emitDeprecationWarningForUserFetchFlags(false);
emitDeprecationWarningForUserFetchFlags(this.constructor.name);
return this.client.users.fetchFlags(this.id, { force });
}

Expand Down
5 changes: 2 additions & 3 deletions packages/discord.js/src/util/Util.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,12 +504,11 @@ function resolveSKUId(resolvable) {

/**
* Deprecation function for fetching user flags.
* @param {boolean} userManager Whether the class name is the user manager
* @param {string} name Name of the class
* @private
*/
function emitDeprecationWarningForUserFetchFlags(userManager) {
function emitDeprecationWarningForUserFetchFlags(name) {
if (deprecationEmittedForUserFetchFlags) return;
const name = userManager ? 'UserManager' : 'User';
process.emitWarning(`${name}#fetchFlags() is deprecated. Use ${name}#fetch() instead.`);
deprecationEmittedForUserFetchFlags = true;
}
Expand Down

0 comments on commit 154b1d8

Please sign in to comment.