This commit is contained in:
Skillz
2020-07-17 08:09:40 -04:00
parent 391253e92c
commit 88cb68dea4
2 changed files with 10 additions and 11 deletions

View File

@@ -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);

View File

@@ -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[];
}