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

Better synchronize model types with Discord API documentation #2056

Open
kangalio opened this issue Jul 19, 2022 · 2 comments
Open

Better synchronize model types with Discord API documentation #2056

kangalio opened this issue Jul 19, 2022 · 2 comments
Labels
feature-request A new requested functionality. model Related to the `model` module.

Comments

@kangalio
Copy link
Collaborator

kangalio commented Jul 19, 2022

It's a chore to use model types because

  • they're missing some fields
  • they have some redundant Option<T> fields that users think they can use but they're just always None
  • other fields have lacking docs (e.g. Option<T> fields not mentioning they're only sometimes populated, leaving users confused)

All of this could be solved by better integrating the official Discord API docs into serenity.

I think all model types should include a link to the official object structure docs (like #1965).

Ideally, we would also have a tool that parses serenity source code using syn and scrapes Discord API docs, to make sure serenity's model types have correct fields and include Discord's official field documentation

@arqunis arqunis added feature-request A new requested functionality. model Related to the `model` module. labels Jul 19, 2022
@kangalio
Copy link
Collaborator Author

kangalio commented Nov 6, 2022

Ideally, we would also have a tool that parses serenity source code using syn and scrapes Discord API docs, to make sure serenity's model types have correct fields and include Discord's official field documentation

This is not really doable because our structs differ from official Discord docs too often. For example representing mutually exclusive fields via enums instead of flattened nullable fields or inserting additional data like guild_id.

@kangalio
Copy link
Collaborator Author

Also, such a tool isn't needed because Discord announces new API features. So we'd only need to invest a one-time effort of going through all structs and updating them according to the Discord API docs; and after that it's just a matter of keeping up with the announcements.

Plan

  • go through model structs systematically,
  • look at the associated Discord docs page (should be linked in the struct doc comments; insert link if not)
  • sort the struct fields in the same order as in Discord docs for easier comparability
  • add missing struct fields
  • remove phantom struct fields
    • beware for exceptions! Some structs have a guild_id field that is inserted at deserialization time. Such exceptions should be commented in the struct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A new requested functionality. model Related to the `model` module.
Projects
None yet
Development

No branches or pull requests

2 participants