/*
----------------------------------
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 getRank(player) {
  const prefix = config.sudo.rank.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.rank.default;
  } else {
    rank = ranks.join("§r");
  }

  return rank;
}

export { getRank };
