mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53:30 +01:00
Merge branch 'indev-rewrite' of https://github.com/hydrabolt/discord.js into indev-rewrite
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -17,6 +17,7 @@ class ActionsManager {
|
||||
this.register('GuildRoleCreate');
|
||||
this.register('GuildRoleDelete');
|
||||
this.register('GuildRoleUpdate');
|
||||
this.register('UserGet');
|
||||
this.register('UserUpdate');
|
||||
}
|
||||
|
||||
|
||||
15
src/client/actions/UserGet.js
Normal file
15
src/client/actions/UserGet.js
Normal file
@@ -0,0 +1,15 @@
|
||||
const Action = require('./Action');
|
||||
|
||||
class UserGetAction extends Action {
|
||||
|
||||
handle(data) {
|
||||
const client = this.client;
|
||||
const user = client.dataManager.newUser(data);
|
||||
|
||||
return {
|
||||
user,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = UserGetAction;
|
||||
@@ -193,6 +193,16 @@ class RESTMethods {
|
||||
});
|
||||
}
|
||||
|
||||
getUser(userID) {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.rest.makeRequest('get', Constants.Endpoints.user(userID), true)
|
||||
.then((data) => {
|
||||
resolve(this.rest.client.actions.UserGet.handle(data).user);
|
||||
})
|
||||
.catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
updateCurrentUser(_data) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const user = this.rest.client.user;
|
||||
|
||||
Reference in New Issue
Block a user