Working on creating just a simplistic working Discord bot.
It is within Discord currently but upon running with node index.js
I get the following error:
C:\Users\terra\Desktop\SleepyBot>node index.js
{
error: Error: ENOENT: no such file or directory, open 'C:\Users\terra\Desktop\SleepyBot\.env'
at Object.openSync (fs.js:474:3)
at Object.readFileSync (fs.js:375:35)
at Object.config (C:\Users\terra\Desktop\SleepyBot\node_modules\dotenv\lib\main.js:96:29)
at Object.<anonymous> (C:\Users\terra\Desktop\SleepyBot\index.js:1:31)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
errno: -4058,
syscall: 'open',
code: 'ENOENT',
path: 'C:\\Users\\terra\\Desktop\\SleepyBot\\.env'
}
}
Index.js
const Discord = require('discord.js');
const bot = new Discord.Client();
const TOKEN = dotenv.env.TOKEN;
bot.login(TOKEN);
bot.on('ready', () => {
console.info(`Logged in as ${bot.user.tag}!`);
});
bot.on('message', msg => {
if (msg.content === 'ping') {
msg.reply('pong');
msg.channel.send('pong');
} else if (msg.content.startsWith('!kick')) {
if (msg.mentions.users.size) {
const taggedUser = msg.mentions.users.first();
msg.channel.send(`You wanted to kick: ${taggedUser.username}`);
} else {
msg.reply('Please tag a valid user!');
}
}
});
Pictures for Reference:
Any and all advice is greatly appreciated! I'm new to javascript, but familiar with Java and C++.