Skip to content

Class: UserManager

Extends: CachedManager<number, User>

Manages API methods for users and stores their cache

Constructors

Constructor

new UserManager(client, iterable?): UserManager

Parameters

client

Client

The 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

args

...any[]

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

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

User

The cached item

Inherited from

CachedManager._add


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

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()

resolve(user): null | User

Resolves a user resolvable to a User object

Parameters

user

User

The user resolvable to resolve

Returns

null | User

The resolved user

Overrides

CachedManager.resolve


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

CachedManager.resolveId


valueOf()

valueOf(): Map<number, User>

Returns the primitive value of the specified object.

Returns

Map<number, User>

Inherited from

CachedManager.valueOf