Skip to content

Class: UserManager ​

Extends: CachedManager

Manages API methods for users and stores their cache

Constructors ​

Constructor ​

new UserManager(client, iterable?): UserManager

Parameters ​

NameTypeDescription
clientClientThe client that instantiated this manager
iterable?Iterable<User, any, any>An iterable of users to cache

Returns ​

UserManager

Overrides ​

CachedManager.constructor

Properties ​

holds() ​

readonly holds: (...args) => User

Parameters ​

NameTypeDescription
argsany[]

Returns ​

User

Inherited from ​

CachedManager.holds

Accessors ​

cache ​

Get Signature ​

get cache(): Map<K, V>

The cache of items for this manager

Returns ​

Map<K, V>

Inherited from ​

CachedManager.cache

Methods ​

_add() ​

protected _add(data, cache?, options?): User

Adds an item to the cache

Parameters ​

NameTypeDescription
dataanyThe data to add
cache?booleanWhether to cache the item
options?objectAdditional options

Returns ​

User

The cached item

Inherited from ​

CachedManager._add


fetch(user, options?): Promise<null | User> ​

`

Obtains a user from Yurba, or the user cache if it's already available

Parameters ​

NameTypeDescription
userstring | numberThe user ID or link to fetch
options?objectAdditional options

Returns ​

Promise<null | User>

The user, or null if not found

Example ​

ts
// 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(user): null | User ​

`

Resolves a user resolvable to a User object

Parameters ​

NameTypeDescription
userUserThe user resolvable to resolve

Returns ​

null | User

The resolved user

Overrides ​

CachedManager.resolve


resolveId(user): null | number ​

`

Resolves a user resolvable to a user ID

Parameters ​

NameTypeDescription
userstring | number | UserThe user resolvable to resolve

Returns ​

null | number

The resolved user ID

Overrides ​

CachedManager.resolveId


valueOf() ​

valueOf(): Map<number, User>

Returns the primitive value of the specified object.

Returns ​

Map<number, User>

Inherited from ​

CachedManager.valueOf