Reputation: 3
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>");
Upvotes: 0
Views: 8731
Reputation: 1
That's right:
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>");
Upvotes: -1
Reputation: 1
Wrap module name using quotations "
or '
.
Use the command below :
const Discord = require('discord.js');
Upvotes: 0
Reputation: 24
You forgot the " or ' in:
const Discord = require(discord.js)
so try :
const Discord = require("discord.js");
Upvotes: 1
Reputation: 128
When defining something in const syntax, you must always use " or '.
Upvotes: 2
Reputation: 5174
When importing/requiring anything you have to pass it as a string. You essentially tried to pass it as a variable.
const Discord = require('discord.js')
Upvotes: 0