luke
13
Error:
PS C:\Users\crazy\OneDrive\Desktop\mystical-bot-real> node .
C:\Users\crazy\OneDrive\Desktop\mystical-bot-real\index.js:5
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })
^
ReferenceError: Discord is not defined
at Object.<anonymous> (C:\Users\crazy\OneDrive\Desktop\mystical-bot-real\index.js:5:16)
at Module._compile (node:internal/modules/cjs/loader:1099:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47
Node.js v17.7.1
PS C:\Users\crazy\OneDrive\Desktop\mystical-bot-real>
Code:
const fs = require('fs');
const { Client, Collection, Intents } = require('discord.js');
const { token } = require('./config.json');
const client = new Client({ intents: ["GUILDS", "GUILD_MESSAGES"] })
client.commands = new Collection();
const commandFiles = fs.readdirSync('./commands').filter(file => file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.data.name, command);
}
const eventFiles = fs.readdirSync('./events').filter(file => file.endsWith('.js'));
for (const file of eventFiles) {
const event = require(`./events/${file}`);
if (event.once) {
client.once(event.name, (...args) => event.execute(...args));
} else {
client.on(event.name, (...args) => event.execute(...args));
}
}
client.login(token);