mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
feat: User#flags (#4060)
* feat: user flags * fix: unnecessary negated statement * fix: wording for description * fix: an vs. a * feat: add verified bot and dev flags Co-Authored-By: Vlad Frangu <kingdgrizzle@gmail.com> * typings :verified bot and dev flags Co-Authored-By: Vlad Frangu <kingdgrizzle@gmail.com> * feat: mon's suggestion, async fetchFlags & jsdoc * feat: added to index.js * fix: typo * style: leveled flags * typings: update leveled flags Co-authored-by: Vlad Frangu <kingdgrizzle@gmail.com>
This commit is contained in:
@@ -5,6 +5,7 @@ const { Presence } = require('./Presence');
|
||||
const TextBasedChannel = require('./interfaces/TextBasedChannel');
|
||||
const { Error } = require('../errors');
|
||||
const Snowflake = require('../util/Snowflake');
|
||||
const UserFlags = require('../util/UserFlags');
|
||||
|
||||
/**
|
||||
* Represents a user on Discord.
|
||||
@@ -73,6 +74,12 @@ class User extends Base {
|
||||
*/
|
||||
if (data.locale) this.locale = data.locale;
|
||||
|
||||
/**
|
||||
* The flags for this user
|
||||
* @type {?UserFlags}
|
||||
*/
|
||||
if (typeof data.public_flags !== 'undefined') this.flags = new UserFlags(data.public_flags);
|
||||
|
||||
/**
|
||||
* The ID of the last message sent by the user, if one was sent
|
||||
* @type {?Snowflake}
|
||||
@@ -255,6 +262,17 @@ class User extends Base {
|
||||
return equal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches this user's flags.
|
||||
* @returns {Promise<UserFlags>}
|
||||
*/
|
||||
async fetchFlags() {
|
||||
if (this.flags) return this.flags;
|
||||
const data = await this.client.api.users(this.id).get();
|
||||
this._patch(data);
|
||||
return this.flags;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches this user.
|
||||
* @returns {Promise<User>}
|
||||
|
||||
Reference in New Issue
Block a user