Skip to content

Commit db56324

Browse files
authored
types(DirectoryChannel): Ensure directory channels cannot contain user mentions when stringified (#10043)
* types(DirectoryChannel): `ChannelMention` `toString()` * refactor: dynamic test
1 parent a000df6 commit db56324

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

packages/discord.js/typings/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2888,6 +2888,7 @@ export class DirectoryChannel extends BaseChannel {
28882888
public guild: InviteGuild;
28892889
public guildId: Snowflake;
28902890
public name: string;
2891+
public toString(): ChannelMention;
28912892
}
28922893

28932894
export class StageInstance extends Base {

packages/discord.js/typings/index.test-d.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ import {
186186
Emoji,
187187
PartialEmoji,
188188
Awaitable,
189+
Channel,
190+
DirectoryChannel,
189191
} from '.';
190192
import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd';
191193
import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders';
@@ -2282,16 +2284,12 @@ declare const anyComponentsActionRowComp: ActionRow<ActionRowComponent>;
22822284
expectType<ActionRowBuilder>(ActionRowBuilder.from(anyComponentsActionRowData));
22832285
expectType<ActionRowBuilder>(ActionRowBuilder.from(anyComponentsActionRowComp));
22842286

2285-
declare const stageChannel: StageChannel;
2286-
declare const partialGroupDMChannel: PartialGroupDMChannel;
2287+
type UserMentionChannels = DMChannel | PartialDMChannel;
2288+
declare const channelMentionChannels: Exclude<Channel | DirectoryChannel, UserMentionChannels>;
2289+
declare const userMentionChannels: UserMentionChannels;
22872290

2288-
expectType<ChannelMention>(textChannel.toString());
2289-
expectType<ChannelMention>(voiceChannel.toString());
2290-
expectType<ChannelMention>(newsChannel.toString());
2291-
expectType<ChannelMention>(threadChannel.toString());
2292-
expectType<ChannelMention>(stageChannel.toString());
2293-
expectType<ChannelMention>(partialGroupDMChannel.toString());
2294-
expectType<UserMention>(dmChannel.toString());
2291+
expectType<ChannelMention>(channelMentionChannels.toString());
2292+
expectType<UserMention>(userMentionChannels.toString());
22952293
expectType<UserMention>(user.toString());
22962294
expectType<UserMention>(guildMember.toString());
22972295

@@ -2313,7 +2311,9 @@ expectType<Promise<Message>>(interactionWebhook.send('content'));
23132311
expectType<Promise<Message>>(interactionWebhook.editMessage(snowflake, 'content'));
23142312
expectType<Promise<Message>>(interactionWebhook.fetchMessage(snowflake));
23152313

2314+
declare const partialGroupDMChannel: PartialGroupDMChannel;
23162315
declare const categoryChannel: CategoryChannel;
2316+
declare const stageChannel: StageChannel;
23172317
declare const forumChannel: ForumChannel;
23182318

23192319
await forumChannel.edit({

0 commit comments

Comments
 (0)