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.
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
Try putting the token in the .env file for security. And also show your errors!
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
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.
I’ll try that.
Thanks!
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’
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);
Thanks!
No errors in tools, now I just need to test it on discord!
@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