mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-09 16:13:31 +01:00
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:
@@ -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()
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
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 type { RestOrArray } from '../../../util/normalizeArray.js';
|
||||
import { normalizeArray } from '../../../util/normalizeArray.js';
|
||||
@@ -149,6 +150,7 @@ export class SharedSlashCommand {
|
||||
|
||||
return {
|
||||
...this,
|
||||
type: ApplicationCommandType.ChatInput,
|
||||
options: this.options.map((option) => option.toJSON()),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user