Discussion about differentiating between Socket, Http and possibly Cache entities
Created by: Naamloos
Summary
There has been some discussion before about inconsistencies in entities received by either the WebSocket, HTTP requests or from the cache. This issue has come up in several issues before (#583, #582, #472). Other issues that are partially related would be (#435, #571). Opening this issue for centralized further discussion.
Details
I personally think it would be best to create abstract classes for entities that contain fields that are always available. For Socket and HTTP we'd implement these abstract classes with the additional fields these channels provide. We could also provide a separate Cache entity for everything that gets cached, but I'm not 100% sure whether that's a good idea (yet).
Some pseudocode on what I'd assume it to look like
DiscordSocketGuild guild = e.Guild; // A guild received by the websocket, e.g. in an event handler.
DiscordHttpGuild guild2 = await client.GetGuildAsync(379378609942560770); // A guild received from HTTP
BaseDiscordGuild guild3 = guild; // DiscordSocketGuild implements BaseDiscordGuild so we can assign it to that type
guild3 = guild2; // So can we for the HTTP guild
After assigning our guild to BaseDiscordGuild
, we'd assure that all fields on that type are available.
Of course, my word is not final. Please discuss on other viable solutions, or improve on what I proposed. (yes, I'm technically a main maintainer but for this project it's more important to do what the community wishes)