Add client.cacheUser method (#548)

* Add client.cacheUser method

* Fixed ESLint issues

* Added existence check first
This commit is contained in:
Schuyler Cebulskie
2016-08-27 10:22:07 -04:00
committed by Amish Shah
parent e47f3dda94
commit f944dce5c7
5 changed files with 43 additions and 4 deletions

View File

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