From dcf8ddf25b26a9c72dbb1b5712503e6d5e516ad1 Mon Sep 17 00:00:00 2001 From: Sugden <28943913+NotSugden@users.noreply.github.com> Date: Fri, 2 Oct 2020 11:00:18 +0100 Subject: [PATCH] fix(RESTPostAPIGuildsJSONBody): use correct types (#22) Co-authored-by: Vlad Frangu --- v6/rest/guild.ts | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/v6/rest/guild.ts b/v6/rest/guild.ts index e5e2395c..077811de 100644 --- a/v6/rest/guild.ts +++ b/v6/rest/guild.ts @@ -7,6 +7,7 @@ import type { APIGuildPreview, APIGuildWidget, APIInvite, + APIOverwrite, APIRole, APIVoiceRegion, GuildDefaultMessageNotifications, @@ -17,13 +18,25 @@ import type { IntegrationExpireBehavior, } from '../payloads'; +export type APIGuildCreateOverwrite = Pick & { + id: number | string; + allow: number | string; + deny: number | string; +}; + export type APIGuildCreatePartialChannel = Partial< - Pick< - APIChannel, - 'type' | 'permission_overwrites' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user' | 'parent_id' - > -> & - Required>; + Pick +> & { + name: string; + id?: number | string; + parent_id?: number | string; + permission_overwrites?: APIGuildCreateOverwrite[]; +}; + +export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody { + id: number | string; + permissions?: number; +} /** * https://discord.com/developers/docs/resources/guild#create-guild @@ -35,11 +48,11 @@ export interface RESTPostAPIGuildsJSONBody { verification_level?: GuildVerificationLevel; default_message_notifications?: GuildDefaultMessageNotifications; explicit_content_filter?: GuildExplicitContentFilter; - roles?: APIRole[]; + roles?: APIGuildCreateRole[]; channels?: APIGuildCreatePartialChannel[]; - afk_channel_id?: string; + afk_channel_id?: number | string; afk_timeout?: number; - system_channel_id?: string; + system_channel_id?: number | string; } export type RESTPostAPIGuildsResult = APIGuild; @@ -97,7 +110,13 @@ export type RESTGetAPIGuildChannelsResult = APIChannel[]; /** * https://discord.com/developers/docs/resources/guild#create-guild-channel */ -export type RESTPostAPIGuildChannelJSONBody = APIGuildCreatePartialChannel; +export type RESTPostAPIGuildChannelJSONBody = Partial< + Pick< + APIChannel, + 'type' | 'permission_overwrites' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user' | 'parent_id' + > +> & + Required>; export type RESTPostAPIGuildChannelResult = APIChannel;