Skip to content
← Back to Community
Problem getting a JSON file. (Discord bot)
Profile icon
S1ant

Hello, So I'm trying to make a discord bot using Repl.it, and I've run into this error when I try to access my botconfig.json file, here is my code and the error:
CODE:
const Discord = require("discord.js");
const client = new Discord.Client();
const botconfig = require('./botconfig.json');

client.on("ready", () => {
System.out.log("Bot is Ready");
});

client.login(botconfig.token);

ERROR:
Error: Cannot find module './botconfig.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:548:15)
at Function.Module._load (internal/modules/cjs/loader.js:475:25)
at Module.require (internal/modules/cjs/loader.js:598:17)
at require (internal/modules/cjs/helpers.js:11:18)
at evalmachine.:3:19
at Script.runInContext (vm.js:74:29)
at Object.runInContext (vm.js:182:6)
at evaluate (/run_dir/repl.js:133:14)
at ReadStream. (/run_dir/repl.js:116:5)
at ReadStream.emit (events.js:180:13)

Voters
Profile icon
VarunKrishnan
Profile icon
S1ant
Comments
hotnewtop
Profile icon
HACKERZ1290

how did u fixed it

Profile icon
Vandesm14

It works for me:
This file cannot be displayed: https://storage.googleapis.com/replit/images/1544821163426_abb1016ba206b1d39c1c3feac520b814.pn

Profile icon
S1ant

@Vandesm14 Yeah, I forgot I switched the code, sorry. I'm fine now, I just won't use multiple files with repl.it !

Profile icon
leonelbravo059

Hi! i solved that using
const botconfig = require("/home/runner/proyectnamed22/config.json");