forked from discordjs/discord.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewsChannel.js
32 lines (29 loc) · 1.13 KB
/
NewsChannel.js
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
'use strict';
const { Routes } = require('discord-api-types/v10');
const BaseGuildTextChannel = require('./BaseGuildTextChannel');
const { Error, ErrorCodes } = require('../errors');
/**
* Represents a guild news channel on Discord.
* @extends {BaseGuildTextChannel}
*/
class NewsChannel extends BaseGuildTextChannel {
/**
* Adds the target to this channel's followers.
* @param {TextChannelResolvable} channel The channel where the webhook should be created
* @param {string} [reason] Reason for creating the webhook
* @returns {Promise<NewsChannel>}
* @example
* if (channel.type === ChannelType.GuildAnnouncement) {
* 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(ErrorCodes.GuildChannelResolve);
await this.client.rest.post(Routes.channelFollowers(this.id), { body: { webhook_channel_id: channelId }, reason });
return this;
}
}
module.exports = NewsChannel;