fix(helpers): when creating/modifying a channel permission_overwrites can omit the allow and deny (#2053)

Clarify that permission_overwrites can omit allow and deny keys when creating/modifying channel/channel ovewrites
This commit is contained in:
LTS20050703
2022-02-19 21:29:12 +07:00
committed by ITOH
parent 79e260892b
commit bea86bb47b
2 changed files with 11 additions and 12 deletions

View File

@@ -22,11 +22,11 @@ export async function createChannel(bot: Bot, guildId: bigint, options?: CreateG
position: options.position,
parent_id: options.parentId?.toString(),
nsfw: options.nsfw,
permission_overwrites: options?.permissionOverwrites?.map((perm) => ({
id: perm.id.toString(),
type: perm.type,
allow: perm.allow ? bot.utils.calculateBits(perm.allow) : "0",
deny: perm.deny ? bot.utils.calculateBits(perm.deny) : "0",
permission_overwrites: options?.permissionOverwrites?.map((overwrite) => ({
id: overwrite.id.toString(),
type: overwrite.type,
allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : null,
deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : null,
})),
type: options?.type || ChannelTypes.GuildText,
reason,

View File

@@ -46,13 +46,12 @@ export async function editChannel(bot: Bot, channelId: bigint, options: ModifyCh
locked: options.locked,
invitable: options.invitable,
permission_overwrites: options.permissionOverwrites
? options.permissionOverwrites?.map((overwrite) => {
return {
...overwrite,
allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : "0",
deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : "0",
};
})
? options.permissionOverwrites?.map((overwrite) => ({
id: overwrite.id.toString(),
type: overwrite.type,
allow: overwrite.allow ? bot.utils.calculateBits(overwrite.allow) : null,
deny: overwrite.deny ? bot.utils.calculateBits(overwrite.deny) : null,
}))
: undefined,
reason,
});