Title: Issues with partial entities. · Issue #583 · DSharpPlus/DSharpPlus · GitHub
Open Graph Title: Issues with partial entities. · Issue #583 · DSharpPlus/DSharpPlus
X Title: Issues with partial entities. · Issue #583 · DSharpPlus/DSharpPlus
Description: Summary While DSharpPlus makes things simple by using a single class for many operations, it also creates several challenges for users wanting to do more with a partial entity. Details An example of this was reported yesterday by box of ...
Open Graph Description: Summary While DSharpPlus makes things simple by using a single class for many operations, it also creates several challenges for users wanting to do more with a partial entity. Details An example o...
X Description: Summary While DSharpPlus makes things simple by using a single class for many operations, it also creates several challenges for users wanting to do more with a partial entity. Details An example o...
Opengraph URL: https://github.com/DSharpPlus/DSharpPlus/issues/583
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Issues with partial entities.","articleBody":"# Summary\r\nWhile DSharpPlus makes things simple by using a single class for many operations, it also creates several challenges for users wanting to do more with a partial entity.\r\n\r\n# Details\r\nAn example of this was reported yesterday by `box of kittens (acw)#5184` on Discord. When calling `DiscordRestClient.GetGuildAsync()`, it returned a DiscordGuild object, and when trying to call `GetMemberAsync()` on this guild, it threw a NullReferenceException. The reason was because the internal `_members` dictionary was null, as the API does not return a member list for a guild obtained through rest. Overall, because of these singular entities, users believe they can interact with rest entities like they can with the gateway, which is misleading.\r\n\r\nThis can also be applied to skeleton entities, or discord objects containing only an Id.\r\n\r\n# Steps to Reproduce\r\n\r\n1. Create a DiscordRestClient and call `GetGuildAsync()` with a valid Id.\r\n2. Try to call `GetMemberAsync()` on the returned guild.\r\n3. Observe that a null reference exception is thrown because the internal members cache is null.\r\n\r\n# Solutions\r\nThere are a couple of ways to solve this.\r\n\r\nThe first is to go through and place null checks on these methods or make sure these object's properties are initialized when used internally in the methods.\r\n\r\nThe second is to create multiple entities depending on what properties are serialized, similar to Discord.Net. The biggest example would probably be separating rest entities from gateway entities, creating partial object classes as properties (as mentioned in #582), or just exposing the raw ids rather than skeleton objects if the full object cannot be found (as mentioned with MessageReferences in #472).","author":{"url":"https://github.com/sh30801","@type":"Person","name":"sh30801"},"datePublished":"2020-05-24T16:27:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/583/DSharpPlus/issues/583"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:10e96056-fb6a-54c9-bdb1-6c92f14051b0 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | A716:3E0034:4DB2CAA:6A124D3:698CDEA1 |
| html-safe-nonce | 86ee45e783a5c53714e30906f6b5b16d367eb661eeb85826830c1596c1876436 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJBNzE2OjNFMDAzNDo0REIyQ0FBOjZBMTI0RDM6Njk4Q0RFQTEiLCJ2aXNpdG9yX2lkIjoiNDE4ODM0NzM2MzE2NzYyNDg2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 0133bc0b22aa47492185390fe63d487b1d9220ef91cf804517c099f4bb865e60 |
| hovercard-subject-tag | issue:623897789 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/DSharpPlus/DSharpPlus/583/issue_layout |
| twitter:image | https://opengraph.githubassets.com/babca2047fec9a6c7efabd57f7cc176a3d0fcc9e2091044535cf8cbc0548cbd0/DSharpPlus/DSharpPlus/issues/583 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/babca2047fec9a6c7efabd57f7cc176a3d0fcc9e2091044535cf8cbc0548cbd0/DSharpPlus/DSharpPlus/issues/583 |
| og:image:alt | Summary While DSharpPlus makes things simple by using a single class for many operations, it also creates several challenges for users wanting to do more with a partial entity. Details An example o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sh30801 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 640eeb7b6ff4d8d106235d228c0c286e82592d4d2403227b5b2b4fc5832297a4 |
| turbo-cache-control | no-preview |
| go-import | github.com/DSharpPlus/DSharpPlus git https://github.com/DSharpPlus/DSharpPlus.git |
| octolytics-dimension-user_id | 36208721 |
| octolytics-dimension-user_login | DSharpPlus |
| octolytics-dimension-repository_id | 67243489 |
| octolytics-dimension-repository_nwo | DSharpPlus/DSharpPlus |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 67243489 |
| octolytics-dimension-repository_network_root_nwo | DSharpPlus/DSharpPlus |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 3d444f0a47beeeac94cddbb51c91ab408befe8d4 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width