NewsChannel.js
1.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';
const TextChannel = require('./TextChannel');
const { Error } = require('../errors');
/**
* Represents a guild news channel on Discord.
* @extends {TextChannel}
*/
class NewsChannel extends TextChannel {
_patch(data) {
super._patch(data);
// News channels don't have a rate limit per user, remove it
this.rateLimitPerUser = undefined;
}
/**
* Adds the target to this channel's followers.
* @param {GuildChannelResolvable} channel The channel where the webhook should be created
* @param {string} [reason] Reason for creating the webhook
* @returns {Promise<NewsChannel>}
* @example
* if (channel.type === 'news') {
* channel.addFollower('222197033908436994', 'Important announcements')
* .then(() => console.log('Added follower'))
* .catch(console.error);
* }
*/
async addFollower(channel, reason) {
const channelID = this.guild.channels.resolveID(channel);
if (!channelID) throw new Error('GUILD_CHANNEL_RESOLVE');
await this.client.api.channels(this.id).followers.post({ data: { webhook_channel_id: channelID }, reason });
return this;
}
}
module.exports = NewsChannel;