Files
discord.js/src/rest/handlers/sequential.js
2018-05-14 22:55:50 -05:00

19 lines
443 B
JavaScript

module.exports = function sequential() {
if (this.busy || this.limited || this.queue.length === 0) return;
this.busy = true;
this.execute(this.queue.shift())
.then(() => {
this.busy = false;
this.handle();
})
.catch(({ timeout }) => {
if (timeout) {
this.client.setTimeout(() => {
this.reset();
this.busy = false;
this.handle();
}, timeout);
}
});
};