diff options
author | sowgro <tpoke.ferrari@gmail.com> | 2023-09-02 19:12:47 -0400 |
---|---|---|
committer | sowgro <tpoke.ferrari@gmail.com> | 2023-09-02 19:12:47 -0400 |
commit | e4450c8417624b71d779cb4f41692538f9165e10 (patch) | |
tree | b70826542223ecdf8a7a259f61b0a1abb8a217d8 /node_modules/discord.js/src/structures/NewsChannel.js | |
download | sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.tar.gz sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.tar.bz2 sowbot3-e4450c8417624b71d779cb4f41692538f9165e10.zip |
first commit
Diffstat (limited to 'node_modules/discord.js/src/structures/NewsChannel.js')
-rw-r--r-- | node_modules/discord.js/src/structures/NewsChannel.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/discord.js/src/structures/NewsChannel.js b/node_modules/discord.js/src/structures/NewsChannel.js new file mode 100644 index 0000000..3f5aff3 --- /dev/null +++ b/node_modules/discord.js/src/structures/NewsChannel.js @@ -0,0 +1,32 @@ +'use strict'; + +const { Routes } = require('discord-api-types/v10'); +const BaseGuildTextChannel = require('./BaseGuildTextChannel'); +const { DiscordjsError, 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 DiscordjsError(ErrorCodes.GuildChannelResolve); + await this.client.rest.post(Routes.channelFollowers(this.id), { body: { webhook_channel_id: channelId }, reason }); + return this; + } +} + +module.exports = NewsChannel; |