Как исправить файл fs#writefile?
Эй, так. У меня тут такая проблема:
PS C:\Users\name\Desktop\DiscBot\AAA My Custom Discord Bot> node . Nice. (node:6444) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided. at WebSocketConnection.client.ws.connection.once.event (C:\Users\name\Desktop\DiscBot\AAA My Custom Discord Bot\node_modules\discord.js\src\client\ClientManager.js:48:41) at Object.onceWrapper (events.js:286:20) at WebSocketConnection.emit (events.js:198:13) at WebSocketConnection.onClose (C:\Users\name\Desktop\DiscBot\AAA My Custom Discord Bot\node_modules\discord.js\src\client\websocket\WebSocketConnection.js:390:10) at WebSocket.onClose (C:\Users\name\Desktop\DiscBot\AAA My Custom Discord Bot\node_modules\ws\lib\event-target.js:124:16) at WebSocket.emit (events.js:198:13) at WebSocket.emitClose (C:\Users\name\Desktop\DiscBot\AAA My Custom Discord Bot\node_modules\ws\lib\websocket.js:191:10) at TLSSocket.socketOnClose (C:\Users\name\Desktop\DiscBot\AAA My Custom Discord Bot\node_modules\ws\lib\websocket.js:850:15) at TLSSocket.emit (events.js:203:15) at _handle.close (net.js:606:12) (node:6444) 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(). (rejection id: 2) (node:6444) [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.
Как это исправить? В основном я использовал fs#writeFile для чтения из блокнота содержимого, которое у меня есть, и когда люди делают $number, то он отправляет только 1 строку каждый раз.
Что я уже пробовал:
var fs = require('fs'); const Discord = require('discord.js'); const bot = new Discord.Client(); const token = 'NTk5NTIyMzY4MDQ5NjQzNTUw.XSmgXw.mK2EyTJzGGB1MdT3JCmQkRW6oP4'; const PREFIX = "$"; bot.on('ready', () =>{ console.log('I am online!'); bot.user.setActivity("Test | Prefix: $") }) bot.on('message', message=>{ let args = message.content.substring(PREFIX.length).split(" "); switch(args[0]){ case 'help': message.channel.sendMessage('$cyka | Gives back a good word.'); message.channel.sendMessage('$rules | TrustedBusiness Rules.'); message.channel.sendMessage('$ping | Gives back the word [pong].'); break; case 'cyka': message.channel.sendMessage('blyat!'); break; case 'rules': message.channel.sendMessage('Check here and follow them please! #rules'); break; case 'ping': message.channel.sendMessage('pong! POOOOONG!!'); break; case 'clear': if(!args[1]) return message.reply('Sorry. Define also a number after (clear) command!') message.channel.bulkDelete(args[1]); break; } }) bot.login(token) var read_string = fs.readFile('number.txt', 'utf8', function (err, data) { if (err) return console.error(err); console.log('Nice.') })