mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +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;
|
||||
|
||||
@@ -75,12 +75,15 @@ const Endpoints = exports.Endpoints = {
|
||||
// general endpoints
|
||||
login: `${API}/auth/login`,
|
||||
logout: `${API}/auth/logout`,
|
||||
gateway: `${API}/gateway`,
|
||||
invite: (id) => `${API}/invite/${id}`,
|
||||
|
||||
// users
|
||||
user: (userID) => `${API}/users/${userID}`,
|
||||
userChannels: (userID) => `${Endpoints.user(userID)}/channels`,
|
||||
avatar: (userID, avatar) => `${Endpoints.user(userID)}/avatars/${avatar}.jpg`,
|
||||
me: `${API}/users/@me`,
|
||||
meGuild: (guildID) => `${Endpoints.me}/guilds/${guildID}`,
|
||||
gateway: `${API}/gateway`,
|
||||
userChannels: (userID) => `${API}/users/${userID}/channels`,
|
||||
avatar: (userID, avatar) => `${API}/users/${userID}/avatars/${avatar}.jpg`,
|
||||
invite: (id) => `${API}/invite/${id}`,
|
||||
|
||||
// guilds
|
||||
guilds: `${API}/guilds`,
|
||||
|
||||
Reference in New Issue
Block a user