Import client variable in a SlashCommandBuilder function

Hello, i'm trying to use the client variable inside a command but its not accessible.
11 Replies
d.js toolkit
d.js toolkit13mo 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.
Lixeiro Charmoso
Lixeiro Charmoso13mo ago
In the client constructor i have my database settings
Lixeiro Charmoso
Lixeiro Charmoso13mo ago
This is how i use it in the default files
Lixeiro Charmoso
Lixeiro Charmoso13mo ago
but here in the slash commands i dont have the client like in the other files
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Lixeiro Charmoso
Lixeiro Charmoso13mo ago
Tried to use interaction.client but it does not have the db parameter
d.js docs
d.js docs13mo ago
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
Lixeiro Charmoso
Lixeiro Charmoso13mo ago
Using javascript Why it is not properly extending?
Unknown User
Unknown User13mo ago
Message Not Public
Sign In & Join Server To View
Lixeiro Charmoso
Lixeiro Charmoso13mo ago
Using: interaction.client.db.query Error: Cannot read properties of undefined (reading 'query') The custom property i added does not exist here But i'm not understanding why It isnt this one? line 29 Thank you. Your question clarified my mind and i figure out that i have a file DeploySlash.js that instantiate the client without adding the .db property Not the best solution, but adding the db there works 😄 Using a custom class is a way better but it is how it is because it was the way i found to make it work. That code was made some years ago its a bit outdated nor using the best practices I learned much over the years
MaxJ
MaxJ13mo ago
Maybe add the custom client to the parameters when executing the method