`ApplicationCommandType` TypeError

I'm attempting to create a context menu command:
import { Command } from '@sapphire/framework';
import { ApplicationCommandType } from 'discord.js';

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

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerContextMenuCommand(
(builder) =>
builder
.setName('List Characters') //
.setType(ApplicationCommandType.User)
);
}
}
import { Command } from '@sapphire/framework';
import { ApplicationCommandType } from 'discord.js';

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

public override registerApplicationCommands(registry: Command.Registry) {
registry.registerContextMenuCommand(
(builder) =>
builder
.setName('List Characters') //
.setType(ApplicationCommandType.User)
);
}
}
I'm getting the following TypeError:
Argument of type 'ApplicationCommandType.User' is not assignable to parameter of type 'ContextMenuCommandType'.ts(2345)
Argument of type 'ApplicationCommandType.User' is not assignable to parameter of type 'ContextMenuCommandType'.ts(2345)
I've tried importing the enum from discord-api-types/v10 instead but it throws the same error, not sure what I'm doing wrong!
Solution:
It's an issue with the types from discord.js, here's their FAQ that mentions this and the solution: https://discord.com/channels/222078108977594368/1320493963467296929...
Jump to solution
6 Replies
Solution
SirH
SirH4w ago
It's an issue with the types from discord.js, here's their FAQ that mentions this and the solution: https://discord.com/channels/222078108977594368/1320493963467296929
Teixeira
TeixeiraOP4w ago
Still getting the same error after setting overrides and running npm i (also tried deleting node_modules)
"dependencies": {
"@fastify/autoload": "^5.10.0",
"@fastify/bearer-auth": "^9.4.0",
"@fastify/type-provider-typebox": "^5.0.0",
"@sapphire/framework": "^5.2.1",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^7.0.0",
"@sapphire/string-store": "^1.2.0-next.3b1a353c",
"@sapphire/timestamp": "^1.0.3",
"@sinclair/typebox": "^0.32.34",
"discord.js": "^14.15.3",
"envalid": "^8.0.0",
"fastify": "^5.0.0",
"luxon": "^3.5.0",
"mongoose": "^8.6.4"
},
"overrides": {
"discord-api-types": "0.37.114"
},
"dependencies": {
"@fastify/autoload": "^5.10.0",
"@fastify/bearer-auth": "^9.4.0",
"@fastify/type-provider-typebox": "^5.0.0",
"@sapphire/framework": "^5.2.1",
"@sapphire/plugin-logger": "^4.0.2",
"@sapphire/plugin-subcommands": "^7.0.0",
"@sapphire/string-store": "^1.2.0-next.3b1a353c",
"@sapphire/timestamp": "^1.0.3",
"@sinclair/typebox": "^0.32.34",
"discord.js": "^14.15.3",
"envalid": "^8.0.0",
"fastify": "^5.0.0",
"luxon": "^3.5.0",
"mongoose": "^8.6.4"
},
"overrides": {
"discord-api-types": "0.37.114"
},
SirH
SirH4w ago
Idk, but I'd recommend asking in discord.js support, they probably would know what else might be up with it since that didn't fix it for you. But have you also restarted the tsserver? Sometimes it likes to be a pain in the butt
Teixeira
TeixeiraOP4w ago
Yes I did :/ I'll check it out with them, thank you for the help! When/if I find the solution I'll post it here
SirH
SirH4w ago
Awesome
Teixeira
TeixeiraOP4w ago
I'm using npm workspaces and I had placed the overrides key in the workspace's package.json but it needed to be in my "root" package's package.json instead, that fixed it, thank you again for the help!

Did you find this page helpful?