Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: Members didn't arrive in time. #3774

Closed
ndaniel10 opened this issue Feb 12, 2020 · 21 comments
Closed

Error: Members didn't arrive in time. #3774

ndaniel10 opened this issue Feb 12, 2020 · 21 comments

Comments

@ndaniel10
Copy link

Discord bot not caching all members and giving wrong member count

@RDambrosio016
Copy link
Contributor

This has been a recurring issue the past few days, it is not a library problem. There seems to be issues with the guild members chunk event not working properly. It is an API issue out of our control.

P.S.: you should not ignore the issue template 👀

@SpaceEEC
Copy link
Member

It looks like Discord sends those packets (again), at least for me.

@encloinc
Copy link

Same thing happening here

@Hey
Copy link

Hey commented Feb 15, 2020

Same thing here

@ToxicFrog
Copy link

This has been happening consistently to me for a while now.

If it is a problem at Discord's end, I wonder if they broke something when rolling out intent support -- I know intents are meant to be optional right now, but maybe they're not as optional as they should be.

@monbrey
Copy link
Member

monbrey commented Feb 17, 2020

Given that fetching all members was the one intent that they planned on restricting, I don't think this is "broken" but we'd definitely need more information from you all to try to help determine a real cause. Probably most notably - how many guilds is your bot impacted by this issue in?

Of course, if you're all logging in with user tokens, then A) you shouldn't be anyway since its against ToS and B) this is expected behaviour for user accounts

@KevinNovak
Copy link
Contributor

KevinNovak commented Jul 5, 2020

When I do

await guild.members.fetch();

I'm getting the following error message:
[GUILD_MEMBERS_TIMEOUT]: Members didn't arrive in time.

My bot is connected to ~5,000 guilds, and this always happens on the same 4 guilds. I read this might have to do with large guilds, however they're not particularly large at 48, 134, 632, and 1078 members (logging with guild.memberCount). Any ideas what might be causing this and what I can do?

@scottbucher
Copy link
Contributor

scottbucher commented Jul 9, 2020

I tend to get this error a lot when fetching all the guild members but when it fails I fall back to the cache. However, I did notice something interesting.

Whenever I am getting this error (I print out the guild.memberCount() and the guild.members.cache.size) the difference between the member count and cache size is almost always 1 (highest I have seen is 3-4). This makes me feel like the fetch() isn't fully failing, and it might only be failing to fetch one or a few members.
image

It could also be that discord is returning the correct amount of members but discord.js is doing some checks behind the scene and expecting it to be equal to guild.memberCount but it's guild.memberCount is out of date.

@Kotosif
Copy link

Kotosif commented Oct 27, 2020

Hitting the same issue today

@Thornsnake
Copy link

Dito, hitting the same issue today.

@Extroonie
Copy link
Contributor

As of 27/10/2020 (warned since October 7, 2020), Discord has started enforcing intents and developers are required to enable them for receiving certain gateway events. Read the guide on intents.

@DarkMatterMatt
Copy link

DarkMatterMatt commented Oct 28, 2020

Extending Extroonie's comment above, this can be resolved by requesting the GUILD_MEMBERS intent.

Steps:
1a. Go to https://discord.com/developers/applications
1b. Select your application, move to the Bot tab in the sidebar
1c. Enable "server members intent"
2. Make code changes (not required for the current version of Discord.js, will be required in the next major release, thanks @almostSouji )

Code (before):

const { Client } = require("discord.js");
const client = new Client();

Code (after):

const { Client, Intents } = require("discord.js");
const intents = new Intents([
    Intents.NON_PRIVILEGED, // include all non-privileged intents, would be better to specify which ones you actually need
    "GUILD_MEMBERS", // lets you request guild members (i.e. fixes the issue)
]);
const client = new Client({ ws: { intents } });

References:
https://discordjs.guide/popular-topics/intents.html#privileged-intents
https://discord.js.org/#/docs/main/stable/class/Intents

Edit: I made the mistake of referencing this issue in personal projects, would be appreciated if an admin removed the "added a commit that referenced this issue" comments below.

@almostSouji
Copy link
Member

almostSouji commented Oct 28, 2020

  1. Make code changes

