Closed curz46 closed 4 years ago
Using IO.inspect Alchemy.Cache.Guilds.call(guild_id, :show)
I've determined it's nil
whenever the guild state is %{"id" => "437730559486328839", "unavailable" => true}
. This is expected however the guild remains unavailable, as far as I can tell, forever.
I believe there's a race condition with the Guilds
cache being started and GUILD_CREATE
being received.
This fixes a bug that I can only assume will have existed in Alchemy for a long time, which makes the Guild cache useless about 70% of the time due to the READY
event sometimes taking long enough for GUILD_CREATE
to fire before it finishes. It's a bit of a hack, but it successfully forces READY
's handler to occur before any other events. Credit: https://discordapp.com/channels/269508806759809042/269508806759809042/603280763357757443
Hmm, can you try and move these bug fixes to another PR? I'd like to merge/think about them independent of the feature request.
I believe there's a race condition with the Guilds cache being started and GUILD_CREATE being received.
I think this explains a bug I've been seeing for years!
This fixes a bug that I can only assume will have existed in Alchemy for a long time, which makes the Guild cache useless about 70% of the time due to the READY event sometimes taking long enough for GUILD_CREATE to fire before it finishes.
Yes this! My bot just restarts repeatedly until it works as it needed that functionality... >.>
@OvermindDL1 I created an issue regarding the bug here #79 if you're interested.
@cronokirby is there a reason why you're holding back on merging this one? Asking because I have more changes to events lined up fixing channel caching.
Edit: by the way, I think we should change all update
handlers in event to give the old entity so that it's consistent and because it's very useful to have.
This does not work correctly at the moment.
old_role
is very oftennil
, and it appears to be random whether or not the role is already cached. If it isnil
at the start, it will always benil
, even though I am updating the guilds cache. Here's the test I'm using:Note: the above code also seems to receive an update for the
@everyone
role whenever any other role is updated, hopefully that's expected behaviour.