REST API speed improvement (#1577)

This commit is contained in:
Gus Caplan
2017-07-01 04:14:17 -05:00
committed by Amish Shah
parent 6bc7b3e068
commit 5ecd5f7d69
25 changed files with 114 additions and 109 deletions

View File

@@ -205,7 +205,7 @@ class User {
*/
createDM() {
if (this.dmChannel) return Promise.resolve(this.dmChannel);
return this.client.api.users(this.client.user.id).channels.post({ data: {
return this.client.api.users[this.client.user.id].channels.post({ data: {
recipient_id: this.id,
} })
.then(data => this.client.actions.ChannelCreate.handle(data).channel);
@@ -217,7 +217,7 @@ class User {
*/
deleteDM() {
if (!this.dmChannel) return Promise.reject(new Error('No DM Channel exists!'));
return this.client.api.channels(this.dmChannel.id).delete().then(data =>
return this.client.api.channels[this.dmChannel.id].delete().then(data =>
this.client.actions.ChannelDelete.handle(data).channel
);
}
@@ -228,7 +228,7 @@ class User {
* @returns {Promise<UserProfile>}
*/
fetchProfile() {
return this.client.api.users(this.id).profile.get().then(data => new UserProfile(data));
return this.client.api.users[this.id].profile.get().then(data => new UserProfile(data));
}
/**
@@ -238,7 +238,7 @@ class User {
* @returns {Promise<User>}
*/
setNote(note) {
return this.client.api.users('@me').notes(this.id).put({ data: { note } })
return this.client.api.users['@me'].notes[this.id].put({ data: { note } })
.then(() => this);
}