Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(RESTPostAPIGuildsJSONBody): use correct types #22

Merged
merged 4 commits into from
Oct 2, 2020
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions v6/rest/guild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import type {
APIGuildPreview,
APIGuildWidget,
APIInvite,
APIOverwrite,
APIRole,
APIVoiceRegion,
GuildDefaultMessageNotifications,
Expand All @@ -17,13 +18,25 @@ import type {
IntegrationExpireBehavior,
} from '../payloads';

export type APIGuildCreateOverwrite = Pick<APIOverwrite, 'type'> & {
id: string | number;
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved
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<APIChannel, 'name'>>;
Pick<APIChannel, 'type' | 'topic' | 'nsfw' | 'bitrate' | 'user_limit' | 'rate_limit_per_user'>
> & {
name: string;
id?: number;
parent_id?: number;
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved
permission_overwrites?: APIGuildCreateOverwrite[];
};

export interface APIGuildCreateRole extends RESTPostAPIGuildRoleJSONBody {
id?: number;
permissions?: number;
}

/**
* https://discord.com/developers/docs/resources/guild#create-guild
Expand All @@ -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;
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved
afk_timeout?: number;
system_channel_id?: string;
system_channel_id?: number;
vladfrangu marked this conversation as resolved.
Show resolved Hide resolved
}

export type RESTPostAPIGuildsResult = APIGuild;
Expand Down Expand Up @@ -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<Pick<APIChannel, 'name'>>;

export type RESTPostAPIGuildChannelResult = APIChannel;

Expand Down