Handling commands with promises
Hi! So I have been working on this problem for a bit now. I've slowly solved most of the issues I've run into, but this one has me stumped. I know how to handle promises normally, but I cant seem to be able to make it work when loading commands.
Here is a little explanation of the command im making. Basically, In my server we have a command to create characters. That command seems to be working find, but then I made a command that retrieves that character info. In order to avoid having any spelling issues or dealing with case insensitivity What I did was loaded all of the characters in the db using prismaORM and mapped the names so they can be passed into the setChoices method in the EmbedBuilder class. However because this requires async/await it isn't quite working right. Below is my code and a screenshot of the error I'm getting. Thank you in advance for the help on this!
There actually isnt an error, but my condition in index.js is saying "Command with name [] not found. Even though the deploy-commands.js is loading 4 commands (and thats all i have so far.)
62 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!seems like your command isnt being pushed into client.commands then
you'll have to log to see what is being pushed
doesnt seem to be the case, its pushing exactly what Im expecting it to
if it was this wouldnt be your issue
![No description](https://cdn.answeroverflow.com/1263979101971283990/image.png)
this is part of the log before the commands are deployed
its in there which is why im confused
deploying your commands =/= populating your client.commands
client.commands doesnt exist. its a custom property
which you have to populate with your commands
they are not automatically added
also why are you setting the avatar every time your bot logs in
is that ai code
ah i see
and some of it, not all. I do see that the name of the command when its loading client.commands.set is undefined
index.js specifically is directly from the docs
except the setAvatar. I did add that myself. I didn't know client.once is called every time. Thats on me, ive only been looking into the docs a couple days
good catch on the avatar. I must have put that there yesterday when I got a little frustrated. Moved that right below where client was declared instead
.once is called only the first time the event is called, and in the case of ClientReady it's only called once so it doesn't matter much
I think what he meant is that you don't need to set your avatar on every login, you should only need to do it once via the portal
unless the logo changes for some reason
understood. Not sure why the other person said client.commands doesnt exist
this is directly from the docs
![No description](https://cdn.answeroverflow.com/1263981872594030652/image.png)
im saying it doesnt exist by default
you create it
and thus you are responsible to populate it
its not bound to the commands you deploy
its in the index.js. Im not sure what you mean
it doesn't exist as in, it's not something managed by djs
it's a property you create as the user
your issue is with you populating your client.commands