FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Discussion about differentiating between Socket, Http and possibly Cache entities · Issue #839 · DSharpPlus/DSharpPlus · GitHub

Discussion about differentiating between Socket, Http and possibly Cache entities #839

Description

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)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL