Discord bot wont go online - unhandled promise rejection warning error

I installed my bot and got this (i tried run enable-pnpm already, it worked but now i get this):

(node:8801) UnhandledPromiseRejectionWarning: Error: Incorrect login details were provided.

at WebSocketConnection.client.ws.connection.once.event (/rbd/pnpm-volume/f09a781b-a753-45d0-93a3-c49b033e9696/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/ClientManager.js:47:41)

at Object.onceWrapper (events.js:315:30)

at emitOne (events.js:116:13)

at WebSocketConnection.emit (events.js:211:7)

at WebSocketConnection.onClose (/rbd/pnpm-volume/f09a781b-a753-45d0-93a3-c49b033e9696/node_modules/.registry.npmjs.org/discord.js/11.3.2/node_modules/discord.js/src/client/websocket/WebSocketConnection.js:390:10)

at WebSocketClient.internalOnClose (/rbd/pnpm-volume/f09a781b-a753-45d0-93a3-c49b033e9696/node_modules/.registry.npmjs.org/uws/9.148.0/node_modules/uws/uws.js:121:17)

at process.nextTick (/rbd/pnpm-volume/f09a781b-a753-45d0-93a3-c49b033e9696/node_modules/.registry.npmjs.org/uws/9.148.0/node_modules/uws/uws.js:64:19)

at _combinedTickCallback (internal/process/next_tick.js:131:7)

at process._tickCallback (internal/process/next_tick.js:180:9)

(node:8801) 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: 1)

(node:8801) [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.

I have no idea how to start solving any of these… what’s going on? The bot works fine when I host it locally.

Your token is invalid. Go to you discord developer dashboard, click your application, if you haven’t already, press “Create Bot User” or something, then click “Click to reveal token”, and then copy paste your token from the dasboard into Client.login(<token>)

@ihack2712 did answer your question appropriately and correctly (in my vision). I recommend that you (implying @CarlaCardillo) add a .catch statement so that if this happens again it will do what you want (on error) and not crash in the future.

if your project is not private, i highly recommend that is is, unless you are storing your token in the .env file.
if it is stored in the .env file, make sure that .login() looks like: client.login(process.env.<env_variable>).

The problem might be, (And I’ve seen a lot of people mess up on this) that you copied tthe token of your application. Do not copy the token of your Application. Go to Bot and copy THAT token.

If u are using version 12 of discord you should have the env variable as DISCORD_BOT it will work and you need to install dotenv package as dev dependencies

const Discord = require("discord.js");

const client = new Discord.Client();

client.on(“ready”, () => {
console.log(Logged in as ${client.user.tag}!);

client.on(“message”, async (msg) => {
if (msg.content.startsWith(“Hi”)) {
msg.reply(“Hi there”);


an example

Hey there, please don’t bump old questions. Thanks!