Coder
Coder

Reputation: 5

bot is not defined discord bot

I am making a discord bot which will eventually be used as a rating system for the chat, but the index.js terminal says ReferenceError: bot is not defined bot.on('ready',() =>{ I even have const Client = new Discord.Client(); The code is below

const Discord = require('discord.js');
const Client = new Discord.Client();

const token ='xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';

bot.on('ready',() =>{
    console.log('This bot Is Online!');
})

bot.login(token);

Some people have a similar issue but mine seems to persist more hence leaving me clueless to resolve this runtime error

Upvotes: 0

Views: 460

Answers (1)

Sean
Sean

Reputation: 827

bot should be Client. If you want to use the bot variable change const Client = new Discord.Client(); to const bot = new Discord.Client();. This is your client, or the profile/user of the bot.

Its also not a good idea to reveal your bots token (if thats its actual token). Otherwise people can log into your bot with their own script and it will cause problems for whichever server that bot is in (people can kick through the bot etc.)

Upvotes: 1

Related Questions