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

Fix lazy guild loading #161

Merged
merged 1 commit into from
Apr 4, 2016
Merged

Fix lazy guild loading #161

merged 1 commit into from
Apr 4, 2016

Conversation

b1naryth1ef
Copy link
Contributor

We're (Discord) moving to a method of lazy-loading guilds to help with extremely large READY packets. With this new method, clients will now receive only the 'id' and 'unavailable' fields for every guild in the READY packet, and will lazily receive GUILD_CREATE events for those guilds as they are connected by our backend.

Previously discordgo used the Guild objects originally passed in the READY payload as the base object for all future events, however with this new method we now case this to when the original guild is not unavailable.

Something this commit does not add, but may be helpful is a way to detect the difference between GUILD_CREATE's used for the handshake process, vs GUILD_CREATE's that actually represent a guild being created/added. Due to the way the state works right now, the handler is always called before any of the users and therefore you cannot compare the state before/after the GUILD_CREATE to understand whether it is a new or lazily loaded guild.

👀 @iopred @bwmarrin

We're moving to lazy-loading guilds, meaning bots now recieve a READY
packet with guilds that only have 'id' and 'unavailable' fields. Post
READY, the client then lazyily recieves GUILD_CREATE's for the rest of
the guilds it's in. Previously we assumed the first instance of the
guild we got (from ready) had all the required information, now we need
to use the GUILD_CREATE if the guild was marked as unavailable.
@iopred
Copy link
Collaborator

iopred commented Apr 4, 2016

Looks good to me.

@bwmarrin
Copy link
Owner

bwmarrin commented Apr 4, 2016

Thanks! LGTM too...

@bwmarrin bwmarrin added this to the v0.12.0 milestone Apr 4, 2016
@bwmarrin bwmarrin added the feature Feature implementation label Apr 4, 2016
@bwmarrin bwmarrin merged commit 6101abe into bwmarrin:develop Apr 4, 2016
alex-j-butler pushed a commit to alex-j-butler/discordgo that referenced this pull request Nov 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature implementation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants