await channel.permissionOverwrites.set([
...(await tempDb.club_roles).map(id => ({ id, allow: ['VIEW_CHANNEL'] })),
...channel.permissionOverwrites.cache.map(po => {
let allow = po.allow.toArray(), deny = po.deny.toArray();
if (tempDb.club_roles.includes(po.id)) {
if (deny.includes('VIEW_CHANNEL')) {
deny.splice(deny.indexOf('VIEW_CHANNEL'), 1);
po.deny = new Discord.Permissions(deny);
}
if (!allow.includes('VIEW_CHANNEL')) {
allow.push('VIEW_CHANNEL');
po.allow = new Discord.Permissions(allow);
}
}
return po;
})
]);
Is there a better way to write this while it keeps on:
- creating the club roles (array["123", "123"]) as overwrites when they are not yet overwrites in the channel
- only update the VIEW_CHANNEL overwrite, for multiple roles in the channel.
- all other roles and perms other than VIEW_CHANNEL for the selected roles, stay untouched?
