interaction.client.commands
How do i access to commands while interaction.client.commands doesn't exist?
101 Replies
- 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!Node:
v20.12.2
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@Svitkona
So like this?
I'm confused
client is bot client
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
how do i extend Client?
that doesn't seem to work
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
like that?
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
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•8mo ago
Message Not Public
Sign In & Join Server To View
so this would work
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
That's what i did
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
but data, i send only {database}
that's what i do
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
now i have issue:
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
you don't need to reimplement login
it's inherited from the base class
Doesn't
super(data)
do that?Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
the error is because your new implementation is conflicting with the inherited implementation
probably...
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
the only thing i want to make is so my slash commands work
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
You need to actually call the constructor for
Collection
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
its MongoDB,
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
i import Collection from discord.js
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
yeah i already do that
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
No, you're not, this does not show that
it prints
undefined
as command not found
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 JSwhile it does have command
Yea, but look what the key for it is
no key
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
No, there is a key, it's just that its value is undefined
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
I'm also not sure why you're casting this as
any
, you're sort of defeating the point of using TSUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
omg
now it has id
and it finds command
guys we did it
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
time to re- read all this messages and learn
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
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•8mo ago
Message Not Public
Sign In & Join Server To View
why do i need to pass data that is database class
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
Because that is how inheritance works,
super()
calls the parent class to create an instance of it with that parameterUnknown User•8mo ago
Message Not Public
Sign In & Join Server To View
got it
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
my database is just to get collection, and some functions so i could use it inside any bot interaction commands
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
i got it, so i can basiclly just create a new Database class inside discord
so i could just do this?
in every file that i need access to database
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
and it won't like bug or anything if i make 10 new Databases in every file
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
oh i just enter to it like a module
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
gotcha, was thinking it creates 1000 times
Unknown User•8mo ago
Message Not Public
Sign In & Join Server To View
got it, will read it rn
I'm currently havving issues with compoents anyone know how to fix?
In TypeScript the
ActionRowBuilder
class has a generic type parameter that specifies the type of component the action row holds:
ty