Class: UserManager
Extends:
CachedManager<number,User>
Manages API methods for users and stores their cache
Constructors
Constructor
new UserManager(
client,iterable?):UserManager
Parameters
client
The client that instantiated this manager
iterable?
Iterable<User, any, any>
An iterable of users to cache
Returns
UserManager
Overrides
Properties
holds()
readonlyholds: (...args) =>User
Parameters
args
...any[]
Returns
Inherited from
Accessors
cache
Get Signature
get cache():
Map<K,V>
The cache of items for this manager
Returns
Map<K, V>
Inherited from
Methods
_add()
protected_add(data,cache?,options?):User
Adds an item to the cache
Parameters
data
any
The data to add
cache?
boolean = true
Whether to cache the item
options?
Additional options
extras?
any[] = []
Extra parameters for the constructor
id?
number
The ID of the item
Returns
The cached item
Inherited from
fetch()
fetch(
user,options?):Promise<null|User>
Obtains a user from Yurba, or the user cache if it's already available
Parameters
user
The user ID or link to fetch
string | number
options?
Additional options
cache?
boolean = true
Whether to cache the fetched user
force?
boolean = false
Whether to skip the cache check and request the API
Returns
Promise<null | User>
The user, or null if not found
Example
// Fetch a user by ID
const user = await client.users.fetch(123456);
// Fetch a user by link
const user = await client.users.fetch('username');
// Force fetch from API
const user = await client.users.fetch(123456, { force: true });resolve()
resolve(
user):null|User
Resolves a user resolvable to a User object
Parameters
user
The user resolvable to resolve
Returns
null | User
The resolved user
Overrides
resolveId()
resolveId(
user):null|number
Resolves a user resolvable to a user ID
Parameters
user
The user resolvable to resolve
string | number | User
Returns
null | number
The resolved user ID
Overrides
valueOf()
valueOf():
Map<number,User>
Returns the primitive value of the specified object.
Returns
Map<number, User>