feat(TextChannel): RateLimitPerUser (#2811)

* feat: Add TextChannel#rateLimitPerUser
Rename parameter in TextChannel#setRateLimitPerUser
feat: Add `rateLimitPerUser` param to ChannelData
fix: eslint

* docs: Updated typings

* fix: Requested changes

* fix: rateLimitPerUser being undefined when 0

When `rate_limit_per_user` is 0, the gateway does not send it (but REST does). When this is set to a non-zero number, this property starts to exist. Otherwise this will be `0`. Adding `|| 0` should do the trick changing `undefined` to `0`.

* fix: eslint
This commit is contained in:
Kyra
2018-09-29 16:02:49 +02:00
committed by Crawl
parent 60ad9053a3
commit d4c0bb2a0d
3 changed files with 21 additions and 0 deletions

View File

@@ -43,6 +43,12 @@ class TextChannel extends GuildChannel {
*/
this.lastMessageID = data.last_message_id;
/**
* The ratelimit per user for this channel
* @type {number}
*/
this.rateLimitPerUser = data.rate_limit_per_user || 0;
/**
* The timestamp when the last pinned message was pinned, if there was one
* @type {?number}
@@ -52,6 +58,16 @@ class TextChannel extends GuildChannel {
if (data.messages) for (const message of data.messages) this.messages.add(message);
}
/**
* Sets the rate limit per user for this channel.
* @param {number} rateLimitPerUser The new ratelimit
* @param {string} [reason] Reason for changing the channel's ratelimits
* @returns {Promise<TextChannel>}
*/
setRateLimitPerUser(rateLimitPerUser, reason) {
return this.edit({ rateLimitPerUser }, reason);
}
/**
* Sets whether this channel is flagged as NSFW.
* @param {boolean} nsfw Whether the channel should be considered NSFW