TS App does not attach event listeners once complied, works in dev
Hi, my application doesn't execute any event listeners in a compiled JS state, but works fine when booting into TS via nodemon.
I've tried multiple bot accounts with replicated permissions, inside and outside of docker containers, locally and deployed, but for some reason compiling the app to JS gets the app stuck after
ApplicationCommandRegistries
INFO logs are fired. I also can't amend the LogLevel
option on Sapphire instantiation.
Any advice or insight greatly welcome! This has been driving me madSolution:Jump to solution
For anyone that stumbles upon this in future with similar symptoms (app booting, bot is registered online in discord but events not picked up) my solution was to update
package.json
's main
parameter to an appropriate value against the compiled JS entrypoint - in my case dist/index.js
.4 Replies
My package.json dependencies and scripts:
My tsconfig.json
Compiled app is started via a
node ./index.js
command relative to the /dist
folder. Dist folder looks like the below once built via Dockerfile
Finally, index.ts
looks like this and is the root of my application
As always, typing the problem out helps you solve it 😅 Thanks for being a rubber duck...Solution
For anyone that stumbles upon this in future with similar symptoms (app booting, bot is registered online in discord but events not picked up) my solution was to update
package.json
's main
parameter to an appropriate value against the compiled JS entrypoint - in my case dist/index.js
.Note this also needs to be relevant to where you're booting from, you can't just specify a folder path and it works it out.
Fwiw our guide starts with this because it's such a common problem https://sapphirejs.dev/docs/Guide/getting-started/getting-started-with-sapphire
Sapphire Framework
Getting started with Sapphire | Sapphire
To install Sapphire, you need to install both discord.js and