Я работал над моим Discord Bot Rxiqi
, и я хотел получить команды автоматической перезагрузки, когда файл изменился ... мой код
var folder = "./commands/";
fs.watch(folder, { encoding: 'UTF-8' }, (eventType, filename) => {
if (eventType ==="change") {
console.log(`Updating Command: ${folder+filename}`)
delete require.cache[require.resolve(folder+filename)];
client.commands.delete(folder+filename);
const props = require(filename);
client.commands.set(folder+filename,props);
}
});
Но я продолжаю получать этот вывод консоли:
Updating Command: ./commands/adverts.js
Error: Cannot find module './commands/adverts.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.resolve (internal/module.js:18:19)
at FSWatcher.fs.watch (E:\BotDevelopment\Rxiqi\status\ready.js:62:38)
at emitTwo (events.js:126:13)
at FSWatcher.emit (events.js:214:7)
at FSEvent.FSWatcher._handle.onchange (fs.js:1364:12)
Updating Command: ./commands/adverts.js
Error: Cannot find module './commands/adverts.js'
at Function.Module._resolveFilename (module.js:547:15)
at Function.resolve (internal/module.js:18:19)
at FSWatcher.fs.watch (E:\BotDevelopment\Rxiqi\status\ready.js:62:38)
at emitTwo (events.js:126:13)
at FSWatcher.emit (events.js:214:7)
at FSEvent.FSWatcher._handle.onchange (fs.js:1364:12)
Любая помощь очень ценится:)