Types for discord.js with TypeScript
So, I've tried to install
@types/discord.js
, however I get a 404 error. Where can I find types for discord.js?17 Replies
The types are shipped with discord.js inbuilt
discord.js provides full typescript support by default/on install
Oh, so do I need to import them or? For example when defining a client:
Can I just do it like that? The
{something: "a"}
part gives me an error because it isn't a client option, so I guess that's correct?yes
something: "a"
is not an option
but intents
are• Websocket intents limit events and decrease memory usage: learn more
• See what intents you need here
Right! Thank you a lot!
Just starting with TypeScript and this looks very cool!
Also, is there a place where I can find all types in discord.js, for example in the ready event?
Nvm found it
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
on top of every file or just the index one?
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
this is incorrect, it imports discord.js with the name
all
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
I'll deffinitely refer to this later, but since I'm just starting with TS, I'll import needed types at the top of the file when I need them
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
:)
Also, for anyone else looking at this in the future, just discovered there is a blue TS icon (picture above) on the npm site, when a library has built-in TS declarations.
i don't see the reason for that
that's considered best practice anyways
The answer is the docs
Discord.js
Discord.js is a powerful node.js module that allows you to interact with the Discord API very easily. It takes a much more object-oriented approach than most other JS Discord libraries, making your bot's code significantly tidier and easier to comprehend.