#Thread
1 messages · Page 1 of 1 (latest)
the bot is logged in
Have you tried to do a dummy file with the bare min of code?
nope
btw i tried this console.log(client.isReady())
and its responding with false
Thats what I thought, it means your bot isn't logged in when it hits your code
client.login(token) is async and thus it runs in the background
You can either await it with await but the proper way would be to use the clien.on("ready", () => {}) way where the function is your code you want to run once the bot is properly logged in
////////////////////////////////Ready////////////////////////////////////////
client.on('ready', () => {
console.log(`[API] Logged in as ${client.user.username}`);
client.user.setStatus(`idle`)
client.user.setActivity(`Watching in Dark`)
})
////////////////////////////////Logging////////////////////////////////////////
console.log(process.version)
module.exports = client;
client.events = new Collection();
client.slashCommands = new Collection();
require("./handlers");
client.login(config.token).then(() => {
loadEvents(client, color);
loadCommands(client, color);
}).catch(err => {
console.log(`${color.bold.red(`[INDEX ERROR]`)} ` + `${err}`.bgRed);
});
Why did you do .then(() => { loadEvents(client, color); loadCommands(client, color); }) exactly? You should just put it into the ready callback
to load the events and commands
Well ye but the proper way is to put it into the callback as there is other stuff running after the login function has ran
ohh
I had issues myself with that as I tried awaiting the entire login process but it failed for me aswell
Putting everything into the callback has the desired effect and is also the prefered way by discord.js