rewrite ratelimiting and api route builder (#1667)

* rewrite ratelimiting and api route builder

* more stuff

* let people pass their own handlers

* Update burst.js

* Update RequestHandler.js

* Update burst.js

* Update sequential.js

* Update RequestHandler.js
This commit is contained in:
Gus Caplan
2017-07-20 19:32:40 -05:00
committed by Crawl
parent 11556c0b3b
commit a2eeafc75d
20 changed files with 187 additions and 316 deletions

View File

@@ -202,7 +202,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);
@@ -214,7 +214,7 @@ class User {
*/
deleteDM() {
if (!this.dmChannel) return Promise.reject(new Error('USER_NO_DMCHANNEL'));
return this.client.api.channels[this.dmChannel.id].delete()
return this.client.api.channels(this.dmChannel.id).delete()
.then(data => this.client.actions.ChannelDelete.handle(data).channel);
}
@@ -224,7 +224,7 @@ class User {
* @returns {Promise<UserProfile>}
*/
fetchProfile() {
return this.client.api.users[this.id].profile.get().then(data => new UserProfile(this, data));
return this.client.api.users(this.id).profile.get().then(data => new UserProfile(this, data));
}
/**
@@ -234,7 +234,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);
}