From 487e967f30bdfd7fbc4f96a5c01ba951e257cd61 Mon Sep 17 00:00:00 2001 From: Amgelo563 Date: Wed, 17 Jul 2024 21:26:46 -0500 Subject: [PATCH 1/3] feat(SlashCommandBuilder): add explicit command type when building --- .../src/interactions/slashCommands/mixins/SharedSlashCommand.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts b/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts index 5d39cfc60a31..5fe67b4db8c3 100644 --- a/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts +++ b/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts @@ -5,6 +5,7 @@ import type { Permissions, RESTPostAPIChatInputApplicationCommandsJSONBody, } from 'discord-api-types/v10'; +import { ApplicationCommandType } from 'discord-api-types/v10'; import type { RestOrArray } from '../../../util/normalizeArray.js'; import { normalizeArray } from '../../../util/normalizeArray.js'; import { @@ -149,6 +150,7 @@ export class SharedSlashCommand { return { ...this, + type: ApplicationCommandType.ChatInput, options: this.options.map((option) => option.toJSON()), }; } From 3e56b05f66f83170fd18f792d6cd8784ecbb1b55 Mon Sep 17 00:00:00 2001 From: Jiralite <33201955+Jiralite@users.noreply.github.com> Date: Fri, 19 Jul 2024 15:09:33 +0100 Subject: [PATCH 2/3] test: add tests --- .../interactions/SlashCommands/SlashCommands.test.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts b/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts index acfb6fdc2286..64e9d97a710d 100644 --- a/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts +++ b/packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts @@ -1,4 +1,5 @@ import { + ApplicationCommandType, ApplicationIntegrationType, ChannelType, InteractionContextType, @@ -133,6 +134,10 @@ describe('Slash Commands', () => { }); describe('Builder with simple options', () => { + test('GIVEN valid builder THEN returns type included', () => { + expect(getNamedBuilder().toJSON()).includes({ type: ApplicationCommandType.ChatInput }); + }); + test('GIVEN valid builder with options THEN does not throw error', () => { expect(() => getBuilder() From 58f4ea7abb947020b5d3b99f1f9501cb8b6ee29f Mon Sep 17 00:00:00 2001 From: almeidx Date: Sun, 21 Jul 2024 16:01:24 +0100 Subject: [PATCH 3/3] chore: merge import --- .../slashCommands/mixins/SharedSlashCommand.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts b/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts index 5fe67b4db8c3..3908925bdea8 100644 --- a/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts +++ b/packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts @@ -1,11 +1,11 @@ -import type { - ApplicationIntegrationType, - InteractionContextType, - LocalizationMap, - Permissions, - RESTPostAPIChatInputApplicationCommandsJSONBody, +import { + ApplicationCommandType, + type ApplicationIntegrationType, + type InteractionContextType, + type LocalizationMap, + type Permissions, + type RESTPostAPIChatInputApplicationCommandsJSONBody, } from 'discord-api-types/v10'; -import { ApplicationCommandType } from 'discord-api-types/v10'; import type { RestOrArray } from '../../../util/normalizeArray.js'; import { normalizeArray } from '../../../util/normalizeArray.js'; import {