Hi, I've been having an issue when trying to take the permissionOverwrites from one channel and trying to create a new channel with the same overwrites. I get no errors when I run the command, and the bot creates the overwrites in the new channel (as displayed in the screenshot), but it never ends up configuring the allows and denys. When logging o[1] it returns all the permission overwrites and their bitfields correctly as well.
const overwrites = Array.from(interaction.channel.permissionOverwrites.cache).map(o => {
let allow = o[1].allow ? Number(o[1].allow) : 0;
let deny = o[1].deny ? Number(o[1].deny) : 0;
console.log(o[1]);
console.log(o[0]);
return {
id: o[0],
type: o[1].type,
allow: allow,
deny: deny
};
});
const newChannel = await i.guild.channels.create({ name: i.channel.name, topic: i.channel.topic, parent: i.channel.parent, position: i.channel.position });
for (const overwrite of overwrites) {
const role = newChannel.guild.roles.cache.get(overwrite.id);
if(role) {
newChannel.permissionOverwrites.create(role, {
allow: Number(overwrite.allow),
deny: Number(overwrite.deny),
})
} else if(overwrite.type === "member") {
newChannel.permissionOverwrites.create(overwrite.id, {
allow: Number(overwrite.allow),
deny: Number(overwrite.deny),
})
}
}