Search code examples
node.jssyntax-errordiscorddiscord.js

Error "const Discord = require(discord.js) ^ ReferenceError: discord is not defined"


Hi there so i have a weird error that i get that says this "const Discord = require(discord.js) ^ ReferenceError: discord is not defined" here is the code i have written is there a error that i put in there?

const Discord = require(discord.js)
const Client = new Discord.Client
const prefix = "/";
Client.on('ready', ()=>{
    console.log('Bot is online.');
})
Client.on('message', (Message)=>{
    if(!Message.content.startsWith(prefix)) return;
    if(Message.content.startsWith(prefix + "hello")){
        Message.channel.send("Hello.")
    }
})
Client.login("<Token Here>");

Solution

  • You forgot the " or ' in:

    const Discord = require(discord.js)
    

    so try :

    const Discord = require("discord.js");