The bot doesn’t go online.

hi, what should i do if my bot doesn't go online? (the console returns no errors when I type “node index.js” or “node .” to run the bot) my npm -v version is the latest (20) but i have also tried with the 18.
14 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
Squid
Squid2y ago
Are you calling client.login(...) in index.js?
galtic
galticOP2y ago
yes
Squid
Squid2y ago
Can you show your index.js?
galtic
galticOP2y ago
const { Client, Events, GatewayIntentBits } = require('discord.js'); const { token } = require('./config.json'); const client = new Client({ intents: [GatewayIntentBits.Guilds] }); client.once(Events.ClientReady, c => { console.log(Ready! Logged in as ${c.user.tag}); }); client.login(token); and in the config.json file i have { “token” : “my token” }
Squid
Squid2y ago
What host are you using for your bot?
galtic
galticOP2y ago
no one at the moment. just visual studio code on my computer
Squid
Squid2y ago
So whenever you type node . in your console, does it start a new line like PS C:/.../ >, or is the last line the same as where you typed node .?
galtic
galticOP2y ago
it start a new line
Squid
Squid2y ago
Are you sure that index.js is in your working directory (the same as what your "cursor" in your console says)?
galtic
galticOP2y ago
yes
d.js docs
d.js docs2y ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
• Note: if you initialize your Client as bot or other identifiers you need to use these instead of client • If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
Squid
Squid2y ago
Adding these should ensure that you get something logged
galtic
galticOP2y ago
thanks, now it works it was the first time i had this problem, i was practicable with discord.js 12.
Want results from more Discord servers?
Add your server