Skip to content

Commit b2970bb

Browse files
Amgelo563Jiralitealmeidx
authored
feat(SlashCommandBuilder): Add explicit command type when building (discordjs#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>
1 parent efa16a6 commit b2970bb

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/builders/__tests__/interactions/SlashCommands/SlashCommands.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
ApplicationCommandType,
23
ApplicationIntegrationType,
34
ChannelType,
45
InteractionContextType,
@@ -133,6 +134,10 @@ describe('Slash Commands', () => {
133134
});
134135

135136
describe('Builder with simple options', () => {
137+
test('GIVEN valid builder THEN returns type included', () => {
138+
expect(getNamedBuilder().toJSON()).includes({ type: ApplicationCommandType.ChatInput });
139+
});
140+
136141
test('GIVEN valid builder with options THEN does not throw error', () => {
137142
expect(() =>
138143
getBuilder()

packages/builders/src/interactions/slashCommands/mixins/SharedSlashCommand.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
import type {
2-
ApplicationIntegrationType,
3-
InteractionContextType,
4-
LocalizationMap,
5-
Permissions,
6-
RESTPostAPIChatInputApplicationCommandsJSONBody,
1+
import {
2+
ApplicationCommandType,
3+
type ApplicationIntegrationType,
4+
type InteractionContextType,
5+
type LocalizationMap,
6+
type Permissions,
7+
type RESTPostAPIChatInputApplicationCommandsJSONBody,
78
} from 'discord-api-types/v10';
89
import type { RestOrArray } from '../../../util/normalizeArray.js';
910
import { normalizeArray } from '../../../util/normalizeArray.js';
@@ -149,6 +150,7 @@ export class SharedSlashCommand {
149150

150151
return {
151152
...this,
153+
type: ApplicationCommandType.ChatInput,
152154
options: this.options.map((option) => option.toJSON()),
153155
};
154156
}

0 commit comments

Comments
 (0)