Skip to content

Commit 29fd89f

Browse files
TAEMBOJiralite
andauthored
fix(SlashCommandBuilder): add missing shared properties (discordjs#10255)
* types(SlashCommandBuilder): add missing shared properties * Add tests for types * Fix formatting * Enable Vitest type checking --------- Co-authored-by: Jiralite <33201955+Jiralite@users.noreply.github.com>
1 parent c2432d5 commit 29fd89f

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { expectTypeOf } from 'vitest';
2+
import { SlashCommandBuilder, SlashCommandStringOption, SlashCommandSubcommandBuilder } from '../src/index.js';
3+
4+
const getBuilder = () => new SlashCommandBuilder();
5+
const getStringOption = () => new SlashCommandStringOption().setName('owo').setDescription('Testing 123');
6+
const getSubcommand = () => new SlashCommandSubcommandBuilder().setName('owo').setDescription('Testing 123');
7+
8+
type BuilderPropsOnly<Type = SlashCommandBuilder> = Pick<
9+
Type,
10+
keyof {
11+
[Key in keyof Type as Type[Key] extends (...args: any) => any ? never : Key]: any;
12+
}
13+
>;
14+
15+
expectTypeOf(getBuilder().addStringOption(getStringOption())).toMatchTypeOf<BuilderPropsOnly>();
16+
17+
expectTypeOf(getBuilder().addSubcommand(getSubcommand())).toMatchTypeOf<BuilderPropsOnly>();

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,17 @@ export class SharedSlashCommand {
2727

2828
public readonly options: ToAPIApplicationCommandOptions[] = [];
2929

30+
/**
31+
* @deprecated Use {@link SharedSlashCommand.setDefaultMemberPermissions} or {@link SharedSlashCommand.setDMPermission} instead.
32+
*/
33+
public readonly default_permission: boolean | undefined = undefined;
34+
35+
public readonly default_member_permissions: Permissions | null | undefined = undefined;
36+
37+
public readonly dm_permission: boolean | undefined = undefined;
38+
39+
public readonly nsfw: boolean | undefined = undefined;
40+
3041
/**
3142
* Sets whether the command is enabled by default when the application is added to a guild.
3243
*

vitest.config.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ export default defineConfig({
44
test: {
55
exclude: ['**/node_modules', '**/dist', '.idea', '.git', '.cache'],
66
passWithNoTests: true,
7+
typecheck: {
8+
enabled: true,
9+
include: ["**/__tests__/types.test.ts"]
10+
},
711
coverage: {
812
enabled: true,
913
all: true,

0 commit comments

Comments
 (0)