From 17f6a8f743b7950d89e6b3fce6c4313ac33ba8d8 Mon Sep 17 00:00:00 2001 From: Jaw0r3k Date: Wed, 14 Jun 2023 15:14:41 +0200 Subject: [PATCH] feat: support onboarding --- packages/core/src/api/guild.ts | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index 2f74b3caf43b..47d198dd61fa 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -23,6 +23,7 @@ import type { RESTGetAPIGuildMembersResult, RESTGetAPIGuildMembersQuery, RESTGetAPIGuildMembersSearchResult, + RESTGetAPIGuildOnboardingResult, RESTGetAPIGuildPreviewResult, RESTGetAPIGuildPruneCountResult, RESTGetAPIGuildResult, @@ -79,6 +80,8 @@ import type { RESTPostAPIGuildChannelResult, RESTPostAPIGuildEmojiJSONBody, RESTPostAPIGuildEmojiResult, + RESTPutAPIGuildOnboardingJSONBody, + RESTPutAPIGuildOnboardingResult, RESTPostAPIGuildPruneJSONBody, RESTPostAPIGuildPruneResult, RESTPostAPIGuildRoleJSONBody, @@ -1229,4 +1232,37 @@ export class GuildsAPI { body, }) as Promise; } + + /** + * Fetches a guild onboarding + * + * @see {@link https://discord.com/developers/docs/resources/guild#get-guild-onboarding} + * @param guildId - The id of the guild to fetch the onboarding from + * @param options - The options for fetching the guild onboarding + */ + public async getOnboarding(guildId: Snowflake, { signal }: Pick = {}) { + return this.rest.get(Routes.guildOnboarding(guildId), { + signal, + }) as Promise; + } + + /** + * Edits the widget settings for a guild + * + * @see {@link https://discord.com/developers/docs/resources/guild#modify-guild-onboarding} + * @param guildId - The id of the guild to edit the onboarding settings from + * @param body - The new guild onboarding settings data + * @param options - The options for editing the guild onboarding + */ + public async editOnboarding( + guildId: Snowflake, + body: RESTPutAPIGuildOnboardingJSONBody, + { reason, signal }: Pick = {}, + ) { + return this.rest.patch(Routes.guildOnboarding(guildId), { + reason, + body, + signal, + }) as Promise; + } }