Bilaboz/duino-stats

Help!

CoolGuy909 opened this issue · 24 comments

Hello! When i try to run the code with "node index" or "nodejs index" i get this error.

/root/duino-stats-main/index.js:32
client.guilds.cache.forEach(async (g) => {
^

SyntaxError: Unexpected token (
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

i tried removing client.guilds.cache.forEach(async (g) => { but then i get this
let pull = require(./commands/${f});
^^^

SyntaxError: Block-scoped declarations (let, const, function, class) not yet supported outside strict mode
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3

What should i do?

Hey! Which version of node are you running?
You can check it with node -v

I am running version 4.2.6

Ah. I updates to Node.js 12. APT downloaded version 4 for some reason. Thanks anyways!

i will see if it will work. If it wont i will reopen the issue.

Ok 👍

Huh, It seems its getting stuck in
#36: webwallet.js loaded!

No errors?
And did you add your bot token and mongodb connection url in the .env file?

yup!

I am trying to reinstall the modules.

Hmm. Same thing.

Can you send the full output please

MongoDB connection error: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string.
(node:12653) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (/coolguy/duino-stats-main/node_modules/discord.js/src/client/Client.js:206:52)
at Object. (/root/duino-stats-main/index.js:19:8)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
(node:12653) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12653) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
#1: add.js loaded!
#2: balance.js loaded!
#3: ban.js loaded!
#4: bump.js loaded!
#5: clear.js loaded!
#6: coinflip.js loaded!
#7: daily.js loaded!
#8: deposit.js loaded!
#9: eval.js loaded!
#10: exchange.js loaded!
#11: exchangeBalance.js loaded!
#12: exchangeLeaderboard.js loaded!
#13: execute.js loaded!
#14: feed.js loaded!
#15: gamble.js loaded!
#16: help.js loaded!
#17: infractions.js loaded!
#18: kick.js loaded!
#19: leaderboard.js loaded!
#20: pay.js loaded!
#21: price.js loaded!
#22: profile.js loaded!
#23: reload.js loaded!
#24: remove.js loaded!
#25: removeinfraction.js loaded!
#26: restartServer.js.js loaded!
#27: roulette.js loaded!
#28: say.js loaded!
#29: serverstatus.js loaded!
#30: sha1.js loaded!
#31: snipe.js loaded!
#32: start.js loaded!
#33: translate.js loaded!
#34: trivia.js loaded!
#35: warn.js loaded!
#36: webwallet.js loaded!
MongoDB connection error: The uri parameter to openUri() must be a string, got "undefined". Make sure the first parameter to mongoose.connect() or mongoose.createConnection() is a string.
(node:12653) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided.
at Client.login (/root/duino-stats-main/node_modules/discord.js/src/client/Client.js:206:52)
at Object. (/root/duino-stats-main/index.js:19:8)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
at internal/main/run_main_module.js:17:47
(node:12653) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:12653) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
#1: add.js loaded!
#2: balance.js loaded!
#3: ban.js loaded!
#4: bump.js loaded!
#5: clear.js loaded!
#6: coinflip.js loaded!
#7: daily.js loaded!
#8: deposit.js loaded!
#9: eval.js loaded!
#10: exchange.js loaded!
#11: exchangeBalance.js loaded!
#12: exchangeLeaderboard.js loaded!
#13: execute.js loaded!
#14: feed.js loaded!
#15: gamble.js loaded!
#16: help.js loaded!
#17: infractions.js loaded!
#18: kick.js loaded!
#19: leaderboard.js loaded!
#20: pay.js loaded!
#21: price.js loaded!
#22: profile.js loaded!
#23: reload.js loaded!
#24: remove.js loaded!
#25: removeinfraction.js loaded!
#26: restartServer.js.js loaded!
#27: roulette.js loaded!
#28: say.js loaded!
#29: serverstatus.js loaded!
#30: sha1.js loaded!
#31: snipe.js loaded!
#32: start.js loaded!
#33: translate.js loaded!
#34: trivia.js loaded!
#35: warn.js loaded!
#36: webwallet.js loaded!

Ok there must be a problem with your .env file
Are you sure you made a file called ".env"?
Did you put your bot token and the mongo DB connection url in it?
If yes then maybe you need to install dotenv package with npm i dotenv
If you still have troubles with it, you can just replace process.env.token with your token in the code (same for the mongo uri)

It needs to be named ".env"

The bot works! Only one issue, i dont think i setup MongoDB right! I cant get it to auth!

Did you made a cluster? Did you get the connection uri?

Yes. I am using https://cloud.mongodb.com/
I don't know how to setup MongoDB locally

Yes. I am using https://cloud.mongodb.com/
I don't know how to setup MongoDB locally

you dont need to make it locally. Heres a really good guide: https://towardsdatascience.com/creating-a-discord-bot-from-scratch-and-connecting-to-mongodb-828ad1c7c22e
just replace paste the url in the ".env" file.

Yes. I am using https://cloud.mongodb.com/
I don't know how to setup MongoDB locally

you dont need to make it locally. Heres a really good guide: https://towardsdatascience.com/creating-a-discord-bot-from-scratch-and-connecting-to-mongodb-828ad1c7c22e
just replace paste the url in the ".env" file.

I have to pay to read it. What do i do?

Open it in a private window

I found the issue! When I added a new user to MongoDB on https://cloud.mongodb.com/ it started working

Thank you!