Dev works, prod doesnt
Has anyone experienced commands working in dev, but not prod? The commands just will not be registered
68 Replies

I specify a custom directory though with
baseUserDirectory: botDirectory,
works completely fine in devLearnSpigot: Send and save code snippets on our pastebin
LearnSpigot provides a free web-based pastebin service for storing and sharing code snippets with anyone. Powered by hastebin.
Here's with Trace debug enabled
It also does set my bots status

first thought is that your baseUserDirectory between dev and prod is not the same. Do you compile the src to dist or such? are the file systems identical between the 2? Look into those things
1. Which version of
@sapphire/framework
are you using?
2. What's your file/folder structure?
3. Did you use the CLI to generate your bot?
4. What's your main
(CJS) or module
(ESM) property in package.json
5. Are you using TypeScript? And if so, how are you compiling and running your code? That is to say, what are your build and startup scripts?
- Did you remove your output folder and rebuild then try again?
6. Is your problem related to message commands? Did you add loadMessageCommandListeners
to your SapphireClient
options
Remember that if you are new to @sapphire/framework
it is important that you read the user guide.No, not that I am aware of. The start command runs the TS directly

wrong project, here's the correct image

1.
"@sapphire/framework": "^4.0.0",
3. No, the hyperlink leads to a site with broken links btw
4. main is set to src/index.ts
5. Yes, bun runtime. "start": "bun run src/index.ts",
6. No, in prod it would get wiped
7. Yes, loadMessageCommandListeners: true,

I think this is the problem, question is, why ... might be best to set some breakpoints or extra logs in the files in node_modules

@Samu
Thanks yeah I have seen this
Thanks everyone, will check every answer out ASAP
I added a debug message into a command


it simply does not get called during prod
Yeah it doesn't get loaded at all
Like I showed loading gets skipped
So you have to add the log to the code in @sapphire/pieces
ah
And I assume this needs to be changed in prod
If you run in docker then you can explore something like patch package.
And yeah
@Samu 😅
I'd validate if your log change works in Dev tho
interesting
There must be some if check that is failing
The question is which and why
alright let's see how hard this is gonna be
Can we manually register everything in the mean time?
@Boomeravna Hi, sorry for the ping mate, don't want to disturb you but we need to get this running ASAP, can you help us when you get a chance?
@Dawson dont think that'll work
@Samu not sure in what way I can help other than what I've said, especially not without access to your code.
Okay, thanks for your time,we've been trying with what you said, thanks for all the feedback!
My ping was more meant for Dawson's message, we really appreciate it ❤️
the reason I dont think it will is because it will use the loaderstrategy regardless
anyway im macro crafting in ff14 right now so I got some minutes to click around the code
can you start by checking if
process.version
includes the string 'bun'
?sure
other than that I think this is the function where it would get filtered out: https://github.com/sapphiredev/pieces/blob/2c42d6efda2f6711e1ce56ce2a9025c001fcad49/src/lib/strategies/LoaderStrategy.ts#L38-L51
so the file name cannot start with
_
(it doesnt) and TS loading has to be enabled which is https://github.com/sapphiredev/pieces/blob/2c42d6efda2f6711e1ce56ce2a9025c001fcad49/src/lib/strategies/env.ts#L35-L73
uh that is of course assuming you are not overwriting the LoaderStrategy from sapphire pieces. That is quite complex to do so I assume you're not.We made a patch and used postinstall to run it
just to add logging or?
Yeah that's what we are working on
Mainly yeah, i need to test everything out still

btw how do you run on prod? docker? pm2? something else?
if not docker then I know it'll require extra setup but I can recommend it since you can also run the same docker image locally and you dont need to go to prod all the time, you can replicate the exact environment locally.
Docker, we use Dokploy
ah well then if you build the docker image locally and run it then you should be running the same environment locally as you would in prod that should save a lot of time
ive never heard of dokploy but I doubt it does anything special and just follows the containerd spec
Yeah that's an option, fortunately the deployment time is great (about 1min max) so it doesn't take us that much
Nope, it doesn't
hm that's very odd
you do run with bun in prod?
because that would do it
then TS filess arent loaded as per what I linked
console.log("Running on Bun:", process.version.includes('bun'));

Yeah
Okay, the thing i've tried using JS as well (and oh god the experience is terrible after using TypeScript this whole time xD) but still didn't load
the only other idea I have is that it would be baseUserDirectory related that you're overwriting. Any particular reason you're overwriting it?
also what is
process.version
then?We first did it because we made the commands and listeners folder into a general
bot
folder (not package), so i thought that was the standard thing to do, as long as i remember we even tried without overwriting it but it's been a while, worth a try-
Also since i'm at it, i'll log process.version as well
ignore the first part, we already removed it
it's not a mono repo structure but the standard is like this: https://github.com/favware/xiveventbuddy/tree/main/src
I would recommend in a mono repo you do a similar setup but in a subfolder and just have your devdeps and scripts and such shared. I just this through node but bun would be mostly the same. In https://github.com/favware/xiveventbuddy/blob/main/package.json the difference would only be that whereever it says
dist/xiveventbuddy.js
would become src/xiveventbuddy.ts
GitHub
xiveventbuddy/src at main · favware/xiveventbuddy
A user friendly first discord bot to host your XIV events - favware/xiveventbuddy
@workspace/api:start: Running on Bun: false
@workspace/api:start: Process Version: v22.6.0
that looks more like you're running node... ?
There is no bun 22.6.0
what are your dockerfile and package.json?
odd, i didn't set up deployment, @Dawson
Sure,
Dockerfile:
package.json:
where is 'start:api'?
it's not in those scripts
odd. I wonder if turbo messes it up somehow. Can you try this in the dockerfile?
For sure
mhh.
several errors like this
those arent errors. That's just trace logging that it registered the paths
my bad, dokploy counts them as errors

wrong term
Also we're doing some debugging with the Bot Token so it might take a while

It is using bun to run the index.ts

hmmm
i think a patch to pieces may be needed
a new way to detect bun
@Samu you can run
console.log(Bun.version)
if you want to check if it's using bun
but this shows it islet me quick hotfix this
Awesome, thank you

Solution
try the new version #Announcements
Thanks mate!
Will do
he lied
great job lying samu
and he just ghost pinged you
This works amazing!!!! Sorry for the ghost ping
@Dawson screw you!
Anyways, thank you so much for the help on this!
Absolutely mate, we do really appreciate it! Great support