Add a way to skip the rate limiter on ack.

This commit is contained in:
Paul
2021-09-14 20:57:18 +01:00
parent a87204b5b2
commit 7bb61d63d6
2 changed files with 4 additions and 3 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "revolt.js",
"version": "5.1.0-alpha.3",
"version": "5.1.0-alpha.4",
"main": "dist/index.js",
"repository": "https://gitlab.insrt.uk/revolt/revolt.js",
"author": "Paul Makles <insrt.uk>",
+3 -2
View File
@@ -420,15 +420,16 @@ export class Channel {
/**
* Mark a channel as read
* @param message Last read message or its ID
* @param skipRateLimiter Whether to skip the internal rate limiter
*/
async ack(message?: Message | string) {
async ack(message?: Message | string, skipRateLimiter?: boolean) {
const id = (typeof message === 'string' ? message : message?._id) ?? this.last_message_id ?? ulid();
const performAck = () => {
delete this.ackLimit;
this.client.req('PUT', `/channels/${this._id}/ack/${id}` as '/channels/id/ack/id');
}
if (!this.client.options.ackRateLimiter) return performAck();
if (!this.client.options.ackRateLimiter || skipRateLimiter) return performAck();
clearTimeout(this.ackTimeout);
if (this.ackLimit && + new Date() > this.ackLimit) {