Closed SirDeadlystrike closed 6 years ago
Is your own bot invisible? If so, that would explain why the bot member is not cached.
Otherwise, any uncached members can be fetched with guild.fetchMember
.
Edit: guild.members.fetch
on master.
No, the bot is not invisible. While yes, i could check if the member object of both the bot and the message sender is cached on every command, and if not fetch it. That seems like a band-aid solution to larger problem of guilds having no members cached ever.
I don't think this is a intended behavior especially when its happening to only a few guilds at a time.
Every time i restart the bot within 2hrs there is 1-2 people complaining that things arn't working which are caused by both message.member and guild.me returning undefined.
Are these guilds over 250 members?
No 48 members on the most recent noted issue guild
A bit more info. A small 22 man guild went from working fine to no longer having valid objects for the bot member or any message member. For this specific guild the issue persisted them kicking and re-inviting the bot, and was only fixed once i rebooted the bot as a whole
Did you set fetchAllMembers
to true in your client settings? You can try that, and see if that fixes it
the member for the client is always sent regardless of guild size, client status, fetchAllMembers settings, etc
You should not rely on msg.member to always be present @gmedeadlystrike If a member is invis for quite some time you would have to fetch his member each and every restart of your bot. And its not really a band-aid to fetch every time someone triggers a command because if the person is already in cache you get the cached member back.
I understand, I guess I will make sure the member object is present. It does however look like there is a issue with the client not having a member object cached as was noted here https://github.com/Gawdl3y/discord.js-commando/pull/70
Hmmm. seems relatetd to my issue: https://github.com/hydrabolt/discord.js/issues/1848
Could you send me any stacktraces if you have them, and also debug guild.members.size
at the time of the error? I want to see if the members cache is being cleared accidentally.
@hydrabolt - guild.members.size was infact 0 during a couple of these issues
@gmedeadlystrike do you know if the server experience any outages in this time?
Also, are you using any bot frameworks? Can you also debug client.users.filter(u => !u.id).size
at the time of error.
Could you try using master on the lastest commit ^ 👍
Seems to be fixed for @dragonfire535, I'll give it a few more days before officially declaring as fixed 👍
It's back, attempting to get more information.
Yep, issue is still happening
So i got some more info on this issue. I use the commando framework which by default will await the caching of the client and user member objects before running commands to make sure their available. You can see an example of this in this PR https://github.com/Gawdl3y/discord.js-commando/pull/73 - with such a check in place I have not noticed any instances of the user member object not being in cache, but in fact still on occasion notice the clientuser's member object being undefined. @hydrabolt
So... it's still in cache but sometimes still undefined?
I don't quite get what you are saying there.
Sorry, maybe i was unclear. The method you would normally use to ensure and force the member objects (client + user) into cache is in place and being executed, however a few cpu cycles later the clientuser member object can return undefined, im not sure if that means its no longer in the cache or if guild.me is returning undefined for another reason. One line before I call guild.me
I am checking that the guild still exists
Can anyone here try: npm i -S bdistin/discord.js#patch-30
and watch and see if the issue shows up, or if that pr fixes the issue?
This shouldn't be closed 👀
@dragonfire535 ok, I have not seen this issue pop up in a week or so now, so 🤷♂️
@gmedeadlystrike have you been able to reproduce this in the last few days? :s
@hydrabolt I'm not sure if this is related but filtering from GuildMembers in a Guild from Message gives many statuses undefined.
const totalOffline = members.filter(m => m.user.presence.status == "offline").size;
If you log the status, most of them are appearing offline.
from my observations, this issue all but vanished after the "kick-fix" where that seemed to resolve almost all instances of this. Recently I have begun to get reports of this issue occurring with my bot once again.
I don't have a repeatable chain of events to trigger it as was the case last time just yet, will update if i have more info
I've just had to deal with a similar issue on v11.3.0, where lots of members weren't getting cached.
On a small (11 member) server, everything worked as expected, but on a larger (7015 member) server things broke.
Users who just joined would have member
sent correctly for guildMemberAdd
, but trying message.member
on one of their messages or trying to fetch them from guild.members
returns undefined
.
Trying guild.fetchMembers()
didn't help, as the number of cached members before/after were the same
Changing to most recent commit (e576387fea2a973eefe298a6f3610eb0d8b54999) fixes all of this: members are cached on join and message.guild.members.fetch()
fetches all 7k members
@AtlasTheBot, I cannot verify your claims. I have done the same on 11.3 and it updated the cache for me. As for the other behaviour, I believe that you are confusing it with a different issue. Members are not cached if their status is offline in a large guild. Additionally, it should be returning null
over undefined
, if that was a mistake. If it is not, well, then that is concerning. But if it is truly null
, a simple guild.fetchMember()
would do with their id in the message event, that is how we do it in general to grab the cached member.
I have received a report from one of my bot's users that indicates this bug is still occurring. The user reported that all guild members were not considered being in a voice channel despite actually being in a voice channel. I'm running a slightly outdated version of master
(3e3674b1af200eb3947018f210bdf49b0e200b1b). Unfortunately I cannot really provide more information than has already been reported, other than to provide a more recent commit hash (assuming @AtlasTheBot's comment is unrelated to this bug). I will update to a more recent version of master and see if I still have this bug.
This issue has been pretty stale for a few months now, open a new issue if this still persists please.
Error: Invalid or uncached id provided
Please describe the problem you are having in as much detail as possible: Guilds are seemingly at random having no member objects. Even after multiple messages received and minutes later. guild.me and message.member are undefined along with everyone else. These are not new guilds.
Further details: