using SlashCommandBuilder in Constructor
Hey im updating my old discord bot to v14 and used the slashcommand builder in a constructor after updaing it does not work anymore, can someone help me with that?
14 Replies
- What's your exact discord.js
npm list discord.js
and node node -v
version?
- Not a discord.js issue? Check out #other-js-ts.
- Consider reading #how-to-get-help to improve your question!
- Explain what exactly your issue is.
- Post the full error stack trace, not just the top part!
- Show your code!
- Issue solved? Press the button!does not work anymoreelaborate as a side note:
discord.js includes multiple sub-packages, installing these separately can mess with internal code:
you cannt use the slashcommand builder in a constructor? do u know why?
define "can't use"
mb
it throws an error when running? when building? it doesn't work as expected, if so, how?
it shows an error in the ide
[{
"resource": "src/commands/ban.ts",
"owner": "typescript",
"code": "2345",
"severity": 8,
"message": "Argument of type 'SlashCommandOptionsOnlyBuilder' is not assignable to parameter of type 'SlashCommandSubcommandsOnlyBuilder | Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">'.\n Type 'SlashCommandOptionsOnlyBuilder' is not assignable to type 'Omit<SlashCommandBuilder, "addSubcommand" | "addSubcommandGroup">'.\n The types returned by 'setName(...)' are incompatible between these types.\n Type 'SlashCommandOptionsOnlyBuilder' is missing the following properties from type 'SlashCommandBuilder': addSubcommandGroup, addSubcommand",
"source": "ts",
"startLineNumber": 11,
"startColumn": 7,
"endLineNumber": 15,
"endColumn": 100
}]
Unknown User•4mo ago
Message Not Public
Sign In & Join Server To View
thats possible
I used a "BaseCommand" to create my commands and used the SlashCommandBuilder in the Constructor. now it thows and error in vscode but i cannto get rid of the error
the error isn't about using it in the constructor, as the message clearly says
the problem's about the builder's type not matching your BaseCommand's type
you can try using SlashCommandOptionsOnlyBuilder | SlashCommandSubcommandsOnlyBuilder instead, or using a Pick type with the properties that you need
like toJSON
Thank you it worked 🙂
Sorry for my stupidity