#Want to deploy my bot but its not working?!

61 messages ยท Page 1 of 1 (latest)

topaz briarBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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!
compact nymph
#

You can't import a folder. That is indeed wrong in your code

#

Show your imports in index.ts

candid owl
#

ah

#
import { commands } from "./commands";
import { deployGlobalCommands } from "./deploy-commands";
import { EnhancedLogger } from "./logger/enhancedLogger";
import { TicketHandler } from "./handlers/ticketHandler";
import { ApplicationHandler } from "./handlers/applicationHandler";
import { SuggestionHandler } from "./handlers/suggestionHandler";
import { GiveawayHandler } from "./handlers/giveawayHandler";
import { startRoleAssigning } from "./Listeners/JoinRole";```
compact nymph
#

What runtime do you use to run that? Considering you say node but it seems to run ts files

#

You probably want from "./commands/index.js"

candid owl
#

its typescript

compact nymph
#

That's the language. But how do you run it? node with experimental CLI flags or another runtime or..?

candid owl
#

npm run dev

#

and that runs tsx watch src/index.ts

uncut drift
#

thats what you run to start it on your local pc but since it works there but not on the host im assuming the host just tries to run it with normal node which doesnt support running typescript directly

candid owl
#

my hosts startup command is

if [[ -d .git ]] && [[ 1 == "1" ]]; then git pull; fi; if [[ ! -z ${NODE_PACKAGES} ]]; then /usr/local/bin/npm install ${NODE_PACKAGES}; fi; if [[ ! -z ${UNNODE_PACKAGES} ]]; then /usr/local/bin/npm uninstall ${UNNODE_PACKAGES}; fi; if [ -f /home/container/package.json ]; then /usr/local/bin/npm install; fi; if [[ "${MAIN_FILE}" == "*.js" ]]; then /usr/local/bin/node "/home/container/${MAIN_FILE}" ${NODE_ARGS}; else /usr/local/bin/ts-node --esm "/home/container/${MAIN_FILE}" ${NODE_ARGS}; fi```
compact nymph
compact nymph
#

I'd rather suggest uploading the transpiled js files and run those on your host

candid owl
#

the transpiled js files?

#

what is that sorry im new to deploying discord bots

compact nymph
#

Are you also new to typescript as a language?

#

tsc or any other transpiler you use will give you .js files

candid owl
compact nymph
#

Then where did you get all that content you have from? Who told you to use tsx and all that stuff?

candid owl
#

a friend ๐Ÿ’€

#

but he dont make discord bots-

compact nymph
#

Then ask that friend how to run in production

#

Because that's definitely not gonna get you the answer npm run dev

candid owl
#

he doesnt know as he dont make discord bots ๐Ÿ’€

compact nymph
#

Irrelevant. If he does anything in typescript then that anything would still run in production in the end

candid owl
#

I will ask him

#

but whats the correct way?

compact nymph
#

Alternatively don't use tsx and instead tsc

candid owl
#

bet

compact nymph
#

Assuming you have a tsconfig setup

candid owl
#

I will use that

#

I do

#

Do i need to recode everything

#

for TSC

compact nymph
#

No

#

Just add another script in your package.json, name it build for example and just put tsc.
Maybe want to add an outdir: config in your tsconfig.json before

candid owl
#

what is it

npx tsc

#

it needs to run

#

so its like:
"build": "npx tsc",

compact nymph
#

In scripts you don't needs the npx

candid owl
#

ah

#

just tsc

compact nymph
#

Because that's when you run from console directly. In npm scripts the npx always is implied

candid owl
#

so i can just type npx tsc in console?

#

without any issue

compact nymph
#

Try it and see

candid owl
#

it will giev sum errors

#

xD

#

but everything works fine in the discord bot

candid owl
uncut drift
#

was a folder made?

#

might be called dist?

candid owl
#

yea

#

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/home/container/src/config/config' imported from /home/container/src/index.ts
at finalizeResolution (node:internal/modules/esm/resolve:275:11)
at moduleResolve (node:internal/modules/esm/resolve:860:10)
at defaultResolve (node:internal/modules/esm/resolve:984:11)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at resolve (/usr/local/lib/node_modules/ts-node/dist/child/child-loader.js:15:125)
at nextResolve (node:internal/modules/esm/hooks:748:28)
at Hooks.resolve (node:internal/modules/esm/hooks:240:30)
at handleMessage (node:internal/modules/esm/worker:199:24)
at Immediate.checkForMessages (node:internal/modules/esm/worker:141:28)
at process.processImmediate (node:internal/timers:505:21) {
code: 'ERR_MODULE_NOT_FOUND',
url: 'file:///home/container/src/config/config'
}

Even there is a src/config/config.ts

compact nymph
#

You should run node dist/index.js now

#

Not the ts files

candid owl
#

BRO!