Discord.js: Login promise will resolve before the Ready event is generated.

Created on 1 Dec 2019  Â·  1Comment  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:

The Login promise will resolve before the Ready event is generated.

Maybe this is the wanted behaviour ? I'm not sure, it feels odd to me.

Include a reproducible code sample here, if possible:


try {
    // Login the client to the Discord API
    await bot.login(env.DISCORD_TOKEN)
    // On Ready runs about here but on this line it may not have generated the ready event yet so any code here will not see the guilds as the bot is not truly connected.

// Although it will work on small test Discords I ran the same code on a bot that run on 3, 2000+ members Discord and the first Discord was not ready when that line ran, but the 2 after were actually ready.
} catch (err) {
    console.error("ERROR : An error occurred during login, ABORTING !", err)
    process.exit(21)
}
// True Ready state
bot.on("ready", () => {
    // The bot is truly logged in at this point.
})


Further details:

  • discord.js version: discord.[email protected]
  • Node.js version: v12.12.0
  • Operating system: Windows 10 Pro 1903
  • Priority this issue should have – please be realistic and elaborate if possible:
  • [x] I have also tested the issue on latest master, commit hash: 1b1289b35e2f8cd21341351549e6ac52fd08cb34
unverified bug

Most helpful comment

This is pretty much exactly why the ready event exists.

The process of initialising the bot is much more than a login - it identifies with the gateway and Discord.js populates it's Collections with the data received (guilds, channels, etc).

>All comments

This is pretty much exactly why the ready event exists.

The process of initialising the bot is much more than a login - it identifies with the gateway and Discord.js populates it's Collections with the data received (guilds, channels, etc).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

smchase picture smchase  Â·  3Comments

PassTheMayo picture PassTheMayo  Â·  3Comments

iCrawl picture iCrawl  Â·  3Comments

Acaretia picture Acaretia  Â·  3Comments

Alipoodle picture Alipoodle  Â·  3Comments