Discord Music Bot Help

Reposting since last time I had my token in the config.json file.

I’m getting errors that I don’t have any idea how to fix.

Please post the errors you are receiving in this thread so we can help :slight_smile:

1 Like

Try putting the token in the .env file for security. And also show your errors!

2 Likes

Here:

internal/modules/cjs/loader.js:584 throw err; ^ Error: Cannot find module './env' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:582:15) at Function.Module._load (internal/modules/cjs/loader.js:508:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:22:18) at Object.<anonymous> (/app/index.js:26:27) at Module._compile (internal/modules/cjs/loader.js:701:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:712:10) at Module.load (internal/modules/cjs/loader.js:600:32) at tryModuleLoad (internal/modules/cjs/loader.js:539:12) at Function.Module._load (internal/modules/cjs/loader.js:531:3)

Did you use .env


1 Like

yessir

20chars20chars

To use a variable inside of the .env file use this:

process.env.variablename

what-

im confused

20chars

^^^ This is your error and I assume you are trying to use a variable in the .env file and it is causing this error. To use a variable do it with this:

process.env.variablename

with ‘variablename’ being the name of the variable that you chose in the .env file.

1 Like

I’ll try that.

Thanks!

1 Like

For this line,

const { prefix, token } = require(process.env.TOKEN);
what do I put?

You can put that at the top of your file and then log in to Discord at the bottom using the variable ‘token’ :slight_smile:

still confused

20chars

const Discord = require("discord.js");
const bot = new Discord.Client();
const token = process.env.TOKEN;
const prefix = process.env.PREFIX;
bot.login(token);
2 Likes

Thanks!

No errors in tools, now I just need to test it on discord!

3 Likes

@okboomer1234321 Did it work?

New errors @EddiesTech,

at WebSocketManager.connect (/rbd/pnpm-volume/fbe60cb1-4b8d-42f7-b863-8fc4097e94f6/node_modules/.github.com/discordjs/discord.js/c4c6ad4a63fcbc46fdf4e6f1ea01472e67c31839/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:26) at CommandoClient.login (/rbd/pnpm-volume/fbe60cb1-4b8d-42f7-b863-8fc4097e94f6/node_modules/.github.com/discordjs/discord.js/c4c6ad4a63fcbc46fdf4e6f1ea01472e67c31839/node_modules/discord.js/src/client/Client.js:212:21) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:757:11) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) (node:113) 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(). (rejection id: 1) (node:113) [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. (node:113) UnhandledPromiseRejectionWarning: Error [TOKEN_INVALID]: An invalid token was provided. at WebSocketManager.connect (/rbd/pnpm-volume/fbe60cb1-4b8d-42f7-b863-8fc4097e94f6/node_modules/.github.com/discordjs/discord.js/c4c6ad4a63fcbc46fdf4e6f1ea01472e67c31839/node_modules/discord.js/src/client/websocket/WebSocketManager.js:133:26) at Client.login (/rbd/pnpm-volume/fbe60cb1-4b8d-42f7-b863-8fc4097e94f6/node_modules/.github.com/discordjs/discord.js/c4c6ad4a63fcbc46fdf4e6f1ea01472e67c31839/node_modules/discord.js/src/client/Client.js:212:21) at process._tickCallback (internal/process/next_tick.js:68:7) at Function.Module.runMain (internal/modules/cjs/loader.js:757:11) at startup (internal/bootstrap/node.js:283:19) at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3) (node:113) 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(). (rejection id: 2)

anyone?

sorry for being impatient

EDIT: I am getting no new errors but the bot doesn’t respond now.

Have you provided the correct token in the .env

Yes, I’ll add it again though.

After you edit it, does it show as online on Discord? (Green dot next to profile)

It was the incorrect token, tysm!

1 Like

Yes it does.

20chars

1 Like

Brilliant! Glad I could help! :slight_smile:

1 Like

new errors cries

Could not extract html5player key: https://www.youtube.com/s/player/39dd62a0/player_ias.vflset/en_US/base.js

2:42 PM

url.js:154

2:42 PM

throw new ERR_INVALID_ARG_TYPE(‘url’, ‘string’, url);

2:42 PM

^

2:42 PM

2:42 PM

TypeError [ERR_INVALID_ARG_TYPE]: The “url” argument must be of type string. Received type undefined

2:42 PM

at Url.parse (url.js:154:11)

2:42 PM

at Object.urlParse [as parse] (url.js:148:13)

2:42 PM

at doDownload (/rbd/pnpm-volume/fbe60cb1-4b8d-42f7-b863-8fc4097e94f6/node_modules/.registry.npmjs.org/miniget/1.6.1/node_modules/miniget/dist/index.js:90:28)

2:42 PM

at process._tickCallback (internal/process/next_tick.js:61:11)

2:42 PM