'Discord.js not logging in
I cannot figure out why my bot is not working. Can someone please tell me why it is not logging in?? It shows the logo (the last console.log line), but does not say, "logged in as foo#1234". (I am not getting any errors as well.)
code removed because of answered question. the code worked fine ;)
Solution 1:[1]
Use client.once(‘ready’, async () => {//code here});
as a a pose to client.on()
Solution 2:[2]
As mentioned on discord.js Guide, here's the base code to get you started:
// Require the necessary discord.js classes
const { Client, Intents } = require('discord.js');
const { token } = require('./config.json');
// Create a new client instance
const client = new Client({ intents: [Intents.FLAGS.GUILDS] });
// When the client is ready, run this code (only once)
client.once('ready', () => {
console.log('Ready!');
});
// Login to Discord with your client's token
client.login(token);
Open your terminal and run node index.js
(assuming that your file name is index.js) to start the process. If you see "Ready!" after a few seconds, you're good to go!
I recommend for you to follow this guide, it helped me a lot with the first steps with the discord bot.
Solution 3:[3]
The Token had reset for some reason, I do not remember resetting it, but after updating the token, it worked fine. Thank you for your answers and helpful comments.
If somebody else is having this problem, try resetting the token again.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | WilliamDragon10 |
Solution 2 | p-destri |
Solution 3 |