galnir / Master-Bot

A Discord music bot and dashboard with slash commands, playlist support, Spotify, music quiz, saved playlists, lyrics, gifs and more
MIT License
465 stars 372 forks source link

Adding a Prefix to Bot #607

Closed JackW25 closed 3 years ago

JackW25 commented 3 years ago

I would like to also add a prefix to the bot, I don't mind if that means I have to do some extra work, or if it means disabling slash commands. I tried sticking with v12 to keep prefix but ran into issues with hosting it on Heroku (Got a Error: Cannot find module './config.json error)

If anybody has any idea on how to do this, or how to fix that error on v12, that would be amazing!

galnir commented 3 years ago

The old v12 branch should work for you. Can you paste the full error?

JackW25 commented 3 years ago

Sure thing, error I got was:

2021-09-02T03:40:47.127186+00:00 heroku[worker.1]: Starting process with command node index.js 2021-09-02T03:40:47.818131+00:00 heroku[worker.1]: State changed from starting to up 2021-09-02T03:40:49.322447+00:00 app[worker.1]: internal/modules/cjs/loader.js:892 2021-09-02T03:40:49.322460+00:00 app[worker.1]: throw err; 2021-09-02T03:40:49.322461+00:00 app[worker.1]: ^ 2021-09-02T03:40:49.322461+00:00 app[worker.1]: 2021-09-02T03:40:49.322461+00:00 app[worker.1]: Error: Cannot find module '../../config.json' 2021-09-02T03:40:49.322462+00:00 app[worker.1]: Require stack: 2021-09-02T03:40:49.322462+00:00 app[worker.1]: - /app/commands/gifs/animegif.js 2021-09-02T03:40:49.322463+00:00 app[worker.1]: - /app/node_modules/require-all/index.js 2021-09-02T03:40:49.322463+00:00 app[worker.1]: - /app/node_modules/discord.js-commando/src/registry.js 2021-09-02T03:40:49.322463+00:00 app[worker.1]: - /app/node_modules/discord.js-commando/src/client.js 2021-09-02T03:40:49.322464+00:00 app[worker.1]: - /app/node_modules/discord.js-commando/src/index.js 2021-09-02T03:40:49.322464+00:00 app[worker.1]: - /app/index.js 2021-09-02T03:40:49.322464+00:00 app[worker.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:745:27) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:961:19) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:92:18) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at Object. (/app/commands/gifs/animegif.js:2:22) 2021-09-02T03:40:49.322466+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14) 2021-09-02T03:40:49.322466+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) 2021-09-02T03:40:49.322466+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:937:32) 2021-09-02T03:40:49.322467+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12) 2021-09-02T03:40:49.322467+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:961:19) { 2021-09-02T03:40:49.322467+00:00 app[worker.1]: code: 'MODULE_NOT_FOUND', 2021-09-02T03:40:49.322467+00:00 app[worker.1]: requireStack: [ 2021-09-02T03:40:49.322468+00:00 app[worker.1]: '/app/commands/gifs/animegif.js', 2021-09-02T03:40:49.322468+00:00 app[worker.1]: '/app/node_modules/require-all/index.js', 2021-09-02T03:40:49.322468+00:00 app[worker.1]: '/app/node_modules/discord.js-commando/src/registry.js', 2021-09-02T03:40:49.322469+00:00 app[worker.1]: '/app/node_modules/discord.js-commando/src/client.js', 2021-09-02T03:40:49.322469+00:00 app[worker.1]: '/app/node_modules/discord.js-commando/src/index.js', 2021-09-02T03:40:49.322469+00:00 app[worker.1]: '/app/index.js' 2021-09-02T03:40:49.322469+00:00 app[worker.1]: ] 2021-09-02T03:40:49.322470+00:00 app[worker.1]: } 2021-09-02T03:40:49.388761+00:00 heroku[worker.1]: Process exited with status 1 2021-09-02T03:40:49.772365+00:00 heroku[worker.1]: State changed from up to crashed

Hosting locally is fine, this error is only on Heroku

galnir commented 3 years ago

Sure thing, error I got was:

