#Stuck on discord.js guide while using TypeScript
24 messages · Page 1 of 1 (latest)
my .commands property is not being recognized with typescript.
I'm not not sure how to do the part in the discord.js guide that I've highlighted in the first screenshot.
Tag suggestion for @oak chasm:
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
Yes, this is what I'm not sure how to do. I don't know how to augment the module type.
I have trouble understanding the guide when I look at it. It's a little hard for me to visualize in my head on how to implement it.
declare module "discord.js" {
export interface Client {
commands: Collection<string, Command>;
}
}```
Replace Command with your own command type
Is this suppose to be added at the top of my index.ts?
err no, it would go in a d.ts file it seems.
Sorry, I'm not entirely sure what you mean by my own command type.
It's a Collection object right?
I'm just trying to follow through with the discord.js guide
Yeah but what are you putting in the collection
I'm not sure yet, I haven't gotten that far in the guide lol.
https://discordjs.guide/creating-your-bot/command-handling.html#loading-command-files
Not very familiar. I've only set it up a couple times, but this is the first time I'm trying to set it up on a discord js bot.
The guide really barely touches on TypeScript, its written with JS examples throughout
I see