SlashCommandBuilder is not defined in compiled TypeScript, but the TypeScript file acts like it is
Hi everybody,
I'm pretty new to TypeScript and wanted to migrate my bot to use it instead of JavaScript. No errors in the compiler (well, one intentional), and everything looks fine. When starting up my bot, however, it immediately crashes and says that SlashCommandBuilder is not defined. All other signs say it is defined. I am using a command handler slightly modified from the one in discordjs.guide.
6 Replies
• What's your exact discord.js
npm list discord.js
and node node -v
version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.I would appreciate being pinged if you reply :)
can you show your ts code that compiles and js code that fails
Sure, just a second
The full error:
TypeScript code (SlashCommandBuilder is already defined in index.ts, I can show some of that if it would be helpful)
JS compiled version:
@qjuh @superchupu
I can provide more if needed I just wasn't sure if it was
I had it in them both and it complained that it was already defined?
however the compiler doesn't complain about that...
const { SlashCommandBuilder } = require ("discord.js");
, as I was doing before. I'm not sure what block-scoped means, do I need to do this some other way with typescript?
As I said I'm quite new to typescript 😆
Will do. Thanks.