mirror of
https://github.com/discordeno/discordeno.git
synced 2026-06-03 01:10:07 +00:00
fix #70
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user