moonstar-x / discord-tts-bot

A Text-to-Speech bot for Discord.
https://docs.moonstar-x.dev/discord-tts-bot
MIT License
98 stars 84 forks source link

Cannot run the Bot #17

Closed PhiJoTo closed 4 years ago

PhiJoTo commented 4 years ago

Whenever I try to start the Bot, the following error message appears: `> discord-tts-bot@1.1.0 start /home/ubuntu/TTSBot/discord-tts-bot

node ./src/app.js

internal/modules/cjs/loader.js:638 throw err; ^

Error: Cannot find module '@discordjs/form-data' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/ubuntu/TTSBot/discord-tts-bot/node_modules/discord.js/src/rest/APIRequest.js:4:18) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! discord-tts-bot@1.1.0 start: node ./src/app.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the discord-tts-bot@1.1.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/ubuntu/.npm/_logs/2020-06-07T17_40_59_743Z-debug.log ubuntu@ubuntu:~/TTSBot/discord-tts-bot/config$ npm start

discord-tts-bot@1.1.0 start /home/ubuntu/TTSBot/discord-tts-bot node ./src/app.js

internal/modules/cjs/loader.js:638 throw err; ^

Error: Cannot find module '@discordjs/form-data' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/ubuntu/TTSBot/discord-tts-bot/node_modules/discord.js/src/rest/APIRequest.js:4:18) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! discord-tts-bot@1.1.0 start: node ./src/app.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the discord-tts-bot@1.1.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/ubuntu/.npm/_logs/2020-06-07T17_44_34_382Z-debug.log `

PhiJoTo commented 4 years ago

