feat(SlashCommandBuilder): Add explicit command type when building (#10395)

* feat(SlashCommandBuilder): add explicit command type when building

* test: add tests

* chore: merge import

---------

Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
Co-authored-by: almeidx <github@almeidx.dev>
This commit is contained in:
Amgelo563
2024-07-21 10:08:24 -05:00
committed by GitHub
parent efa16a6095
commit b2970bb2dd
2 changed files with 13 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
import { import {
ApplicationCommandType,
ApplicationIntegrationType, ApplicationIntegrationType,
ChannelType, ChannelType,
InteractionContextType, InteractionContextType,
@@ -133,6 +134,10 @@ describe('Slash Commands', () => {
}); });
describe('Builder with simple options', () => { 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', () => { test('GIVEN valid builder with options THEN does not throw error', () => {
expect(() => expect(() =>
getBuilder() getBuilder()

View File

@@ -1,9 +1,10 @@
import type { import {
ApplicationIntegrationType, ApplicationCommandType,
InteractionContextType, type ApplicationIntegrationType,
LocalizationMap, type InteractionContextType,
Permissions, type LocalizationMap,
RESTPostAPIChatInputApplicationCommandsJSONBody, type Permissions,
type RESTPostAPIChatInputApplicationCommandsJSONBody,
} from 'discord-api-types/v10'; } from 'discord-api-types/v10';
import type { RestOrArray } from '../../../util/normalizeArray.js'; import type { RestOrArray } from '../../../util/normalizeArray.js';
import { normalizeArray } from '../../../util/normalizeArray.js'; import { normalizeArray } from '../../../util/normalizeArray.js';
@@ -149,6 +150,7 @@ export class SharedSlashCommand {
return { return {
...this, ...this,
type: ApplicationCommandType.ChatInput,
options: this.options.map((option) => option.toJSON()), options: this.options.map((option) => option.toJSON()),
}; };
} }