From 55ba6b2f81cc118fa27122f57e836a8bdceef4da Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Sun, 10 Dec 2023 14:58:59 +0000 Subject: [PATCH 1/2] types(DirectoryChannel): `ChannelMention` `toString()` --- packages/discord.js/typings/index.d.ts | 1 + packages/discord.js/typings/index.test-d.ts | 13 ++++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index eeef3f337d75..2bb8cd4699fe 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -2888,6 +2888,7 @@ export class DirectoryChannel extends BaseChannel { public guild: InviteGuild; public guildId: Snowflake; public name: string; + public toString(): ChannelMention; } export class StageInstance extends Base { diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 4e9f064ab957..08dc9b7cd6a6 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -186,6 +186,7 @@ import { Emoji, PartialEmoji, Awaitable, + DirectoryChannel, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; @@ -2282,16 +2283,22 @@ declare const anyComponentsActionRowComp: ActionRow; expectType(ActionRowBuilder.from(anyComponentsActionRowData)); expectType(ActionRowBuilder.from(anyComponentsActionRowComp)); -declare const stageChannel: StageChannel; declare const partialGroupDMChannel: PartialGroupDMChannel; +declare const stageChannel: StageChannel; +declare const directoryChannel: DirectoryChannel; +declare const mediaChannel: MediaChannel; expectType(textChannel.toString()); +expectType(dmChannel.toString()); expectType(voiceChannel.toString()); +expectType(partialGroupDMChannel.toString()); +expectType(categoryChannel.toString()); expectType(newsChannel.toString()); expectType(threadChannel.toString()); expectType(stageChannel.toString()); -expectType(partialGroupDMChannel.toString()); -expectType(dmChannel.toString()); +expectType(directoryChannel.toString()); +expectType(forumChannel.toString()); +expectType(mediaChannel.toString()); expectType(user.toString()); expectType(guildMember.toString()); From 10cab2684f561260a54b83bd542ea49b737fbea8 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:23:54 +0000 Subject: [PATCH 2/2] refactor: dynamic test --- packages/discord.js/typings/index.test-d.ts | 25 ++++++++------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 08dc9b7cd6a6..44b53da81984 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -186,6 +186,7 @@ import { Emoji, PartialEmoji, Awaitable, + Channel, DirectoryChannel, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; @@ -2283,22 +2284,12 @@ declare const anyComponentsActionRowComp: ActionRow; expectType(ActionRowBuilder.from(anyComponentsActionRowData)); expectType(ActionRowBuilder.from(anyComponentsActionRowComp)); -declare const partialGroupDMChannel: PartialGroupDMChannel; -declare const stageChannel: StageChannel; -declare const directoryChannel: DirectoryChannel; -declare const mediaChannel: MediaChannel; - -expectType(textChannel.toString()); -expectType(dmChannel.toString()); -expectType(voiceChannel.toString()); -expectType(partialGroupDMChannel.toString()); -expectType(categoryChannel.toString()); -expectType(newsChannel.toString()); -expectType(threadChannel.toString()); -expectType(stageChannel.toString()); -expectType(directoryChannel.toString()); -expectType(forumChannel.toString()); -expectType(mediaChannel.toString()); +type UserMentionChannels = DMChannel | PartialDMChannel; +declare const channelMentionChannels: Exclude; +declare const userMentionChannels: UserMentionChannels; + +expectType(channelMentionChannels.toString()); +expectType(userMentionChannels.toString()); expectType(user.toString()); expectType(guildMember.toString()); @@ -2320,7 +2311,9 @@ expectType>(interactionWebhook.send('content')); expectType>(interactionWebhook.editMessage(snowflake, 'content')); expectType>(interactionWebhook.fetchMessage(snowflake)); +declare const partialGroupDMChannel: PartialGroupDMChannel; declare const categoryChannel: CategoryChannel; +declare const stageChannel: StageChannel; declare const forumChannel: ForumChannel; await forumChannel.edit({