async function requireOverwritePermissions(
  guildOrId,
  overwrites,
) {
  let requiredPerms = new Set([
    "MANAGE_CHANNELS",
  ]);
  overwrites?.forEach((overwrite) => {
    overwrite.allow.forEach(requiredPerms.add, requiredPerms);
    overwrite.deny.forEach(requiredPerms.add, requiredPerms);
  });
  // MANAGE_ROLES permission can only be set by administrators
  if (requiredPerms.has("MANAGE_ROLES")) {
    requiredPerms = new Set([
      "ADMINISTRATOR",
    ]);
  }
  await requireGuildPermissions(guildOrId, botId, [
    ...requiredPerms,
  ]);
}
/** Internal function to check if the bot has the permissions to set these overwrites */
Internal function to check if the bot has the permissions to set these overwrites
Internal function to check if the bot has the permissions to set these overwrites
async function requireOverwritePermissions(
  guildOrId,
  overwrites,
) {
  let requiredPerms = new Set([
    "MANAGE_CHANNELS",
  ]);
  overwrites?.forEach((overwrite) => {
    overwrite.allow.forEach(requiredPerms.add, requiredPerms);
    overwrite.deny.forEach(requiredPerms.add, requiredPerms);
  });
  if (requiredPerms.has("MANAGE_ROLES")) {
    requiredPerms = new Set([
      "ADMINISTRATOR",
    ]);
  }
  await requireGuildPermissions(guildOrId, botId, [
    ...requiredPerms,
  ]);
}
async function requireOverwritePermissions ( guildOrId , overwrites , ) { let requiredPerms = new Set ( [ "MANAGE_CHANNELS" , ] ) ; overwrites ?. forEach ( ( overwrite ) => { overwrite . allow . forEach ( requiredPerms . add , requiredPerms ) ; overwrite . deny . forEach ( requiredPerms . add , requiredPerms ) ; } ) ; if ( requiredPerms . has ( "MANAGE_ROLES" ) ) { requiredPerms = new Set ( [ "ADMINISTRATOR" , ] ) ; } await requireGuildPermissions ( guildOrId , botId , [ ... requiredPerms , ] ) ; }
Internal function to check if the bot has the permissions to set these overwrites
Internal function to check if the bot has the permissions to set these overwrites
// MANAGE_ROLES permission can only be set by administrators