From 88cb68dea4dee47246a3fef93288e0f2154095ef Mon Sep 17 00:00:00 2001 From: Skillz Date: Fri, 17 Jul 2020 08:09:40 -0400 Subject: [PATCH] fix #70 --- handlers/guild.ts | 19 +++++++++---------- types/channel.ts | 2 +- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/handlers/guild.ts b/handlers/guild.ts index b6102ae3a..aff3b6b8a 100644 --- a/handlers/guild.ts +++ b/handlers/guild.ts @@ -93,23 +93,22 @@ export function guildBannerURL( export async function createGuildChannel( guild: Guild, name: string, - options: CreateChannelOptions, + options?: CreateChannelOptions, ) { if (!botHasPermission(guild.id, [Permissions.MANAGE_CHANNELS])) { throw new Error(Errors.MISSING_MANAGE_CHANNELS); } + const result = (await RequestManager.post(endpoints.GUILD_CHANNELS(guild.id), { - name, - permission_overwrites: options?.permission_overwrites - ? options.permission_overwrites.map((perm) => ({ - ...perm, - allow: perm.allow.map((p) => Permissions[p]), - deny: perm.deny.map((p) => Permissions[p]), - })) - : undefined, ...options, - type: options.type ? ChannelTypes[options.type] : undefined, + name, + permission_overwrites: options?.permission_overwrites?.map((perm) => ({ + ...perm, + allow: perm.allow.map((p) => Permissions[p]), + deny: perm.deny.map((p) => Permissions[p]), + })), + type: options?.type || ChannelTypes.GUILD_TEXT, })) as ChannelCreatePayload; const channel = createChannel(result); diff --git a/types/channel.ts b/types/channel.ts index 57f9b5b87..af74f2844 100644 --- a/types/channel.ts +++ b/types/channel.ts @@ -76,7 +76,7 @@ export interface ChannelCreatePayload extends Base_Channel_Create { export interface CreateChannelOptions extends Base_Channel_Create { /** The type of the channel */ - type: ChannelTypes; + type?: ChannelTypes; /** Explicit permission overwrites for members and roles */ permission_overwrites?: Overwrite[]; }