From 8a51fc8e2ce93e6aafe0b71de2a818f685c54350 Mon Sep 17 00:00:00 2001 From: Naiyar <137700126+imnaiyar@users.noreply.github.com> Date: Mon, 9 Dec 2024 13:02:32 +0000 Subject: [PATCH] test: update index.test-d.ts --- packages/discord.js/typings/index.test-d.ts | 49 +++++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 036d7250d8c42..d013e59baf101 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -209,6 +209,7 @@ import { SendableChannels, PollData, InteractionCallbackResponse, + PrimaryEntryPointCommandInteraction, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; @@ -1793,6 +1794,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.update({ content: 'a', withResponse: true })); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -1805,6 +1807,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.update({ content: 'a', withResponse: true })); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.component); @@ -1817,6 +1820,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.update({ content: 'a', withResponse: true })); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } } @@ -1854,6 +1858,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -1862,6 +1867,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.editReply({ content: 'a' })); expectType>>(interaction.fetchReply()); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -1870,6 +1876,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.editReply({ content: 'a' })); expectType>(interaction.fetchReply()); expectType>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } } @@ -2038,6 +2045,45 @@ client.on('interactionCreate', async interaction => { interaction.options.getMessage('name'); } + if ( + interaction.type === InteractionType.ApplicationCommand && + interaction.commandType === ApplicationCommandType.PrimaryEntryPoint + ) { + expectType(interaction); + + // @ts-expect-error No options on primary entry point commands + interaction.options; + if (interaction.inCachedGuild()) { + expectAssignable(interaction); + expectAssignable(interaction.guild); + expectAssignable>(interaction); + expectType>(interaction.reply({ content: 'a', withResponse: true })); + expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.editReply({ content: 'a' })); + expectType>>(interaction.fetchReply()); + expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); + } else if (interaction.inRawGuild()) { + expectAssignable(interaction); + expectType(interaction.guild); + expectType>(interaction.reply({ content: 'a', withResponse: true })); + expectType>(interaction.deferReply({ withResponse: true })); + expectType>>(interaction.editReply({ content: 'a' })); + expectType>>(interaction.fetchReply()); + expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); + } else if (interaction.inGuild()) { + expectAssignable(interaction); + expectType(interaction.guild); + expectType>(interaction.reply({ content: 'a', withResponse: true })); + expectType>(interaction.deferReply({ withResponse: true })); + expectType>(interaction.editReply({ content: 'a' })); + expectType>(interaction.fetchReply()); + expectType>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); + } + } + if (interaction.isRepliable()) { expectAssignable(interaction); interaction.reply('test'); @@ -2064,6 +2110,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.fetchReply()); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } else if (interaction.inRawGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -2073,6 +2120,7 @@ client.on('interactionCreate', async interaction => { expectType>>(interaction.fetchReply()); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } else if (interaction.inGuild()) { expectAssignable(interaction); expectType(interaction.guild); @@ -2082,6 +2130,7 @@ client.on('interactionCreate', async interaction => { expectType>(interaction.fetchReply()); expectType>(interaction.deferUpdate({ withResponse: true })); expectType>(interaction.followUp({ content: 'a' })); + expectType>(interaction.launchActivity()); } } });