I'm using this code below to edit every new channel or an edited channel to deny SendMessages for Mute-Role, and deny ViewChannel for Prison-Role. However I'm getting this weird error in the attachment I sent, and maybe just maybe because there's a ticket bot that created and deleted some channels so how to remove this error?
const MuteR = "MUTEROLEID"
const PrisonR = "PRISONROLEID"
client.on('channelUpdate', async (oldChannel, newChannel) => {
let role = newChannel.guild.roles.cache.get(MuteR);
await newChannel.permissionOverwrites.edit(role.id, {
SendMessages: false,
}).catch(err => console.log(err));
//
let role2 = newChannel.guild.roles.cache.get(PrisonR);
await newChannel.permissionOverwrites.edit(role2.id, {
ViewChannel: false,
}).catch(err => console.log(err));
});
client.on('channelCreate', async (channel) => {
let role = channel.guild.roles.cache.get(MuteR);
await channel.permissionOverwrites.edit(role.id, {
SendMessages: false,
}).catch(err => console.log(err));
//
let role2 = channel.guild.roles.cache.get(PrisonR);
await channel.permissionOverwrites.edit(role2.id, {
ViewChannel: false,
}).catch(err => console.log(err));
});