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

@@ -413,7 +413,7 @@ class Message {
* @returns {Promise<Message>}
*/
pin() {
return this.client.api.channels[this.channel.id].pins[this.id].put()
return this.client.api.channels(this.channel.id).pins(this.id).put()
.then(() => this);
}
@@ -422,7 +422,7 @@ class Message {
* @returns {Promise<Message>}
*/
unpin() {
return this.client.api.channels[this.channel.id].pins[this.id].delete()
return this.client.api.channels(this.channel.id).pins(this.id).delete()
.then(() => this);
}
@@ -435,7 +435,7 @@ class Message {
emoji = this.client.resolver.resolveEmojiIdentifier(emoji);
if (!emoji) throw new TypeError('EMOJI_TYPE');
return this.client.api.channels[this.channel.id].messages[this.id].reactions[emoji]['@me']
return this.client.api.channels(this.channel.id).messages(this.id).reactions(emoji, '@me')
.put()
.then(() => this._addReaction(Util.parseEmoji(emoji), this.client.user));
}
@@ -445,7 +445,7 @@ class Message {
* @returns {Promise<Message>}
*/
clearReactions() {
return this.client.api.channels[this.channel.id].messages[this.id].reactions.delete()
return this.client.api.channels(this.channel.id).messages(this.id).reactions.delete()
.then(() => this);
}
@@ -463,7 +463,7 @@ class Message {
*/
delete({ timeout = 0, reason } = {}) {
if (timeout <= 0) {
return this.client.api.channels[this.channel.id].messages[this.id]
return this.client.api.channels(this.channel.id).messages(this.id)
.delete({ reason })
.then(() =>
this.client.actions.MessageDelete.handle({
@@ -506,7 +506,7 @@ class Message {
* @returns {Promise<Message>}
*/
acknowledge() {
return this.client.api.channels[this.channel.id].messages[this.id].ack
return this.client.api.channels(this.channel.id).messages(this.id).ack
.post({ data: { token: this.client.rest._ackToken } })
.then(res => {
if (res.token) this.client.rest._ackToken = res.token;