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

feat(APIGuildScheduledEvent): add more precise types for stage instance/voice/external events #278

Merged
merged 1 commit into from Dec 26, 2021
Merged

feat(APIGuildScheduledEvent): add more precise types for stage instance/voice/external events #278

merged 1 commit into from Dec 26, 2021

Conversation

cherryblossom000
Copy link
Contributor

@cherryblossom000 cherryblossom000 commented Dec 26, 2021

Please describe the changes this PR makes and why it should be merged:

This PR turns APIGuildScheduledEvent into a union of APIStageInstanceGuildScheduledEvent, APIVoiceGuildScheduledEvent, and APIExternalGuildScheduledEvent, which each has more precise types according to the docs.

This PR also fixes a bug as previously APIGuildScheduledEvent#entity_metadata was not nullable, even though it should be.

Reference Discord API Docs PRs or commits:


Technically, entity_metadata isn’t always null for stage instance events (see discord/discord-api-docs#4198) and contains a speaker_ids field, but that isn’t documented anymore.

From this comment:

there are currently no plans on publicly supporting this field for events with type STAGE_INSTANCE. this is more of a free form metadata property with no guarantees for this field to be non-null in the future for STAGE_INSTANCE events.

I decided to make entity_metadata null for stage instance events as that is what the documentation states.

…ce/voice/external events

This commit turns `APIGuildScheduledEvent` into a union of
`APIStageInstanceGuildScheduledEvent`, `APIVoiceGuildScheduledEvent`,
and `APIExternalGuildScheduledEvent`, which each has more precise types
according to [the docs][1].

This commit also fixes a bug as previously
`APIGuildScheduledEvent#entity_metadata` was not nullable, even though
it should be.

[1]: https://discord.com/developers/docs/resources/guild-scheduled-event#guild-scheduled-event-object-field-requirements-by-entity-type
@vladfrangu vladfrangu merged commit 751aee6 into discordjs:main Dec 26, 2021
@cherryblossom000 cherryblossom000 deleted the better-event-types branch December 26, 2021 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants