Skip to content

fix(SlashCommandBuilder): add missing shared properties #10255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
May 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions packages/builders/__tests__/types.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { expectTypeOf } from 'vitest';
import { SlashCommandBuilder, SlashCommandStringOption, SlashCommandSubcommandBuilder } from '../src/index.js';

const getBuilder = () => new SlashCommandBuilder();
const getStringOption = () => new SlashCommandStringOption().setName('owo').setDescription('Testing 123');
const getSubcommand = () => new SlashCommandSubcommandBuilder().setName('owo').setDescription('Testing 123');

type BuilderPropsOnly<Type = SlashCommandBuilder> = Pick<
Type,
keyof {
[Key in keyof Type as Type[Key] extends (...args: any) => any ? never : Key]: any;
}
>;

expectTypeOf(getBuilder().addStringOption(getStringOption())).toMatchTypeOf<BuilderPropsOnly>();

expectTypeOf(getBuilder().addSubcommand(getSubcommand())).toMatchTypeOf<BuilderPropsOnly>();
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,17 @@ export class SharedSlashCommand {

public readonly options: ToAPIApplicationCommandOptions[] = [];

/**
* @deprecated Use {@link SharedSlashCommand.setDefaultMemberPermissions} or {@link SharedSlashCommand.setDMPermission} instead.
*/
public readonly default_permission: boolean | undefined = undefined;

public readonly default_member_permissions: Permissions | null | undefined = undefined;

public readonly dm_permission: boolean | undefined = undefined;

public readonly nsfw: boolean | undefined = undefined;

/**
* Sets whether the command is enabled by default when the application is added to a guild.
*
Expand Down
4 changes: 4 additions & 0 deletions vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ export default defineConfig({
test: {
exclude: ['**/node_modules', '**/dist', '.idea', '.git', '.cache'],
passWithNoTests: true,
typecheck: {
enabled: true,
include: ["**/__tests__/types.test.ts"]
},
coverage: {
enabled: true,
all: true,
Expand Down