Skip to content

Commit

Permalink
types: allow raw components for reply and message options (#7573)
Browse files Browse the repository at this point in the history
  • Loading branch information
suneettipirneni committed Mar 2, 2022
1 parent c6cb5e9 commit 2d4971b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/discord.js/typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ import {
AuditLogEvent,
APIMessageComponentEmoji,
EmbedType,
APIActionRowComponentTypes,
} from 'discord-api-types/v9';
import { ChildProcess } from 'node:child_process';
import { EventEmitter } from 'node:events';
Expand Down Expand Up @@ -4600,7 +4601,11 @@ export interface MessageOptions {
nonce?: string | number;
content?: string | null;
embeds?: (Embed | APIEmbed)[];
components?: (ActionRow<ActionRowComponent> | (Required<BaseComponentData> & ActionRowData))[];
components?: (
| ActionRow<ActionRowComponent>
| (Required<BaseComponentData> & ActionRowData)
| APIActionRowComponent<APIActionRowComponentTypes>
)[];
allowedMentions?: MessageMentionOptions;
files?: (FileOptions | BufferResolvable | Stream | MessageAttachment)[];
reply?: ReplyOptions;
Expand Down
17 changes: 17 additions & 0 deletions packages/discord.js/typings/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,23 @@ client.on('interactionCreate', async interaction => {
// @ts-expect-error
await interaction.reply({ content: 'Hi!', components: [button] });

await interaction.reply({
content: 'test',
components: [
{
components: [
{
custom_id: 'abc',
label: 'abc',
style: ButtonStyle.Primary,
type: ComponentType.Button,
},
],
type: ComponentType.ActionRow,
},
],
});

if (interaction.isMessageComponent()) {
expectType<Snowflake>(interaction.channelId);
}
Expand Down

0 comments on commit 2d4971b

Please sign in to comment.