No code changes needed. You don't need to necessarily provide the intents for version 12 of discord.js.
If you provide no intents to the Client constructor discord will just send all events for all intents (privileged intents require the toggle or explicit grant in case of bot verification (100+ servers). This will change in v13 where intents will be required.)


⚙️ Privileged intents and what they mean for you
❯ If you are on version 11 or earlier
• Update. We no longer provide support for or add features and bug fixes to version 11.

❯ Which intents are privileged, which do I need?
GUILD_MEMBERS | guildMemberAdd, guildMemberRemove, guildMemberUpdate
GUILD_PRESENCES | presenceUpdate, knowledge about peoples activities and client status
• If your bot does not need this information to provide its functionality, please do not request it.

❯ How can I do things without these events?
• Try to design your commands so they do not require this information
• Fetch member data by ID as you need it <Guild>.members.fetch("id")
• You have GUILD_MEMBERS: consider fetching members periodically, for the initial operation on boot you can consider using the client option fetchAllMembers (note: this will heavily increase memory usage)

❯ A) Your bot is verified
• You need to reach out to discord support R3 in order for intents to be enabled
• Please include a use case sample as to why you need that intent into your request
• Read R1, it explains the whole procedure and requirements

❯ B) Your bot is not verified
• You can switch the toggles (attached image)
• You should still consider designing your commands to not require privileged intents where ever possible

❯ Symptoms you might be experiencing right now:
• member caches are empty (or only have very few entries)
• user cache is empty (or has only very few entries)
• fetching members times out
• all members appear to be offline
• login times out if you try to fetch all members on startup
• The client events "guildMemberAdd", "guildMemberRemove", "guildMemberUpdate" do not emit
Guild#memberCount returns count as of ready

❯ Resources
R1 Discords FAQ: https://dis.gd/gwupdate
R2 Discord Developer Portal: https://discord.com/developers/applications
R3 Discord Support: https://dis.gd/contact

@JosefBud
Copy link

As of 27/10/2020 (warned since October 7, 2020), Discord has started enforcing intents and developers are required to enable them for receiving certain gateway events. Read the guide on intents.

Thank you @Extroonie ! I could not figure this out this morning, you're a life saver!

@kiyokodyele
Copy link

This happened to my discord server after having 1500+ members.

@monbrey
Copy link
Member

monbrey commented Oct 30, 2020

This happened to my discord server after having 1500+ members.

Well then since this already has a solution, please follow it.

@bala-techguy
Copy link

As of 27/10/2020 (warned since October 7, 2020), Discord has started enforcing intents and developers are required to enable them for receiving certain gateway events. Read the guide on intents.

It took me several days to reach here. I wish I had found this long back. Thank you @Extroonie

@MDxWARRIORxOP
Copy link

i am still getting this error in discord.js v14, i have my intents on (in both the dev portal and the code) but im still getting this error, none of the above answers seemed to help

@JRTMediaUK
Copy link

JRTMediaUK commented Aug 26, 2022

Also having this issue, not an intents problem as all enabled on the dev portal and all intents added.

EDIT: Bot is only in 3 servers (Private bot)

@bala-techguy
Copy link

bala-techguy commented Aug 26, 2022

i am still getting this error in discord.js v14, i have my intents on (in both the dev portal and the code) but im still getting this error, none of the above answers seemed to help

I had the problem in v14 and it was resolved by adding the below:

const { Client, GatewayIntentBits, Partials } = require('discord.js');

const client = new Client({
  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMembers, GatewayIntentBits.DirectMessages, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],
  partials: [Partials.Channel],
});

client.login(config.token);

After I added GatewayIntentBits.GuildMembers, I did not get this error message.

@almostSouji
Copy link
Member

This issue is by now very outdated and originally was happening for very different reasons.
If you still run into this error, please fill out a new issue, as we are currently supporting both v13 and v14 the treatment varies.

Generally speaking, the reasoning is still the same I outlined in #3774 (comment) , but with applying new enums or at least PasCase flag names, as shown in #3774 (comment)

@discordjs discordjs locked as resolved and limited conversation to collaborators Aug 26, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests