interaction.client.commands

How do i access to commands while interaction.client.commands doesn't exist?
No description
101 Replies
d.js toolkit
d.js toolkit8mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
linesty
linestyOP8mo ago
Node: v20.12.2
d.js docs
d.js docs8mo 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
linesty
linestyOP8mo ago
@Svitkona So like this? I'm confused
No description
linesty
linestyOP8mo ago
client is bot client
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
how do i extend Client? that doesn't seem to work
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs8mo ago
Documentation suggestion for @linesty: :mdn: extends The extends keyword is used in class declarations or class expressions to create a class that is a child of another class.
linesty
linestyOP8mo ago
No description
No description
linesty
linestyOP8mo ago
like that?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
d.js docs
d.js docs8mo ago
Documentation suggestion for @linesty: :mdn: Classes Classes are a template for creating objects. They encapsulate data with code to work on that data. Classes in JS are built on prototypes but also have some syntax and semantics that are unique to classes.
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
i get the idea of classes just not extends ill learn im confused how Client is a class, i cannot extend it, its discord.js thing
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
so this would work
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
That's what i did
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
but data, i send only {database}
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
that's what i do
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
now i have issue:
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Svitkona
Svitkona8mo ago
you don't need to reimplement login it's inherited from the base class
TÆMBØ
TÆMBØ8mo ago
Doesn't super(data) do that?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Svitkona
Svitkona8mo ago
the error is because your new implementation is conflicting with the inherited implementation probably...
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
the only thing i want to make is so my slash commands work
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
TÆMBØ
TÆMBØ8mo ago
You need to actually call the constructor for Collection
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
its MongoDB,
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
i import Collection from discord.js
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
yeah i already do that
linesty
linestyOP8mo ago
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
TÆMBØ
TÆMBØ8mo ago
No, you're not, this does not show that
linesty
linestyOP8mo ago
it prints undefined
No description
linesty
linestyOP8mo ago
as command not found
TÆMBØ
TÆMBØ8mo ago
And like what was already mentioned, I'm not sure why you're extending the Client class, but then making a new instance of it as a client property. Please look into how inheritance works in JS
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
while it does have command
TÆMBØ
TÆMBØ8mo ago
Yea, but look what the key for it is
linesty
linestyOP8mo ago
no key
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
TÆMBØ
TÆMBØ8mo ago
No, there is a key, it's just that its value is undefined
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
TÆMBØ
TÆMBØ8mo ago
I'm also not sure why you're casting this as any, you're sort of defeating the point of using TS
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
omg
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
now it has id
linesty
linestyOP8mo ago
and it finds command
No description
linesty
linestyOP8mo ago
guys we did it
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
time to re- read all this messages and learn
linesty
linestyOP8mo ago
No description
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
TÆMBØ
TÆMBØ8mo ago
Sooo what's the point of extending the Client if you're still just creating a new Client instance yourself and attaching your properties to that?
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
why do i need to pass data that is database class
d.js docs
d.js docs8mo ago
Documentation suggestion for @linesty: :mdn: Classes Classes are a template for creating objects. They encapsulate data with code to work on that data. Classes in JS are built on prototypes but also have some syntax and semantics that are unique to classes.
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
TÆMBØ
TÆMBØ8mo ago
Because that is how inheritance works, super() calls the parent class to create an instance of it with that parameter
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
got it
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
my database is just to get collection, and some functions so i could use it inside any bot interaction commands
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
i got it, so i can basiclly just create a new Database class inside discord
linesty
linestyOP8mo ago
No description
linesty
linestyOP8mo ago
so i could just do this? in every file that i need access to database
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
and it won't like bug or anything if i make 10 new Databases in every file
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
oh i just enter to it like a module
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
gotcha, was thinking it creates 1000 times
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
linesty
linestyOP8mo ago
got it, will read it rn
linesty
linestyOP8mo ago
I'm currently havving issues with compoents anyone know how to fix?
No description
No description
d.js docs
d.js docs8mo ago
In TypeScript the ActionRowBuilder class has a generic type parameter that specifies the type of component the action row holds:
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
const row = new ActionRowBuilder<ButtonBuilder>().addComponents(button)
const row = new ActionRowBuilder<StringSelectMenuBuilder>().addComponents(selectMenu)
const row = new ActionRowBuilder<TextInputBuilder>().addComponents(textInput)
linesty
linestyOP8mo ago
ty
Want results from more Discord servers?
Add your server