From a8efb1949ad4b554d5c59f7b55a251ee12abc93d Mon Sep 17 00:00:00 2001 From: Almeida Date: Tue, 7 Nov 2023 19:37:36 +0000 Subject: [PATCH] fix(RESTPutAPIGuildOnboardingJSONBody): optional keys and flattened emoji (#839) * fix(RESTPutAPIGuildOnboardingJSONBody): optional keys and flattened emoji * fix: requested changes --- deno/rest/v10/guild.ts | 43 ++++++++++++++++++++++++++++++---- deno/rest/v9/guild.ts | 43 ++++++++++++++++++++++++++++++---- rest/v10/guild.ts | 43 ++++++++++++++++++++++++++++++---- rest/v9/guild.ts | 43 ++++++++++++++++++++++++++++++---- tests/v10/onboarding.test-d.ts | 30 ++++++++++++++++++++++++ 5 files changed, 186 insertions(+), 16 deletions(-) create mode 100644 tests/v10/onboarding.test-d.ts diff --git a/deno/rest/v10/guild.ts b/deno/rest/v10/guild.ts index 9af8b836..67a69bde 100644 --- a/deno/rest/v10/guild.ts +++ b/deno/rest/v10/guild.ts @@ -24,8 +24,11 @@ import type { GuildSystemChannelFlags, GuildVerificationLevel, GuildWidgetStyle, + APIGuildOnboardingPrompt, + APIGuildOnboardingPromptOption, } from '../../payloads/v10/mod.ts'; import type { + AddUndefinedToPossiblyUndefinedPropertiesOfInterface, DistributiveOmit, DistributivePick, Nullable, @@ -930,10 +933,42 @@ export type RESTGetAPIGuildOnboardingResult = APIGuildOnboarding; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding */ -export type RESTPutAPIGuildOnboardingJSONBody = Pick< - APIGuildOnboarding, - 'default_channel_ids' | 'enabled' | 'mode' | 'prompts' ->; +export type RESTPutAPIGuildOnboardingJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> +> & { + /** + * Prompts shown during onboarding and in customize community + */ + prompts?: RESTAPIModifyGuildOnboardingPromptData[] | undefined; +}; + +export type RESTAPIModifyGuildOnboardingPromptData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Options available within the prompt + */ + options: RESTAPIModifyGuildOnboardingPromptOptionData[]; + }; + +export type RESTAPIModifyGuildOnboardingPromptOptionData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Emoji id + */ + emoji_id?: Snowflake | null | undefined; + /** + * Emoji name + */ + emoji_name?: string | null | undefined; + /** + * Whether this emoji is animated + */ + emoji_animated?: boolean | null | undefined; + }; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding diff --git a/deno/rest/v9/guild.ts b/deno/rest/v9/guild.ts index db39b13b..144bcb37 100644 --- a/deno/rest/v9/guild.ts +++ b/deno/rest/v9/guild.ts @@ -24,8 +24,11 @@ import type { GuildWidgetStyle, APIDMChannel, APIGroupDMChannel, + APIGuildOnboardingPrompt, + APIGuildOnboardingPromptOption, } from '../../payloads/v9/mod.ts'; import type { + AddUndefinedToPossiblyUndefinedPropertiesOfInterface, DistributiveOmit, DistributivePick, Nullable, @@ -936,10 +939,42 @@ export type RESTGetAPIGuildOnboardingResult = APIGuildOnboarding; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding */ -export type RESTPutAPIGuildOnboardingJSONBody = Pick< - APIGuildOnboarding, - 'default_channel_ids' | 'enabled' | 'mode' | 'prompts' ->; +export type RESTPutAPIGuildOnboardingJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> +> & { + /** + * Prompts shown during onboarding and in customize community + */ + prompts?: RESTAPIModifyGuildOnboardingPromptData[] | undefined; +}; + +export type RESTAPIModifyGuildOnboardingPromptData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Options available within the prompt + */ + options: RESTAPIModifyGuildOnboardingPromptOptionData[]; + }; + +export type RESTAPIModifyGuildOnboardingPromptOptionData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Emoji id + */ + emoji_id?: Snowflake | null | undefined; + /** + * Emoji name + */ + emoji_name?: string | null | undefined; + /** + * Whether this emoji is animated + */ + emoji_animated?: boolean | null | undefined; + }; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding diff --git a/rest/v10/guild.ts b/rest/v10/guild.ts index b918af67..c3ae0143 100644 --- a/rest/v10/guild.ts +++ b/rest/v10/guild.ts @@ -24,8 +24,11 @@ import type { GuildSystemChannelFlags, GuildVerificationLevel, GuildWidgetStyle, + APIGuildOnboardingPrompt, + APIGuildOnboardingPromptOption, } from '../../payloads/v10/index'; import type { + AddUndefinedToPossiblyUndefinedPropertiesOfInterface, DistributiveOmit, DistributivePick, Nullable, @@ -930,10 +933,42 @@ export type RESTGetAPIGuildOnboardingResult = APIGuildOnboarding; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding */ -export type RESTPutAPIGuildOnboardingJSONBody = Pick< - APIGuildOnboarding, - 'default_channel_ids' | 'enabled' | 'mode' | 'prompts' ->; +export type RESTPutAPIGuildOnboardingJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> +> & { + /** + * Prompts shown during onboarding and in customize community + */ + prompts?: RESTAPIModifyGuildOnboardingPromptData[] | undefined; +}; + +export type RESTAPIModifyGuildOnboardingPromptData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Options available within the prompt + */ + options: RESTAPIModifyGuildOnboardingPromptOptionData[]; + }; + +export type RESTAPIModifyGuildOnboardingPromptOptionData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Emoji id + */ + emoji_id?: Snowflake | null | undefined; + /** + * Emoji name + */ + emoji_name?: string | null | undefined; + /** + * Whether this emoji is animated + */ + emoji_animated?: boolean | null | undefined; + }; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding diff --git a/rest/v9/guild.ts b/rest/v9/guild.ts index d05ebb3b..fc99f74f 100644 --- a/rest/v9/guild.ts +++ b/rest/v9/guild.ts @@ -24,8 +24,11 @@ import type { GuildWidgetStyle, APIDMChannel, APIGroupDMChannel, + APIGuildOnboardingPrompt, + APIGuildOnboardingPromptOption, } from '../../payloads/v9/index'; import type { + AddUndefinedToPossiblyUndefinedPropertiesOfInterface, DistributiveOmit, DistributivePick, Nullable, @@ -936,10 +939,42 @@ export type RESTGetAPIGuildOnboardingResult = APIGuildOnboarding; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding */ -export type RESTPutAPIGuildOnboardingJSONBody = Pick< - APIGuildOnboarding, - 'default_channel_ids' | 'enabled' | 'mode' | 'prompts' ->; +export type RESTPutAPIGuildOnboardingJSONBody = AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> +> & { + /** + * Prompts shown during onboarding and in customize community + */ + prompts?: RESTAPIModifyGuildOnboardingPromptData[] | undefined; +}; + +export type RESTAPIModifyGuildOnboardingPromptData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Options available within the prompt + */ + options: RESTAPIModifyGuildOnboardingPromptOptionData[]; + }; + +export type RESTAPIModifyGuildOnboardingPromptOptionData = Pick & + AddUndefinedToPossiblyUndefinedPropertiesOfInterface< + Partial> + > & { + /** + * Emoji id + */ + emoji_id?: Snowflake | null | undefined; + /** + * Emoji name + */ + emoji_name?: string | null | undefined; + /** + * Whether this emoji is animated + */ + emoji_animated?: boolean | null | undefined; + }; /** * https://discord.com/developers/docs/resources/guild#modify-guild-onboarding diff --git a/tests/v10/onboarding.test-d.ts b/tests/v10/onboarding.test-d.ts new file mode 100644 index 00000000..3d061d9e --- /dev/null +++ b/tests/v10/onboarding.test-d.ts @@ -0,0 +1,30 @@ +import { expectAssignable } from 'tsd'; +import type { APIGuildOnboarding, RESTPutAPIGuildOnboardingJSONBody } from '../../v10'; + +declare const onboarding: APIGuildOnboarding; + +expectAssignable({}); +expectAssignable(onboarding); +expectAssignable({ + default_channel_ids: ['123456789012345678'], + prompts: [ + { + id: '123456789012345678', + title: 'This is a title', + options: [ + { + title: 'yeet', + emoji_name: '😎', + role_ids: undefined, + }, + { + id: '123456789012345678', + title: 'yeet with id', + emoji_id: '123456789012345678', + }, + ], + in_onboarding: undefined, + }, + ], + enabled: undefined, +});