Weird PermissionOverwrite triggers ChannelUpdate for every guildChannel

Hello. I've setup a listener to the event ChannelUpdate that should handle permissionOverwrites modifications. But I some weird trigger that concerns every channels.

I've node v16.14.2, djs 13.9.0

Here's the code :
client.on("channelUpdate", onChannelUpdate);

//in another file
export const onChannelUpdate = async (oldChannel, newChannel) => {
  //handle channel update event
  ...
  //basic operations
  const logChannel = await getLogChannel(commons, newChannel); //get logChannelId
  const embed = setupEmbed("DARK_AQUA", chnUp, newChannel, "tag"); //setup embed
  const chnLog = await fetchAuditLog(oldChannel.guild, "CHANNEL_UPDATE", 1); //get auditLog

  //check for permission overwrite
  const oldOverwrite = oldChannel.permissionOverwrites.cache;
  const newOverwrite = newChannel.permissionOverwrites.cache;
  const diffOverwrite = oldOverwrite.difference(newOverwrite);

  if (diffOverwrite.size !== 0) {
    //add/removed permission orverwrite
    ...
  }
  if (!oldOverwrite.equals(newOverwrite)) {
    //if permissionOverwrite changed without add/remove role/user
    //sort by id
    oldOverwrite.sort((a, b) => a.id - b.id);
    newOverwrite.sort((a, b) => a.id - b.id);

    //find PO difference by couple
    const diff = oldOverwrite.reduce((acc, cur) => {
      const newPO = newOverwrite.get(cur.id);
      if (
        cur.deny.bitfield !== newPO.deny.bitfield ||
        cur.allow.bitfield !== newPO.allow.bitfield
      )
        return [...acc, [cur, newPO]];
      else return acc;
    }, []);

    //get bit diff, write it along channel.toString()
    const modifs = await diff.reduce(async (acc, cur) => {
    ...
    }, "");

    if (modifs.length !== 0) {
      embed.addField(chnUp.text, modifs); //add modifs in embed
      finishEmbed(chnUp, null, embed, logChannel); //send log message
    }
    else console.log("channelUpdate permOverwrite noModifs", new Date(), newChannel.name, diff, [modifs]);
    return;
  }
unknown.png
Was this page helpful?