/*
----------------------------------
Creator: Mafly
Discord:
https://discord.gg/BUFxackwWb
Youtube: MaFly
https://www.youtube.com/c/MaFly16

Website:
https://mcblibrary.com/user/mafly
----------------------------------
*/

import { config } from "../command/config.js";

function getClan(player) {
  const prefix = config.sudo.clan.prefix;

  const ranks = player
    .getTags()
    .filter((v) => v.startsWith(prefix))
    .map((v) => v.substring(prefix.length))
    .filter((x) => x);

  let rank;
  if (ranks.length === 0) {
    rank = config.sudo.clan.default;
  } else {
    rank = ranks.join("§r");
  }

  return rank;
}

export { getClan };
