diff --git a/packages/core/src/api/guild.ts b/packages/core/src/api/guild.ts index 2f74b3caf43b..50555e96cf05 100644 --- a/packages/core/src/api/guild.ts +++ b/packages/core/src/api/guild.ts @@ -1,98 +1,99 @@ /* eslint-disable jsdoc/check-param-names */ import { makeURLSearchParams, type REST, type RawFile, type RequestData } from '@discordjs/rest'; -import { Routes } from 'discord-api-types/v10'; -import type { - RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, - RESTPatchAPIGuildVoiceStateCurrentMemberResult, - GuildMFALevel, - GuildWidgetStyle, - RESTGetAPIAuditLogQuery, - RESTGetAPIAuditLogResult, - RESTGetAPIAutoModerationRuleResult, - RESTGetAPIAutoModerationRulesResult, - RESTGetAPIGuildBanResult, - RESTGetAPIGuildBansQuery, - RESTGetAPIGuildBansResult, - RESTGetAPIGuildChannelsResult, - RESTGetAPIGuildEmojiResult, - RESTGetAPIGuildEmojisResult, - RESTGetAPIGuildIntegrationsResult, - RESTGetAPIGuildInvitesResult, - RESTGetAPIGuildMemberResult, - RESTGetAPIGuildMembersResult, - RESTGetAPIGuildMembersQuery, - RESTGetAPIGuildMembersSearchResult, - RESTGetAPIGuildPreviewResult, - RESTGetAPIGuildPruneCountResult, - RESTGetAPIGuildResult, - RESTGetAPIGuildRolesResult, - RESTGetAPIGuildScheduledEventQuery, - RESTGetAPIGuildScheduledEventResult, - RESTGetAPIGuildScheduledEventsQuery, - RESTGetAPIGuildScheduledEventsResult, - RESTGetAPIGuildScheduledEventUsersQuery, - RESTGetAPIGuildScheduledEventUsersResult, - RESTGetAPIGuildStickerResult, - RESTGetAPIGuildStickersResult, - RESTGetAPIGuildTemplatesResult, - RESTGetAPIGuildThreadsResult, - RESTGetAPIGuildVanityUrlResult, - RESTGetAPIGuildVoiceRegionsResult, - RESTGetAPIGuildPruneCountQuery, - RESTPostAPIGuildStickerFormDataBody, - RESTPostAPIGuildStickerResult, - RESTGetAPIGuildMembersSearchQuery, - RESTGetAPIGuildWebhooksResult, - RESTGetAPIGuildWelcomeScreenResult, - RESTGetAPIGuildWidgetImageResult, - RESTGetAPIGuildWidgetJSONResult, - RESTGetAPIGuildWidgetSettingsResult, - RESTGetAPITemplateResult, - RESTPatchAPIAutoModerationRuleJSONBody, - RESTPatchAPIAutoModerationRuleResult, - RESTPatchAPIGuildChannelPositionsJSONBody, - RESTPatchAPIGuildEmojiJSONBody, - RESTPatchAPIGuildEmojiResult, - RESTPatchAPIGuildJSONBody, - RESTPatchAPIGuildMemberJSONBody, - RESTPatchAPIGuildMemberResult, - RESTPatchAPIGuildResult, - RESTPatchAPIGuildRoleJSONBody, - RESTPatchAPIGuildRolePositionsJSONBody, - RESTPatchAPIGuildRolePositionsResult, - RESTPatchAPIGuildRoleResult, - RESTPatchAPIGuildScheduledEventJSONBody, - RESTPatchAPIGuildScheduledEventResult, - RESTPatchAPIGuildStickerJSONBody, - RESTPatchAPIGuildStickerResult, - RESTPatchAPIGuildTemplateJSONBody, - RESTPatchAPIGuildTemplateResult, - RESTPatchAPIGuildVoiceStateUserJSONBody, - RESTPatchAPIGuildWelcomeScreenJSONBody, - RESTPatchAPIGuildWelcomeScreenResult, - RESTPatchAPIGuildWidgetSettingsJSONBody, - RESTPatchAPIGuildWidgetSettingsResult, - RESTPostAPIAutoModerationRuleJSONBody, - RESTPostAPIAutoModerationRuleResult, - RESTPostAPIGuildChannelJSONBody, - RESTPostAPIGuildChannelResult, - RESTPostAPIGuildEmojiJSONBody, - RESTPostAPIGuildEmojiResult, - RESTPostAPIGuildPruneJSONBody, - RESTPostAPIGuildPruneResult, - RESTPostAPIGuildRoleJSONBody, - RESTPostAPIGuildRoleResult, - RESTPostAPIGuildScheduledEventJSONBody, - RESTPostAPIGuildScheduledEventResult, - RESTPostAPIGuildsJSONBody, - RESTPostAPIGuildsMFAResult, - RESTPostAPIGuildsResult, - RESTPostAPIGuildTemplatesJSONBody, - RESTPostAPIGuildTemplatesResult, - RESTPutAPIGuildBanJSONBody, - RESTPutAPIGuildTemplateSyncResult, - Snowflake, +import { + Routes, + type GuildMFALevel, + type GuildWidgetStyle, + type RESTGetAPIAuditLogQuery, + type RESTGetAPIAuditLogResult, + type RESTGetAPIAutoModerationRuleResult, + type RESTGetAPIAutoModerationRulesResult, + type RESTGetAPIGuildBanResult, + type RESTGetAPIGuildBansQuery, + type RESTGetAPIGuildBansResult, + type RESTGetAPIGuildChannelsResult, + type RESTGetAPIGuildEmojiResult, + type RESTGetAPIGuildEmojisResult, + type RESTGetAPIGuildIntegrationsResult, + type RESTGetAPIGuildInvitesResult, + type RESTGetAPIGuildMemberResult, + type RESTGetAPIGuildMembersQuery, + type RESTGetAPIGuildMembersResult, + type RESTGetAPIGuildMembersSearchQuery, + type RESTGetAPIGuildMembersSearchResult, + type RESTGetAPIGuildOnboardingResult, + type RESTGetAPIGuildPreviewResult, + type RESTGetAPIGuildPruneCountQuery, + type RESTGetAPIGuildPruneCountResult, + type RESTGetAPIGuildResult, + type RESTGetAPIGuildRolesResult, + type RESTGetAPIGuildScheduledEventQuery, + type RESTGetAPIGuildScheduledEventResult, + type RESTGetAPIGuildScheduledEventUsersQuery, + type RESTGetAPIGuildScheduledEventUsersResult, + type RESTGetAPIGuildScheduledEventsQuery, + type RESTGetAPIGuildScheduledEventsResult, + type RESTGetAPIGuildStickerResult, + type RESTGetAPIGuildStickersResult, + type RESTGetAPIGuildTemplatesResult, + type RESTGetAPIGuildThreadsResult, + type RESTGetAPIGuildVanityUrlResult, + type RESTGetAPIGuildVoiceRegionsResult, + type RESTGetAPIGuildWebhooksResult, + type RESTGetAPIGuildWelcomeScreenResult, + type RESTGetAPIGuildWidgetImageResult, + type RESTGetAPIGuildWidgetJSONResult, + type RESTGetAPIGuildWidgetSettingsResult, + type RESTGetAPITemplateResult, + type RESTPatchAPIAutoModerationRuleJSONBody, + type RESTPatchAPIAutoModerationRuleResult, + type RESTPatchAPIGuildChannelPositionsJSONBody, + type RESTPatchAPIGuildEmojiJSONBody, + type RESTPatchAPIGuildEmojiResult, + type RESTPatchAPIGuildJSONBody, + type RESTPatchAPIGuildMemberJSONBody, + type RESTPatchAPIGuildMemberResult, + type RESTPatchAPIGuildResult, + type RESTPatchAPIGuildRoleJSONBody, + type RESTPatchAPIGuildRolePositionsJSONBody, + type RESTPatchAPIGuildRolePositionsResult, + type RESTPatchAPIGuildRoleResult, + type RESTPatchAPIGuildScheduledEventJSONBody, + type RESTPatchAPIGuildScheduledEventResult, + type RESTPatchAPIGuildStickerJSONBody, + type RESTPatchAPIGuildStickerResult, + type RESTPatchAPIGuildTemplateJSONBody, + type RESTPatchAPIGuildTemplateResult, + type RESTPatchAPIGuildVoiceStateCurrentMemberJSONBody, + type RESTPatchAPIGuildVoiceStateCurrentMemberResult, + type RESTPatchAPIGuildVoiceStateUserJSONBody, + type RESTPatchAPIGuildWelcomeScreenJSONBody, + type RESTPatchAPIGuildWelcomeScreenResult, + type RESTPatchAPIGuildWidgetSettingsJSONBody, + type RESTPatchAPIGuildWidgetSettingsResult, + type RESTPostAPIAutoModerationRuleJSONBody, + type RESTPostAPIAutoModerationRuleResult, + type RESTPostAPIGuildChannelJSONBody, + type RESTPostAPIGuildChannelResult, + type RESTPostAPIGuildEmojiJSONBody, + type RESTPostAPIGuildEmojiResult, + type RESTPostAPIGuildPruneJSONBody, + type RESTPostAPIGuildPruneResult, + type RESTPostAPIGuildRoleJSONBody, + type RESTPostAPIGuildRoleResult, + type RESTPostAPIGuildScheduledEventJSONBody, + type RESTPostAPIGuildScheduledEventResult, + type RESTPostAPIGuildStickerFormDataBody, + type RESTPostAPIGuildStickerResult, + type RESTPostAPIGuildTemplatesJSONBody, + type RESTPostAPIGuildTemplatesResult, + type RESTPostAPIGuildsJSONBody, + type RESTPostAPIGuildsMFAResult, + type RESTPostAPIGuildsResult, + type RESTPutAPIGuildBanJSONBody, + type RESTPutAPIGuildTemplateSyncResult, + type Snowflake, } from 'discord-api-types/v10'; export class GuildsAPI { @@ -1229,4 +1230,15 @@ 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 + * @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; + } } diff --git a/packages/discord.js/typings/index.d.ts b/packages/discord.js/typings/index.d.ts index ef0e3e435879..91fd348be571 100644 --- a/packages/discord.js/typings/index.d.ts +++ b/packages/discord.js/typings/index.d.ts @@ -157,6 +157,10 @@ import { ImageFormat, GuildMemberFlags, RESTGetAPIGuildThreadsResult, + RESTGetAPIGuildOnboardingResult, + APIGuildOnboardingPrompt, + APIGuildOnboardingPromptOption, + GuildOnboardingPromptType, } from 'discord-api-types/v10'; import { ChildProcess } from 'node:child_process'; import { EventEmitter } from 'node:events'; @@ -1568,7 +1572,7 @@ export class GuildMember extends PartialTextBasedChannel(Base) { } export class GuildOnboarding extends Base { - private constructor(client: Client, data: any); + private constructor(client: Client, data: RESTGetAPIGuildOnboardingResult); public get guild(): Guild; public guildId: Snowflake; public prompts: Collection; @@ -1577,7 +1581,7 @@ export class GuildOnboarding extends Base { } export class GuildOnboardingPrompt extends Base { - private constructor(client: Client, data: any, guildId: Snowflake); + private constructor(client: Client, data: APIGuildOnboardingPrompt, guildId: Snowflake); public id: Snowflake; public get guild(): Guild; public guildId: Snowflake; @@ -1586,11 +1590,11 @@ export class GuildOnboardingPrompt extends Base { public singleSelect: boolean; public required: boolean; public inOnboarding: boolean; - public type: any; + public type: GuildOnboardingPromptType; } export class GuildOnboardingPromptOption extends Base { - private constructor(client: Client, data: any, guildId: Snowflake); + private constructor(client: Client, data: APIGuildOnboardingPromptOption, guildId: Snowflake); public id: Snowflake; public get guild(): Guild; public guildId: Snowflake; diff --git a/packages/discord.js/typings/index.test-d.ts b/packages/discord.js/typings/index.test-d.ts index 552d39986b47..d3cd2f29931e 100644 --- a/packages/discord.js/typings/index.test-d.ts +++ b/packages/discord.js/typings/index.test-d.ts @@ -171,6 +171,7 @@ import { ApplicationCommandSubCommand, ChatInputApplicationCommandData, ApplicationCommandPermissionsManager, + GuildOnboarding, } from '.'; import { expectAssignable, expectNotAssignable, expectNotType, expectType } from 'tsd'; import type { ContextMenuCommandBuilder, SlashCommandBuilder } from '@discordjs/builders'; @@ -2267,3 +2268,8 @@ client.on('guildAuditLogEntryCreate', (auditLogEntry, guild) => { }); expectType>(guildMember.flags); + +{ + const onboarding = await guild.fetchOnboarding(); + expectType(onboarding); +}