Discord.js: Odd error thrown when attempting to send multiple avatarURLs

Created on 13 May 2019  Â·  8Comments  Â·  Source: discordjs/discord.js

Please describe the problem you are having in as much detail as possible:
When attempting to send a message of the URL's of every user in the guild, it only sends about a third and throws this error:
"TypeError: Cannot destructure property reply of 'undefined' or 'null'."
I don't know how that's in relation at all to the code sample below.

Include a reproducible code sample here, if possible:

let b = msg.guild.members.map(x => x);
for (let i in b) {
   client.channels.get('channel id').send(b[i].user.avatarURL)
}

Further details:

  • discord.js version: 11.4.2 happens on new release 11.5.0 too
  • Node.js version: v8.15.0
  • Operating system: Ubuntu 16.04.5 LTS
  • Priority this issue should have – please be realistic and elaborate if possible:
    Decently low, not many other people should want to mass send profile pictures of members in their guild
  • [ ] I have also tested the issue on latest master, commit hash:
invalid

Most helpful comment

It could be possible that a Member does not have a custom avatar since ur using User.avatarURL as opposed to User.displayAvatarURL. Sending undefined gives a "Can't send empty message" error.

All 8 comments

I used the same code sample on my guild which has 4 members only, and the expected output was achieved. I tested it in discord.[email protected], discord.[email protected], and in the master branch.

If anything is going to happen, you will get rate limited due to the repetitive API call (API spam); as you are sending a message containing the avatar URL for every member.

Are you doing anything rather than that code sample? Like some side functions or events might be triggered without notice containing Message#reply.

I expected being ratelimited, but shouldn't Discord resume the buffer?
Is there a ratelimit on requests for profile pictures?
I haven't modified .reply in anyway, and the code in the sample is all that's being run

Although it might be worth looking into it, you realize that code is crazy api spam right? You would be far better off pushing those to an aray or something and sending a concatenated string which would make far fewer api calls.

I ran code from example and indeed got the error.
However, interestingly enough, when i replaced sending with logging to console, and then ran it in same guild in same minute, error wasn't thrown.

It might be related to the large amount of API calls. I still don't understand the relation with Message#reply, though.

Could you please show the stacktrace of the error and the string being sent?
I can not see how this would happen when sending a string.

It could be possible that a Member does not have a custom avatar since ur using User.avatarURL as opposed to User.displayAvatarURL. Sending undefined gives a "Can't send empty message" error.

Can you confirm if @KinectTheUnknown's comment was valid?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  Â·  3Comments

ghost picture ghost  Â·  3Comments

shukriadams picture shukriadams  Â·  3Comments

DatMayo picture DatMayo  Â·  3Comments

xCuzImPro picture xCuzImPro  Â·  3Comments