1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using npm@6.14.4 3 info using node@v10.19.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle discord-tts-bot@1.1.0~prestart: discord-tts-bot@1.1.0 6 info lifecycle discord-tts-bot@1.1.0~start: discord-tts-bot@1.1.0 7 verbose lifecycle discord-tts-bot@1.1.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle discord-tts-bot@1.1.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ubuntu/TTSBot/discord-tts-bot/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/> 9 verbose lifecycle discord-tts-bot@1.1.0~start: CWD: /home/ubuntu/TTSBot/discord-tts-bot 10 silly lifecycle discord-tts-bot@1.1.0~start: Args: [ '-c', 'node ./src/app.js' ] 11 silly lifecycle discord-tts-bot@1.1.0~start: Returned: code: 1 signal: null 12 info lifecycle discord-tts-bot@1.1.0~start: Failed to exec start script 13 verbose stack Error: discord-tts-bot@1.1.0 start:node ./src/app.js 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:198:13) 13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:198:13) 13 verbose stack at maybeClose (internal/child_process.js:982:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 14 verbose pkgid discord-tts-bot@1.1.0 15 verbose cwd /home/ubuntu/TTSBot/discord-tts-bot/config 16 verbose Linux 5.4.0-1011-raspi 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" 18 verbose node v10.19.0 19 verbose npm v6.14.4 20 error code ELIFECYCLE 21 error errno 1 22 error discord-tts-bot@1.1.0 start:node ./src/app.js` 22 error Exit status 1 23 error Failed at the discord-tts-bot@1.1.0 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

`

moonstar-x commented 4 years ago

Hey there, this may sound like a dumb question but did you run npm install or yarn install before trying to start the bot?

PhiJoTo commented 4 years ago

I installed npm but I didn't install yarn, sorry.. I will try it, I'm kinda new to Linux..

PhiJoTo commented 4 years ago

It still isn't working.. 0 info it worked if it ends with ok 1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'start' ] 2 info using npm@6.14.4 3 info using node@v10.19.0 4 verbose run-script [ 'prestart', 'start', 'poststart' ] 5 info lifecycle discord-tts-bot@1.1.0~prestart: discord-tts-bot@1.1.0 6 info lifecycle discord-tts-bot@1.1.0~start: discord-tts-bot@1.1.0 7 verbose lifecycle discord-tts-bot@1.1.0~start: unsafe-perm in lifecycle true 8 verbose lifecycle discord-tts-bot@1.1.0~start: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ubuntu/TTSBot/discord-tts-bot/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/> 9 verbose lifecycle discord-tts-bot@1.1.0~start: CWD: /home/ubuntu/TTSBot/discord-tts-bot 10 silly lifecycle discord-tts-bot@1.1.0~start: Args: [ '-c', 'node ./src/app.js' ] 11 silly lifecycle discord-tts-bot@1.1.0~start: Returned: code: 1 signal: null 12 info lifecycle discord-tts-bot@1.1.0~start: Failed to exec start script 13 verbose stack Error: discord-tts-bot@1.1.0 start:node ./src/app.js 13 verbose stack Exit status 1 13 verbose stack at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16) 13 verbose stack at EventEmitter.emit (events.js:198:13) 13 verbose stack at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) 13 verbose stack at ChildProcess.emit (events.js:198:13) 13 verbose stack at maybeClose (internal/child_process.js:982:16) 13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5) 14 verbose pkgid discord-tts-bot@1.1.0 15 verbose cwd /home/ubuntu/TTSBot/discord-tts-bot 16 verbose Linux 5.4.0-1011-raspi 17 verbose argv "/usr/bin/node" "/usr/bin/npm" "start" 18 verbose node v10.19.0 19 verbose npm v6.14.4 20 error code ELIFECYCLE 21 error errno 1 22 error discord-tts-bot@1.1.0 start:node ./src/app.js` 22 error Exit status 1 23 error Failed at the discord-tts-bot@1.1.0 start script. 23 error This is probably not a problem with npm. There is likely additional logging output above. 24 verbose exit [ 1, true ]

`

moonstar-x commented 4 years ago

Oh no, you may have misunderstood me, you don't need yarn. What I meant is that you should run npm install before npm start in the same folder where the bot is located.

PhiJoTo commented 4 years ago

I did both now but without success...

moonstar-x commented 4 years ago

Do you get any error messages after running npm install?

PhiJoTo commented 4 years ago

nope.. it says "audited 41 packages in 1.928s found 0 vulnerabilities"

moonstar-x commented 4 years ago

I see, I tried installing the bot in my computer and I got the same error. It seems that discord.js changed the way to install the version 12 of their library, which the bot currently uses. I could do the fix later today but if you feel in a bit of a rush, you can do the following:

  1. Open the package.json file and remove the line that says: "discord.js": "github:discordjs/discord.js",.
  2. In your terminal, in the same directory as the file package.json, run the following commands:
    rm -rf node-modules/
    npm install
    npm install discord.js

Finally, it should work. But like I said, I will make this change later tonight, so that the rest aren't forced to go through this. Please do tell me if after doing this the bot is running fine so I can close this issue.

Thanks for your report!

PhiJoTo commented 4 years ago

On the last command I get following error: `ubuntu@ubuntu:~/TTSBot/discord-tts-bot$ npm install discord.js npm WARN notsup Unsupported engine for discord.js@12.2.0: wanted: {"node":">=12.0.0"} (current: {"node":"10.19.0","npm":"6.14.4"}) npm WARN notsup Not compatible with your version of node/npm: discord.js@12.2.0

`

moonstar-x commented 4 years ago

As of right now, discord.js only supports node version 12 or higher and your current node version is 10 so you need to update it.

PhiJoTo commented 4 years ago

I really don't want to bother you but even after installing version 14 it isn't working.

PhiJoTo commented 4 years ago

Error: Cannot find module '../config/settings.json' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:692:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (/home/ubuntu/TTSBot/discord-tts-bot/src/app.js:4:51) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! discord-tts-bot@1.1.0 start: node ./src/app.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the discord-tts-bot@1.1.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/ubuntu/.npm/_logs/2020-06-07T18_42_03_583Z-debug.log

moonstar-x commented 4 years ago

I really don't want to bother you but even after installing version 14 it isn't working.

Don't worry man you're not bothering me, you're rather helping me improve this bot, which I'm grateful for.

As for the error you just posted right now, that shows that it's working but that you haven't followed the installation notes.

PhiJoTo commented 4 years ago

I am really sorry.. I forget renaming the config file.. But the error is still the same..

moonstar-x commented 4 years ago

If you're getting the same error as the one your previously mentioned then it means that the filename is still incorrect or that the file is in the wrong folder.

PhiJoTo commented 4 years ago

Anmerkung 2020-06-07 205725 Anmerkung 2020-06-07 205751

moonstar-x commented 4 years ago

And you're still getting the module not found settings.json error when doing npm start?

PhiJoTo commented 4 years ago

Yes.. Anmerkung 2020-06-07 210216

moonstar-x commented 4 years ago

I see, the error is not the same but it still related to the update that there was with discord.js. I'm gonna work on it tonight, in tue meantime I invite you to use the version of the bot that I'm hosting until I fix it so that you can use your own self-hosted version.

Thanks for your report and I'm sorry for all the inconveniences this may have caused you.

PhiJoTo commented 4 years ago

Okay, really thank you.. I am gonna wait till tonight..

moonstar-x commented 4 years ago

Hey there, I updated the code to work with the newest stable version of discord.js. I tested it on my local machine and it works with node versions 12.0.0 and 14.4.0.

Moreover, the last error that you were getting was due because you were running a node version older than the 12.0.0. Maybe you needed to restart your ssh connection?

In any case, if you update your bot by redownloading the zip with the code or by running git pull origin master, you should have the new changes. Make sure you remove again the node-modules folder and re-run npm install and npm run with the proper node version.

PhiJoTo commented 4 years ago

I completely reinstalled everything and this is the error I'm still getting. `

discord-tts-bot@1.2.0 start /home/ubuntu/discord-tts-bot node ./src/app.js

/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:443 .flat(2) ^

TypeError: fields.flat is not a function at Function.normalizeFields (/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:443:8) at MessageEmbed.addFields (/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:259:42) at MessageEmbed.addField (/home/ubuntu/discord-tts-bot/node_modules/discord.js/src/structures/MessageEmbed.js:250:17) at Object. (/home/ubuntu/discord-tts-bot/src/common/langsEmbed.js:13:4) at Module._compile (internal/modules/cjs/loader.js:778:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:692:17) npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! discord-tts-bot@1.2.0 start: node ./src/app.js npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the discord-tts-bot@1.2.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/ubuntu/.npm/_logs/2020-06-07T23_55_53_767Z-debug.log `

If it has to do with node, how do I switch versions?

moonstar-x commented 4 years ago

That error is due to the outdated node version. If you run node -v what do you get?

PhiJoTo commented 4 years ago

v10.19.0

PhiJoTo commented 4 years ago

I figured it out.. Again, thanks for helping :)

PhiJoTo commented 4 years ago

One last question: How can I run the Bot, so that he stays online when I close putty?

PhiJoTo commented 4 years ago

I solved this using forever.. The Bot is in my channel now but it isn't saying anything.. https://discord.gg/vSUKgWr - This is my discord server. The prefix is "!"..

moonstar-x commented 4 years ago

I solved this using forever.. The Bot is in my channel now but it isn't saying anything..

https://discord.gg/vSUKgWr - This is my discord server. The prefix is "!"..

Check the console output of your bot, maybe there's a clue there as to what's going on. Some things you should look out for:

  1. Does the bot have permissions to talk on your voice channel?
  2. Do you have ffmpeg installed on the computer running the bot?

But again, it's hard for me to help you right now without any console messages.

PhiJoTo commented 4 years ago

`(3:31:15 PM) - [ERROR] - Error: Error: Cannot find module '/home/ubuntu/discord- tts-bot/node_modules/@discordjs/opus/prebuild/node-v83-napi-v3-linux-arm64-glibc -2.31/opus.node' Require stack:

moonstar-x commented 4 years ago

Hmm this is kinda weird. I tested the changes on two different machines with multiple node versions (macOS and Ubuntu Server) and they both work. Your error is displaying that node-opus cannot be found which is required to use voice channels for the bot. My bet would be that your machine may have had some issues compiling the opus bindings when doing npm install?

Maybe your computer doesn't have a C compiler installed?

Try running sudo apt-get install build-essential and then try removing node-modules and re running npm install.

PhiJoTo commented 4 years ago

Finally, it works. Thanks for the massive help, I wouldn't have figured it out by myself by any chance :)

moonstar-x commented 4 years ago

I'm glad it works now for you, you've been an immense help to realize that there were some changes that needed to be implemented since the latest discord-js update which I was unaware of.

I'll go ahead and close this issue, if anything else comes up, feel free to open a new one and I'll do my best to assist you!