Hello! Recently, I started to create my own discord bot. I’ve learned the basics of commands and others, but when I want to start the bot, I am getting an error. Do you have any solution how can I solve the problem?
The following lines are the codes inserted:
Package.json
{
“name”: “discord-bot”,
“version”: “1.0.0”,
“description”: “First Discord Bot Try”,
“main”: “index.js”,
“scripts”: {
"test": "echo \"Error: no test specified\" && exit 1"
},
“author”: “Rares.OfficialBDT”,
“license”: “ISC”,
“dependencies”: {
"discord.js": "^11.5.1"
}
}
index.js
const Discord = require(‘discord.js’);
const BOT = new Discord.Client();
const token = ‘Hidden’;
bot.on(‘ready’, () =>{
console.log (‘The bot is ready!’);
})
When I am opening the console (ALT+`) and type “node .” I get this error:
ReferenceError: bot is not defined
at Object. (C:\Users\mihai\Desktop\Discord Bot\index.js:7:1)
at Module._compile (internal/modules/cjs/loader.js:1157:30)
at Object.Module._extensions…js (internal/modules/cjs/loader.js:1177:10)
at Module.load (internal/modules/cjs/loader.js:1001:32)
at Function.Module._load (internal/modules/cjs/loader.js:900:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
And if I type node run index.js I get this error:
Error: Cannot find module ‘C:\Users\mihai\Desktop\Discord Bot\run’
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:981:15)
at Function.Module._load (internal/modules/cjs/loader.js:863:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47 {
code: ‘MODULE_NOT_FOUND’,
requireStack:
Variable names are case sensitive. Your bot variable is named “BOT”, not “bot”.
You can either make it lowercase, or make every other refernce “BOT.{etc}” instead of “bot.{etc}”.
I’d recommend not sharing your private token on any public forum as any malicious person can hijack your bot for their own use. You should generate a new one as soon as you can.
Please do not be asking people for there tokens for there bot, if someone stupid takes it, god knows what happens.
@RaresMihai74 Please make sure you do not give out your token, if someone gets your bot token, they could do a raid on every server your bot is in, which could get your discord account banned.