Skip to content

Commit

Permalink
chore: add Membership Screening
Browse files Browse the repository at this point in the history
  • Loading branch information
vladfrangu committed Dec 28, 2020
1 parent 0f37235 commit cd90bd1
Show file tree
Hide file tree
Showing 3 changed files with 84 additions and 2 deletions.
55 changes: 53 additions & 2 deletions v8/payloads/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ export const enum GuildFeature {
*/
COMMERCE = 'COMMERCE',
/**
* Guild can enable welcome screen and discovery, and receives community updates
* Guild can enable welcome screen, Membership Screening and discovery, and receives community updates
*/
COMMUNITY = 'COMMUNITY',
/**
* Guild is lurkable and able to be discovered in the directory
* Guild is able to be discovered in the directory
*/
DISCOVERABLE = 'DISCOVERABLE',
/**
Expand Down Expand Up @@ -430,6 +430,14 @@ export const enum GuildFeature {
* Guild has enabled the welcome screen
*/
WELCOME_SCREEN_ENABLED = 'WELCOME_SCREEN_ENABLED',
/**
* Guild has enabled Membership Screening
*/
MEMBER_VERIFICATION_GATE_ENABLED = 'MEMBER_VERIFICATION_GATE_ENABLED',
/**
* Guild can be previewed before joining via Membership Screening or the directory
*/
PREVIEW_ENABLED = 'PREVIEW_ENABLED',
}

/**
Expand Down Expand Up @@ -802,3 +810,46 @@ export interface APIGuildWelcomeScreenChannel {
*/
emoji_name: string | null;
}

export interface APIGuildMembershipScreening {
/**
* When the fields were last updated
*/
version: string;
/**
* The steps in the screening form
*/
form_fields: APIGuildMembershipScreeningField[];
/**
* The server description shown in the screening form
*/
description: string | null;
}

// TODO: make this a union based on the type in the future, when new types are added

export interface APIGuildMembershipScreeningField {
/**
* The type of field
*/
field_type: MembershipScreeningFieldType;
/**
* The title of the field
*/
label: string;
/**
* The list of rules
*/
values?: string[];
/**
* Whether the user has to fill out this field
*/
required: boolean;
}

export const enum MembershipScreeningFieldType {
/**
* Server Rules
*/
TERMS = 'TERMS',
}
20 changes: 20 additions & 0 deletions v8/rest/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import type {
APIGuild,
APIGuildIntegration,
APIGuildMember,
APIGuildMembershipScreening,
APIGuildPreview,
APIGuildWidget,
APIGuildWidgetSettings,
Expand Down Expand Up @@ -749,3 +750,22 @@ export interface RESTGetAPIGuildWidgetImageQuery {
* a buffer of sorts (depends if in browser or on node.js/deno).
*/
export type RESTGetAPIGuildWidgetImageResult = ArrayBuffer;

export type RESTGetAPIGuildMemberVerificationResult = APIGuildMembershipScreening;

export interface RESTPatchAPIGuildMemberVerificationJSONBody {
/**
* Whether Membership Screening is enabled
*/
enabled?: boolean;
/**
* Array of field objects serialized in a string
*/
form_fields?: string;
/**
* The server description to show in the screening form
*/
description?: string | null;
}

export type RESTPatchAPIGuildMemberVerificationResult = APIGuildMembershipScreening;
11 changes: 11 additions & 0 deletions v8/rest/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -572,6 +572,7 @@ export const Routes = {
},

/**
* Route for:
* - PATCH `/applications/{application.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/commands/{command.id}`
*/
Expand All @@ -589,6 +590,7 @@ export const Routes = {
},

/**
* Route for:
* - PATCH `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
* - DELETE `/applications/{application.id}/guilds/{guild.id}/commands/{command.id}`
*/
Expand All @@ -603,6 +605,15 @@ export const Routes = {
interactionCallback(interactionID: string, interactionToken: string) {
return `/interactions/${interactionID}/${interactionToken}/callback`;
},

/**
* Route for:
* - GET `/guilds/{guild.id}/member-verification`
* - PATCH `/guilds/{guild.id}/member-verification`
*/
guildMemberVerification(guildID: string) {
return `/guilds/${guildID}/member-verification`;
},
};

export const OAuth2Routes = {
Expand Down

0 comments on commit cd90bd1

Please sign in to comment.