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:
Carter
2020-04-16 02:32:15 -06:00
committed by GitHub
parent 72a33cb8c2
commit 2e5a6476d5
4 changed files with 91 additions and 0 deletions

View File

@@ -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>}