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
}
}
2 Replies
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
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.