KagChi / noteblock

A open-source music bot based on lavalink.
GNU General Public License v3.0
115 stars 110 forks source link

could not start on replit #45

Open fanesz opened 2 years ago

fanesz commented 2 years ago

i can't run in replit, it always says [Symbol(code)]: 'TOKEN_INVALID'] because i can't rename .env.scheme to .env how to solve it?

KagChi commented 2 years ago

replit introduce new way to fill .env file, its now on environtment tab

fanesz commented 2 years ago

i just did that, but it still show this

[2021-10-12T14:07:38.291] [INFO] NOTEBLOCK - [REPLIT ENVIRONMENT DETECTED] [STARTING WEBSERVER]
/home/runner/noteblock-2/node_modules/discord.js/src/client/Client.js:228
    if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID');
                                                   ^

Error [TOKEN_INVALID]: An invalid token was provided.
    at NoteClient.login (/home/runner/noteblock-2/node_modules/discord.js/src/client/Client.js:228:52)
    at NoteClient.initialize (/home/runner/noteblock-2/src/Struct/NoteClient.js:75:10)
    at Object.<anonymous> (/home/runner/noteblock-2/src/index.js:6:8)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at initialize (/home/runner/noteblock-2/src/main.js:25:12) {
  [Symbol(code)]: 'TOKEN_INVALID'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! noteblock@1.3.0 start: `bash start.sh`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the noteblock@1.3.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2021-10-12T14_07_39_392Z-debug.log
exit status 1

what i did :

  1. import from github
  2. input owner id at index.js
  3. make .env on environtment tab
  4. run
KagChi commented 2 years ago

does it log your token if do console.log(process.env.DISCORD_TOKEN) ?, aslo dont copy the client secret one

fanesz commented 2 years ago

it says :

console.log(process.env.DISCORD_TOKEN)
bash: syntax error near unexpected token `process.env.DISCORD_TOKEN'
KagChi commented 2 years ago

in your main.js file duh, basic js.

fanesz commented 2 years ago

sorry im new, i try to put console.log(process.env.DISCORD_TOKEN) in src/main.js but still says the same error (i've tried put it at the first line, middle line, and last line)

KagChi commented 2 years ago

does it log your token

fanesz commented 2 years ago

no, i didn't see any token when i run with that thing in my main.js still show same error

fanesz commented 2 years ago

also i've try self hosting it, and work perfectly. So i think the problem is with replit.

KagChi commented 2 years ago

also i've try self hosting it, and work perfectly. So i think the problem is with replit.

Maybe you wrongly place the cofiguration in environment

fanesz commented 2 years ago

i just host it at HEROKU.com and work perfectly, but i still want host it at replit because heroku have limit usage.

is that any command for .replit file to read and run inside the code folder? so i can bash start.sh along with .env file in the same folder? like : (inside .replit)

cd noteblock
run="npm run"

or maybe can i move .env file inside any folder and main.js still can read it?

KagChi commented 2 years ago

image are you inputed environment like this?

fanesz commented 2 years ago

yes, i input : key -> .env value -> DISCORD_TOKEN=xxxx

fanesz commented 2 years ago

SOLVED

so i just do npm install after cloning, then make .env with the things inside src folder then in main.js i change from : require('dotenv').config(); to

const path = require('path')
require('dotenv').config({ path: path.resolve(__dirname, '.env') })

and it work prefectly ^^

KagChi commented 2 years ago

thanks for resolving, current issue. gonna add to the code soon

Boggles1288 commented 2 years ago

THis still doesn't work, please help, I'm a bit rusty to this. I did everything you guys said and I got this error:

`[2022-06-17T07:42:45.419] [INFO] NOTEBLOCK - [REPLIT ENVIRONMENT DETECTED] [STARTING WEBSERVER] /home/runner/noteblock/node_modules/discord.js/src/client/Client.js:237 if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID'); ^

Error [TOKEN_INVALID]: An invalid token was provided.  npm start

noteblock@1.3.0 start /home/runner/noteblock bash start.sh

npm WARN lifecycle The node binary used for scripts is /usr/bin/node but npm is using /home/runner/noteblock/node_modules/node/bin/node itself. Use the --scripts-prepend-node-path option to include the path for the node binary npm was executed with.

node@16.14.2 preinstall /home/runner/noteblock/node_modules/node node installArchSpecificPackage

65 packages are looking for funding run npm fund for details

found 0 vulnerabilities

[2022-06-17T07:43:21.975] [INFO] NOTEBLOCK - [REPLIT ENVIRONMENT DETECTED] [STARTING WEBSERVER] /home/runner/noteblock/node_modules/discord.js/src/client/Client.js:237 if (!token || typeof token !== 'string') throw new Error('TOKEN_INVALID'); ^

Error [TOKEN_INVALID]: An invalid token was provided. at NoteClient.login (/home/runner/noteblock/node_modules/discord.js/src/client/Client.js:237:52) at NoteClient.initialize (/home/runner/noteblock/src/Struct/NoteClient.js:75:10) at Object. (/home/runner/noteblock/src/index.js:7:8) at Module._compile (node:internal/modules/cjs/loader:1103:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10) at Module.load (node:internal/modules/cjs/loader:981:32) at Function.Module._load (node:internal/modules/cjs/loader:822:12) at Module.require (node:internal/modules/cjs/loader:1005:19) at require (node:internal/modules/cjs/helpers:102:18) at initialize (/home/runner/noteblock/src/main.js:26:12) {

} npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! noteblock@1.3.0 start: bash start.sh npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the noteblock@1.3.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! /home/runner/.npm/_logs/2022-06-17T07_43_24_237Z-debug.log exit status 1`

UnknownLITE commented 2 years ago

yes, i input : key -> .env value -> DISCORD_TOKEN=xxxx

Nope, you did it wrong, This is what should be (according to this repo) key=DISCORD_TOKEN, value=[insert_your_bot_token_here]

KagChi commented 2 years ago

yes, i input : key -> .env value -> DISCORD_TOKEN=xxxx

Nope, you did it wrong, This is what should be (according to this repo) key=DISCORD_TOKEN, value=****

this is not valid.

env should be DISCORD_TOKEN=TOKEN DISCORD_TOKEN is your key, and token is your value.

UnknownLITE commented 2 years ago

I'm talking about Replit Secrets This 👇 image