Click here to Skip to main content
15,890,123 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hey so. I have this problem here:

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.


How to fix it? Basically I used fs#writeFile to read from a notepad the content I have in it and when people do $number then it sends only 1 line each time.

What I have tried:

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.')
})
Posted
Updated 8-Aug-19 4:18am

1 solution

Quote:
Incorrect login details were provided.
That's the relevant part of your error message. The token you have provided is not valid.

And that's probably a good thing, given that you've just posted it to a public forum!
A token is essentially your bot's password; it's what your bot uses to login to Discord. With that being said, it is vital that you do not ever share this token with anybody, purposely or accidentally. If someone does manage to get a hold of your token, they can use your bot as if it were theirs—this means they can perform malicious acts with it.
 
Share this answer
 
Comments
IDKaName 8-Aug-19 17:23pm    
yes i know but can you help me out by fs#writeFile instead of token? the thing is another
Richard Deeming 9-Aug-19 7:19am    
That makes no sense. There is no writeFile in your code.

To use the API, you need a valid token. If you don't want to use the API, then the code and error in your question are completely irrelevant, and you haven't provided any information about what you're trying to do.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900