#Context.Guild.Users contains users not on the server

1 messages · Page 1 of 1 (latest)

sage hamlet
#

Sometimes, after the bot has been connected for a few days, Guild.Users becomes corrupted and contains people that were on the server once. Either they left on their own, or more often, were banned.

This doesn't happen immediately after bot starting. It takes a couple-three days of runtime to get corrupted.

Idk if it's even possible for my code to do this, but my code does not alter Guild.Users ever.

#

In this image, Mr. Peanut left the server on their own august of 2023.

#

relevant code for the unverified command

#

that is the relevant code for the prune command

#

no other code in the bot looks at Context.Guild.Users

#

i have seen this show 3 or 4 people that had been banned previously

#

(at which point ill restart the bot)

#

i did not notice this issue prior to 1.15.3 api .. currently running 1.16.0 and still see it

harsh tide
#

Assuming that you have the GuildMembers intent enabled - the cache should always be up to date

#

so that all sounds weird hm.

sage hamlet
#

#discussion message there was also an issue i outlined here (and i think once or twice before in months previous) where the channel message cache is getting corrupted too. that issue predates the users one.. to like 3.13 maybe?

raven adderBOT
#
lexialexis
Message:

i have a super weird bug going back a long time.. we have a verification channel.. people say their thing .. we issue a command .. the bot looks in our verification channel for a message from the person we are doing verify on .. if it finds messages from that person it deletes them.

it does this two ways .. it checks SocketTextChannel.CachedMessages for messages that were added after the bot connects, and i have a separate List<IMessage> of messages from before the bot connected --- obtained via SocketTextChannel.GetMessagesAsync()

this works for a day or two .. after a couple days -- sometimes a week the cache gets corrupted and discord.net stops adding new messages to the CachedMessages list .. and i have no idea why. this bug has persisted in my bot since like discord.net 3.13 and im on .16 now

none of my code removes anything from that list.. it only reads from it

Quoted By:

@sage hamlet from #discussion in Discord.Net

sage hamlet
#

to solve it i just dont use the cache at all anymore and pull the channel history every single time i need it .. obviously i shouldn't have to do that

#

im surprised you haven't encountered this before .. i assumed there was some race condition causing all these corrupted cache issues upstream

harsh tide
#

The only way cache could come out of sync would be the client missing events from the gateway

sage hamlet
#

but its responding to events like commands .. and that doesnt explain how things like banned users ending up on the user cache

#

and for the channel cache problem, it's like a switch flips .. it was working, and now from this point moving forward until the bot is restarted, it no longer records cache for the channel. (I only ever looked at the cache for a single channel -- i can not confirm its a wider issue)

#

client missing events doesn't make sense to explain what's happening

sage hamlet