Discord.js: Client Readying before Client.Emojis is defined

Created on 17 Aug 2017  路  17Comments  路  Source: discordjs/discord.js

Hey, so I've noticed that the client readies often before client.emojis is even defined.
This leads to all sorts of errors on any of my commands that use the property. I don't feel like it should be necessary for people to have to try/catch every single time they use the property in case someone uses a command that accesses it too early after the bot starts up.
I suggest this be fixed before the next update to stable and don't ready the client before things have finished loading in.

question (please use Discord instead)

Most helpful comment

provide some code, as asked in the issue template you deleted, stop putting thumbs down on my comments, and be helpful, thx :)

All 17 comments

Please follow the template issue you were presented upon opening the issue.
Also, I've noticed similar things with variables not being defined in ready on my host but are on local.

Emojis is a getter on the client, which is defined at instantiation time. This means whatever error you are having is your fault.

Nothing is wrong with how my client is defined.

What gus is attempting to say is that client.emojis will never be undefined after instantiation. It would rather be an empty collection.

Well the problem is that attempting to do anything with client.emojis soon after the bot starts up gives an error for "cant read property X of undefined". This error fixes itself after some time

do you mean client is undefined?

No, only the emojis property
Nothing is wrong with client as everything else is functional

The issue as you've described it thus far indicates an issue with your own code. As I mentioned previously, client.emojis will never be undefined upon instantiation.

What could cause an issue that would make client.emojis undefined ONLY soon after restarting the bot and then fix itself over time with no change to the code?
Would be extremely hard for me to accidentally do something like that.

if your error truly is cannot read property emojis of undefined then your client variable is undefined.

No, its not. The error is coming from reading a property of client.emojis, not an error with reading the emojis property

Instead of deleting the issue template, can you follow the instructions and provide a small sample to recreate the issue?

provide some code, as asked in the issue template you deleted, stop putting thumbs down on my comments, and be helpful, thx :)

Ok, heres what you do, run a bot through your user account, like a selfbot
if you have access to enough emojis, trying to use client.emojis soon after it starts will just throw an error

my example is literally client.emojis.WhateverPropertyOrMethodYouWant

in this case, i will ask you to join our support server here so we can assist you further

馃

@devsnek I tested it myself, the error wasn't actually client.emojis being undefined, it was simply throwing an error saying cannot read the property of .values() of undefined, which was in the emojis getter. I was going to make an issue myself explaining what he was trying to say properly, but I tested it on master, and it is working fine there.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

xCuzImPro picture xCuzImPro  路  3Comments

kvn1351 picture kvn1351  路  3Comments

Lombra picture Lombra  路  3Comments

DatMayo picture DatMayo  路  3Comments

Acaretia picture Acaretia  路  3Comments