Skip to content

Commit c8ef899

Browse files
authored
refactor(NewsChannel)!: rename NewsChannel to AnnouncementChannel (#10532)
BREAKING CHANGE: The `NewsChannel` class was renamed to `AnnouncementChannel`, in line with the type name change
1 parent a65c762 commit c8ef899

19 files changed

+94
-79
lines changed

packages/discord.js/src/client/actions/ThreadListSync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class ThreadListSyncAction extends Action {
3636
}
3737

3838
/**
39-
* Emitted whenever the client user gains access to a text or news channel that contains threads
39+
* Emitted whenever the client user gains access to a text or announcement channel that contains threads
4040
* @event Client#threadListSync
4141
* @param {Collection<Snowflake, ThreadChannel>} threads The threads that were synced
4242
* @param {Guild} guild The guild that the threads were synced in

packages/discord.js/src/client/actions/WebhooksUpdate.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class WebhooksUpdate extends Action {
1212
/**
1313
* Emitted whenever a channel has its webhooks changed.
1414
* @event Client#webhooksUpdate
15-
* @param {TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel|MediaChannel} channel
15+
* @param {TextChannel|AnnouncementChannel|VoiceChannel|StageChannel|ForumChannel|MediaChannel} channel
1616
* The channel that had a webhook update
1717
*/
1818
client.emit(Events.WebhooksUpdate, channel);

packages/discord.js/src/errors/Messages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ const Messages = {
7575
[DjsErrorCodes.InvalidType]: (name, expected, an = false) => `Supplied ${name} is not a${an ? 'n' : ''} ${expected}.`,
7676
[DjsErrorCodes.InvalidElement]: (type, name, elem) => `Supplied ${type} ${name} includes an invalid element: ${elem}`,
7777

78-
[DjsErrorCodes.MessageThreadParent]: 'The message was not sent in a guild text or news channel',
78+
[DjsErrorCodes.MessageThreadParent]: 'The message was not sent in a guild text or announcement channel',
7979
[DjsErrorCodes.MessageExistingThread]: 'The message already has a thread',
8080
[DjsErrorCodes.ThreadInvitableType]: type => `Invitable cannot be edited on ${type}`,
8181

packages/discord.js/src/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ exports.MessagePayload = require('./structures/MessagePayload');
161161
exports.MessageReaction = require('./structures/MessageReaction');
162162
exports.ModalSubmitInteraction = require('./structures/ModalSubmitInteraction');
163163
exports.ModalSubmitFields = require('./structures/ModalSubmitFields');
164-
exports.NewsChannel = require('./structures/NewsChannel');
164+
exports.AnnouncementChannel = require('./structures/AnnouncementChannel.js');
165165
exports.OAuth2Guild = require('./structures/OAuth2Guild');
166166
exports.PartialGroupDMChannel = require('./structures/PartialGroupDMChannel');
167167
exports.PermissionOverwrites = require('./structures/PermissionOverwrites');

packages/discord.js/src/managers/GuildChannelManager.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,23 +99,23 @@ class GuildChannelManager extends CachedManager {
9999
}
100100

101101
/**
102-
* Data that can be resolved to a News Channel object. This can be:
103-
* * A NewsChannel object
102+
* Data that can be resolved to an Announcement Channel object. This can be:
103+
* * An Announcement Channel object
104104
* * A Snowflake
105-
* @typedef {NewsChannel|Snowflake} NewsChannelResolvable
105+
* @typedef {AnnouncementChannel|Snowflake} AnnouncementChannelResolvable
106106
*/
107107

108108
/**
109109
* Adds the target channel to a channel's followers.
110-
* @param {NewsChannelResolvable} channel The channel to follow
110+
* @param {AnnouncementChannelResolvable} channel The channel to follow
111111
* @param {TextChannelResolvable} targetChannel The channel where published announcements will be posted at
112112
* @param {string} [reason] Reason for creating the webhook
113113
* @returns {Promise<Snowflake>} Returns created target webhook id.
114114
*/
115115
async addFollower(channel, targetChannel, reason) {
116116
const channelId = this.resolveId(channel);
117117
if (!channelId) {
118-
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'NewsChannelResolvable');
118+
throw new DiscordjsTypeError(ErrorCodes.InvalidType, 'channel', 'AnnouncementChannelResolvable');
119119
}
120120
const targetChannelId = this.resolveId(targetChannel);
121121
if (!targetChannelId) {
@@ -208,7 +208,7 @@ class GuildChannelManager extends CachedManager {
208208

209209
/**
210210
* @typedef {ChannelWebhookCreateOptions} WebhookCreateOptions
211-
* @property {TextChannel|NewsChannel|VoiceChannel|StageChannel|ForumChannel|MediaChannel|Snowflake} channel
211+
* @property {TextChannel|AnnouncementChannel|VoiceChannel|StageChannel|ForumChannel|MediaChannel|Snowflake} channel
212212
* The channel to create the webhook for
213213
*/
214214

@@ -247,7 +247,7 @@ class GuildChannelManager extends CachedManager {
247247
* Options used to edit a guild channel.
248248
* @typedef {Object} GuildChannelEditOptions
249249
* @property {string} [name] The name of the channel
250-
* @property {ChannelType} [type] The type of the channel (only conversion between text and news is supported)
250+
* @property {ChannelType} [type] The type of the channel (only conversion between text and announcement is supported)
251251
* @property {number} [position] The position of the channel
252252
* @property {?string} [topic] The topic of the text channel
253253
* @property {boolean} [nsfw] Whether the channel is NSFW

packages/discord.js/src/managers/GuildInviteManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ class GuildInviteManager extends CachedManager {
4343
* Data that can be resolved to a channel that an invite can be created on. This can be:
4444
* * TextChannel
4545
* * VoiceChannel
46-
* * NewsChannel
46+
* * AnnouncementChannel
4747
* * StageChannel
4848
* * ForumChannel
4949
* * MediaChannel
5050
* * Snowflake
51-
* @typedef {TextChannel|VoiceChannel|NewsChannel|StageChannel|ForumChannel|MediaChannel|Snowflake}
51+
* @typedef {TextChannel|VoiceChannel|AnnouncementChannel|StageChannel|ForumChannel|MediaChannel|Snowflake}
5252
* GuildInvitableChannelResolvable
5353
*/
5454

packages/discord.js/src/managers/GuildTextThreadManager.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class GuildTextThreadManager extends ThreadManager {
1212
/**
1313
* The channel this Manager belongs to
1414
* @name GuildTextThreadManager#channel
15-
* @type {TextChannel|NewsChannel}
15+
* @type {TextChannel|AnnouncementChannel}
1616
*/
1717

1818
/**
@@ -22,7 +22,7 @@ class GuildTextThreadManager extends ThreadManager {
2222
* <warn>If this is defined, then the `type` of thread gets inferred automatically and cannot be changed.</warn>
2323
* @property {ThreadChannelTypes} [type] The type of thread to create.
2424
* Defaults to {@link ChannelType.PublicThread} if created in a {@link TextChannel}
25-
* <warn>When creating threads in a {@link NewsChannel}, this is ignored and is always
25+
* <warn>When creating threads in a {@link AnnouncementChannel}, this is ignored and is always
2626
* {@link ChannelType.AnnouncementThread}</warn>
2727
* @property {boolean} [invitable] Whether non-moderators can add other non-moderators to the thread
2828
* <info>Can only be set when type will be {@link ChannelType.PrivateThread}</info>

packages/discord.js/src/managers/ThreadManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ThreadManager extends CachedManager {
2020

2121
/**
2222
* The channel this Manager belongs to
23-
* @type {TextChannel|NewsChannel|ForumChannel|MediaChannel}
23+
* @type {TextChannel|AnnouncementChannel|ForumChannel|MediaChannel}
2424
*/
2525
this.channel = channel;
2626
}

packages/discord.js/src/structures/NewsChannel.js renamed to packages/discord.js/src/structures/AnnouncementChannel.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ const BaseGuildTextChannel = require('./BaseGuildTextChannel');
55
const { DiscordjsError, ErrorCodes } = require('../errors');
66

77
/**
8-
* Represents a guild news channel on Discord.
8+
* Represents a guild announcement channel on Discord.
99
* @extends {BaseGuildTextChannel}
1010
*/
11-
class NewsChannel extends BaseGuildTextChannel {
11+
class AnnouncementChannel extends BaseGuildTextChannel {
1212
/**
1313
* Adds the target to this channel's followers.
1414
* @param {TextChannelResolvable} channel The channel where the webhook should be created
1515
* @param {string} [reason] Reason for creating the webhook
16-
* @returns {Promise<NewsChannel>}
16+
* @returns {Promise<AnnouncementChannel>}
1717
* @example
1818
* if (channel.type === ChannelType.GuildAnnouncement) {
1919
* channel.addFollower('222197033908436994', 'Important announcements')
@@ -29,4 +29,4 @@ class NewsChannel extends BaseGuildTextChannel {
2929
}
3030
}
3131

32-
module.exports = NewsChannel;
32+
module.exports = AnnouncementChannel;

packages/discord.js/src/structures/BaseGuildTextChannel.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class BaseGuildTextChannel extends GuildChannel {
101101

102102
/**
103103
* Sets the type of this channel.
104-
* <info>Only conversion between {@link TextChannel} and {@link NewsChannel} is supported.</info>
104+
* <info>Only conversion between {@link TextChannel} and {@link AnnouncementChannel} is supported.</info>
105105
* @param {ChannelType.GuildText|ChannelType.GuildAnnouncement} type The new channel type
106106
* @param {string} [reason] Reason for changing the channel's type
107107
* @returns {Promise<GuildChannel>}

0 commit comments

Comments
 (0)