mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-11 17:13:31 +01:00
REST API speed improvement (#1577)
This commit is contained in:
@@ -50,13 +50,6 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
this.rest = new RESTManager(this);
|
||||
|
||||
/**
|
||||
* API shortcut
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
this.api = this.rest.api;
|
||||
|
||||
/**
|
||||
* The data manager of the client
|
||||
* @type {ClientDataManager}
|
||||
@@ -198,6 +191,15 @@ class Client extends EventEmitter {
|
||||
return this.ws.connection ? this.ws.connection.lastPingTimestamp : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* API shortcut
|
||||
* @type {Object}
|
||||
* @private
|
||||
*/
|
||||
get api() {
|
||||
return this.rest.api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Current status of the client's connection to Discord
|
||||
* @type {?Status}
|
||||
@@ -330,7 +332,7 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
fetchUser(id, cache = true) {
|
||||
if (this.users.has(id)) return Promise.resolve(this.users.get(id));
|
||||
return this.api.users(id).get().then(data =>
|
||||
return this.api.users[id].get().then(data =>
|
||||
cache ? this.dataManager.newUser(data) : new User(this, data)
|
||||
);
|
||||
}
|
||||
@@ -342,7 +344,7 @@ class Client extends EventEmitter {
|
||||
*/
|
||||
fetchInvite(invite) {
|
||||
const code = this.resolver.resolveInviteCode(invite);
|
||||
return this.api.invites(code).get({ query: { with_counts: true } })
|
||||
return this.api.invites[code].get({ query: { with_counts: true } })
|
||||
.then(data => new Invite(this, data));
|
||||
}
|
||||
|
||||
@@ -353,7 +355,7 @@ class Client extends EventEmitter {
|
||||
* @returns {Promise<Webhook>}
|
||||
*/
|
||||
fetchWebhook(id, token) {
|
||||
return this.api.webhooks(id, token).get().then(data => new Webhook(this, data));
|
||||
return this.api.webhooks.opts(id, token).get().then(data => new Webhook(this, data));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user