Skip to content

Commit

Permalink
feat(SlashCommandBuilder): Add explicit command type when building (#…
Browse files Browse the repository at this point in the history
…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>
  • Loading branch information
3 people committed Jul 21, 2024
1 parent efa16a6 commit b2970bb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
ApplicationCommandType,
ApplicationIntegrationType,
ChannelType,
InteractionContextType,
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -149,6 +150,7 @@ export class SharedSlashCommand {

return {
...this,
type: ApplicationCommandType.ChatInput,
options: this.options.map((option) => option.toJSON()),
};
}
Expand Down

0 comments on commit b2970bb

Please sign in to comment.