From 5f93dcce466286f0fdead8faf4131e98d1c9db55 Mon Sep 17 00:00:00 2001 From: Rodry <38259440+ImRodry@users.noreply.github.com> Date: Wed, 22 Mar 2023 22:03:44 +0000 Subject: [PATCH] feat: add GuildBasedTextChannelTypes (#9234) * feat: add GuildBasedTextChannelTypes * docs(GuildTextBasedChannels): distinguish from non other Co-authored-by: Jaw0r3k * fix: spread correct array Co-authored-by: Vlad Frangu --------- Co-authored-by: Jaw0r3k Co-authored-by: Vlad Frangu --- packages/discord.js/src/util/Constants.js | 32 ++++++++++++++++------- packages/discord.js/typings/index.d.ts | 3 +++ 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/packages/discord.js/src/util/Constants.js b/packages/discord.js/src/util/Constants.js index f264e78d1..c2d3da95f 100644 --- a/packages/discord.js/src/util/Constants.js +++ b/packages/discord.js/src/util/Constants.js @@ -70,6 +70,27 @@ exports.NonSystemMessageTypes = [ * @typedef {TextChannel|NewsChannel|ThreadChannel|VoiceChannel|StageChannel} GuildTextBasedChannel */ +/** + * The types of guild channels that are text-based. The available types are: + * * {@link ChannelType.GuildText} + * * {@link ChannelType.GuildAnnouncement} + * * {@link ChannelType.AnnouncementThread} + * * {@link ChannelType.PublicThread} + * * {@link ChannelType.PrivateThread} + * * {@link ChannelType.GuildVoice} + * * {@link ChannelType.GuildStageVoice} + * @typedef {ChannelType[]} GuildTextBasedChannelTypes + */ +exports.GuildTextBasedChannelTypes = [ + ChannelType.GuildText, + ChannelType.GuildAnnouncement, + ChannelType.AnnouncementThread, + ChannelType.PublicThread, + ChannelType.PrivateThread, + ChannelType.GuildVoice, + ChannelType.GuildStageVoice, +]; + /** * The channels that are text-based. * * DMChannel @@ -96,16 +117,7 @@ exports.NonSystemMessageTypes = [ * * {@link ChannelType.GuildStageVoice} * @typedef {ChannelType[]} TextBasedChannelTypes */ -exports.TextBasedChannelTypes = [ - ChannelType.DM, - ChannelType.GuildText, - ChannelType.GuildAnnouncement, - ChannelType.AnnouncementThread, - ChannelType.PublicThread, - ChannelType.PrivateThread, - ChannelType.GuildVoice, - ChannelType.GuildStageVoice, -]; +exports.TextBasedChannelTypes = [...exports.GuildTextBasedChannelTypes, ChannelType.DM]; /** * The types of channels that are threads. The available types are: diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index 46257ab81..f78620bae 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -3478,6 +3478,7 @@ export const Constants: { SweeperKeys: SweeperKey[]; NonSystemMessageTypes: NonSystemMessageType[]; TextBasedChannelTypes: TextBasedChannelTypes[]; + GuildTextBasedChannelTypes: GuildTextBasedChannelTypes[]; ThreadChannelTypes: ThreadChannelType[]; VoiceBasedChannelTypes: VoiceBasedChannelTypes[]; SelectMenuTypes: SelectMenuType[]; @@ -6213,6 +6214,8 @@ export type TextBasedChannel = Exclude< export type TextBasedChannelTypes = TextBasedChannel['type']; +export type GuildTextBasedChannelTypes = Exclude; + export type VoiceBasedChannel = Extract; export type GuildBasedChannel = Extract;