Выдает такую ошибку
(node:5416) UnhandledPromiseRejectionWarning: Error: ENOENT: no such file or directory, scandir 'C:\Users\777\Desktop\discordbot\command'
(Use `node --trace-warnings ...` to show where the warning was created)
(
node:5416) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see
https://nodejs.org/api/cli.html#cli_unhandled_reje...). (rejection id: 1)
(node:5416) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
app.js
const Discord = require(`discord.js`);
const bot = new Discord.Client();
const fs = require(`promise-fs`);
const config = require (`./config.json`);
bot.commands = new Discord.Collection();
loadCommands().then(count => console.log(`Loaded ${count} commands`));
bot.on(`message`, async (message) => {
let arr = message.content.split(/\s+/g);
let args = arr.slice(1);
let name = arr[0].slice(config.prefix.length);
if(!message.content.startsWith(config.prefix)) return;
if(!message.guild) return;
if(message.author.bot) return;
let cmd = bot.commands.get(name);
if(cmd) cmd.run(bot, message, args);
});
bot.on(`guildMemberAdd`, async member => {
bot.logChannel.send(`О Боже кто же это! ${member}!`);
});
bot.on(`guildMemberRemove`, async member => {
bot.logChannel.send(`${member} Покинул нас`);
});
bot.on(`ready`, async () => {
console.log(`Logged as ${bot.user.tag}`);
bot.logChannel = bot.channels.cache.get(`783928263289339926`);
});
bot.login(config.token);
async function loadCommands() {
let dir = await fs.readdir(`command`);
let filles = dir.filter(name => name.endsWith(`.js`));
files.forEach(file => {
let name = file.split(`.`)[0];
let cmd = require(`./commands/${name}`);
bot.commands.set(name, cmd);
});
return bot.commands.size;
}
Ping.js
module.exports.run = async(bot, message, args) => {
message.reply(`Pong!`);
}