From db56324624b4eca706b487f425df990a2e44a369 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Mon, 18 Dec 2023 22:30:24 +0000 Subject: [PATCH] types(DirectoryChannel): Ensure directory channels cannot contain user mentions when stringified (#10043) * types(DirectoryChannel): `ChannelMention` `toString()` * refactor: dynamic test --- packages/discord.js/typings/index.d.ts | 1 + packages/discord.js/typings/index.test-d.ts | 18 +++++++++--------- 2 files changed, 10 insertions(+), 9 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..44b53da81984 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -186,6 +186,8 @@ import { Emoji, PartialEmoji, Awaitable, + Channel, + DirectoryChannel, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; @@ -2282,16 +2284,12 @@ declare const anyComponentsActionRowComp: ActionRow; expectType(ActionRowBuilder.from(anyComponentsActionRowData)); expectType(ActionRowBuilder.from(anyComponentsActionRowComp)); -declare const stageChannel: StageChannel; -declare const partialGroupDMChannel: PartialGroupDMChannel; +type UserMentionChannels = DMChannel | PartialDMChannel; +declare const channelMentionChannels: Exclude; +declare const userMentionChannels: UserMentionChannels; -expectType(textChannel.toString()); -expectType(voiceChannel.toString()); -expectType(newsChannel.toString()); -expectType(threadChannel.toString()); -expectType(stageChannel.toString()); -expectType(partialGroupDMChannel.toString()); -expectType(dmChannel.toString()); +expectType(channelMentionChannels.toString()); +expectType(userMentionChannels.toString()); expectType(user.toString()); expectType(guildMember.toString()); @@ -2313,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({