2021-09-02T03:40:47.127186+00:00 heroku[worker.1]: Starting process with command node index.js 2021-09-02T03:40:47.818131+00:00 heroku[worker.1]: State changed from starting to up 2021-09-02T03:40:49.322447+00:00 app[worker.1]: internal/modules/cjs/loader.js:892 2021-09-02T03:40:49.322460+00:00 app[worker.1]: throw err; 2021-09-02T03:40:49.322461+00:00 app[worker.1]: ^ 2021-09-02T03:40:49.322461+00:00 app[worker.1]: 2021-09-02T03:40:49.322461+00:00 app[worker.1]: Error: Cannot find module '../../config.json' 2021-09-02T03:40:49.322462+00:00 app[worker.1]: Require stack: 2021-09-02T03:40:49.322462+00:00 app[worker.1]: - /app/commands/gifs/animegif.js 2021-09-02T03:40:49.322463+00:00 app[worker.1]: - /app/node_modules/require-all/index.js 2021-09-02T03:40:49.322463+00:00 app[worker.1]: - /app/node_modules/discord.js-commando/src/registry.js 2021-09-02T03:40:49.322463+00:00 app[worker.1]: - /app/node_modules/discord.js-commando/src/client.js 2021-09-02T03:40:49.322464+00:00 app[worker.1]: - /app/node_modules/discord.js-commando/src/index.js 2021-09-02T03:40:49.322464+00:00 app[worker.1]: - /app/index.js 2021-09-02T03:40:49.322464+00:00 app[worker.1]: at Function.Module._resolveFilename (internal/modules/cjs/loader.js:889:15) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:745:27) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:961:19) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at require (internal/modules/cjs/helpers.js:92:18) 2021-09-02T03:40:49.322465+00:00 app[worker.1]: at Object. (/app/commands/gifs/animegif.js:2:22) 2021-09-02T03:40:49.322466+00:00 app[worker.1]: at Module._compile (internal/modules/cjs/loader.js:1072:14) 2021-09-02T03:40:49.322466+00:00 app[worker.1]: at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10) 2021-09-02T03:40:49.322466+00:00 app[worker.1]: at Module.load (internal/modules/cjs/loader.js:937:32) 2021-09-02T03:40:49.322467+00:00 app[worker.1]: at Function.Module._load (internal/modules/cjs/loader.js:778:12) 2021-09-02T03:40:49.322467+00:00 app[worker.1]: at Module.require (internal/modules/cjs/loader.js:961:19) { 2021-09-02T03:40:49.322467+00:00 app[worker.1]: code: 'MODULE_NOT_FOUND', 2021-09-02T03:40:49.322467+00:00 app[worker.1]: requireStack: [ 2021-09-02T03:40:49.322468+00:00 app[worker.1]: '/app/commands/gifs/animegif.js', 2021-09-02T03:40:49.322468+00:00 app[worker.1]: '/app/node_modules/require-all/index.js', 2021-09-02T03:40:49.322468+00:00 app[worker.1]: '/app/node_modules/discord.js-commando/src/registry.js', 2021-09-02T03:40:49.322469+00:00 app[worker.1]: '/app/node_modules/discord.js-commando/src/client.js', 2021-09-02T03:40:49.322469+00:00 app[worker.1]: '/app/node_modules/discord.js-commando/src/index.js', 2021-09-02T03:40:49.322469+00:00 app[worker.1]: '/app/index.js' 2021-09-02T03:40:49.322469+00:00 app[worker.1]: ] 2021-09-02T03:40:49.322470+00:00 app[worker.1]: } 2021-09-02T03:40:49.388761+00:00 heroku[worker.1]: Process exited with status 1 2021-09-02T03:40:49.772365+00:00 heroku[worker.1]: State changed from up to crashed

Hosting locally is fine, this error is only on Heroku

The error is thrown because the bot doesn't find the config.json file. You have to make sure the file is in the root directory of the project (the same one where index.js is)

JackW25 commented 3 years ago

The config.json is in the root directory. That's odd why it's giving the error. I've reinstalled all the files and done it again just in case, will let you know how that goes.

JackW25 commented 3 years ago

Another update, redoing did not work, but it started to work once I removed config.json from the .gitignore file. Thanks for all the help though, really is an awesome bot!