Validation error when importing builders from `discord.js` rather than `@discordjs/builders`

I ended up opening a thread on the d.js server because I thought it was related to it but turns out seems to only happen when used with Sapphire
import { Command } from '@sapphire/framework';
import { SlashCommandSubcommandBuilder } from 'discord.js';
// If import it from @discordjs/builders as such:
// import { SlashCommandSubcommandBuilder } from '@discordjs/builders';
// it works fine

export class BuilderBugCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options });
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName('builder_bug') //
.addSubcommand(
new SlashCommandSubcommandBuilder() //
.setName('something')
)
);
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO
}
}
import { Command } from '@sapphire/framework';
import { SlashCommandSubcommandBuilder } from 'discord.js';
// If import it from @discordjs/builders as such:
// import { SlashCommandSubcommandBuilder } from '@discordjs/builders';
// it works fine

export class BuilderBugCommand extends Command {
public constructor(context: Command.LoaderContext, options: Command.Options) {
super(context, { ...options });
}

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerChatInputCommand((builder) =>
builder
.setName('builder_bug') //
.addSubcommand(
new SlashCommandSubcommandBuilder() //
.setName('something')
)
);
}

public override async chatInputRun(interaction: Command.ChatInputCommandInteraction) {
// TODO
}
}
6 Replies
Teixeira
TeixeiraOP2mo ago
2025-10-08 12:45:18 - ERROR - Encountered error while handling the command application command registry for command "builderbug" at path "dist\shard\commands\BuilderBug.js" ExpectedValidationError > s.instance(V)
2025-10-08 12:45:18 - ERROR - Expected
2025-10-08 12:45:18 - ERROR -
2025-10-08 12:45:18 - ERROR - Expected:
2025-10-08 12:45:18 - ERROR - | [Function: SlashCommandSubcommandBuilder]
2025-10-08 12:45:18 - ERROR -
2025-10-08 12:45:18 - ERROR - Received:
2025-10-08 12:45:18 - ERROR - | [Object]
2025-10-08 12:45:18 - ERROR -
2025-10-08 12:45:18 - ERROR - at _InstanceValidator.handle (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@sapphire/shapeshift/src/validators/InstanceValidator.ts:10:133)
2025-10-08 12:45:18 - ERROR - at _InstanceValidator.parse (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:119:3)
2025-10-08 12:45:18 - ERROR - at assertReturnOfBuilder (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@discordjs/builders/src/interactions/slashCommands/Assertions.ts:79:33)
2025-10-08 12:45:18 - ERROR - at MixedClass.addSubcommand (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@discordjs/builders/src/interactions/slashCommands/mixins/SharedSubcommands.ts:59:3)
2025-10-08 12:45:18 - ERROR - at file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/dist/shard/commands/BuilderBug.js?d=1759923916897&name=BuilderBug&extension=.js:10:14
2025-10-08 12:45:18 - ERROR - Encountered error while handling the command application command registry for command "builderbug" at path "dist\shard\commands\BuilderBug.js" ExpectedValidationError > s.instance(V)
2025-10-08 12:45:18 - ERROR - Expected
2025-10-08 12:45:18 - ERROR -
2025-10-08 12:45:18 - ERROR - Expected:
2025-10-08 12:45:18 - ERROR - | [Function: SlashCommandSubcommandBuilder]
2025-10-08 12:45:18 - ERROR -
2025-10-08 12:45:18 - ERROR - Received:
2025-10-08 12:45:18 - ERROR - | [Object]
2025-10-08 12:45:18 - ERROR -
2025-10-08 12:45:18 - ERROR - at _InstanceValidator.handle (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@sapphire/shapeshift/src/validators/InstanceValidator.ts:10:133)
2025-10-08 12:45:18 - ERROR - at _InstanceValidator.parse (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@sapphire/shapeshift/src/validators/BaseValidator.ts:119:3)
2025-10-08 12:45:18 - ERROR - at assertReturnOfBuilder (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@discordjs/builders/src/interactions/slashCommands/Assertions.ts:79:33)
2025-10-08 12:45:18 - ERROR - at MixedClass.addSubcommand (file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/node_modules/@discordjs/builders/src/interactions/slashCommands/mixins/SharedSubcommands.ts:59:3)
2025-10-08 12:45:18 - ERROR - at file:///C:/Users/jpedr/Documents/Workshop/Work/autogems/discord-bot/services/discord-bot/dist/shard/commands/BuilderBug.js?d=1759923916897&name=BuilderBug&extension=.js:10:14
Favna
Favna2mo ago
Check your dependencies versions. Probably multiple versions there. Either dedupe or if that doesn't work due to conflicting semver locate what pulls in the lower version and fix it or make a pr to fix it.
Teixeira
TeixeiraOP2mo ago
Hey, I've just double checked and I have a single version of @discordjs/builders
No description
Favna
Favna2mo ago
We pass the code 1:1 to djs even before calling any validations whatsoever...
Teixeira
TeixeiraOP2mo ago
Could it have something to do with the fact I'm using npm workspaces which hoists common modules between my workspaces to the root dir?
Favna
Favna2mo ago
It could yes Validate the versions in every package and in node_modules Idk if npm ls respects workspaces You can also manually check your package-lock

Did you find this page helpful?