Many typing issues with Typescript

I am new to DiscordJS, and I keep facing typing issues with Typescript.. There are some examples in the images I tried many types but none seem to work, does anyone have a solution to suggest ? Here are my dependencies : "discord.js": "^14.11.0", "dotenv": "^16.3.1" Here are my dev dependencies : "@types/node": "^20.4.2", "ts-node": "^10.9.1", "typescript": "^5.1.6"
6 Replies
d.js toolkit
d.js toolkit17mo ago
- 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. - Issue solved? Press the button!
duck
duck17mo ago
for the first error, you'll need to typeguard your interaction if that's intended for a slash command, you can use <Interaction>.isChatInputCommand() otherwise, feel free to check out the docs for the appropriate method
d.js docs
d.js docs17mo ago
method BaseInteraction#isChatInputCommand() Indicates whether this interaction is a ChatInputCommandInteraction. We highly recommend you extend the Client structure properly instead of just attaching custom properties like .commands to the regular discord.js Client instance. - Using typescript, you might want to consider casting or augmenting the module type
Emi
EmiOP17mo ago
I've been checking the documentation for a while but couldn't find solutions to my problem... are DiscordJS and Typescript really a good mix of techonologies or should it be avoided ? I tried to check forums too, but it seems like I'm the only person that has so many typing issues I'm wondering if I did something extremely wrong or if DiscordJS is not suited for Typescript hehe
duck
duck17mo ago
it's fine to use ts the errors you're receiving are a result of discord.js having typescript support however it's not required to use ts if you don't feel comfortable enough with ts basics if you're following the official guide, make sure to take note of the tips and warnings in colored boxes often ts specific things will be noted there
Emi
EmiOP17mo ago
Okie I see I was wondering because I already get multiple typing issues after writing about 10 lines of code so... But okie Thank you
Want results from more Discord servers?
Add your server