mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
Add client.cacheUser method (#548)
* Add client.cacheUser method * Fixed ESLint issues * Added existence check first
This commit is contained in:
committed by
Amish Shah
parent
e47f3dda94
commit
f944dce5c7
@@ -135,6 +135,16 @@ class Client extends EventEmitter {
|
||||
return this.rest.methods.loginToken(email);
|
||||
}
|
||||
|
||||
/**
|
||||
* Forces a user to be cached.
|
||||
* @param {String} id The ID of the user to cache
|
||||
* @return {Promise<User>}
|
||||
*/
|
||||
cacheUser(id) {
|
||||
if (this.users.has(id)) return Promise.resolve(this.users.get(id));
|
||||
return this.rest.methods.getUser(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a Collection, mapping Guild ID to Voice Connections.
|
||||
* @readonly
|
||||
|
||||
Reference in New Issue
Block a user