export const getForgeDownload = async (version: string, latest?: boolean) => {
  const res = await fetch(
    `https://files.minecraftforge.net/net/minecraftforge/forge/promotions_slim.json`,
  );

  const { promos } = await res.json();

  // https://maven.minecraftforge.net/net/minecraftforge/forge/1.20.1-47.2.1/forge-1.20.1-47.2.1-installer.jar

  let loaderVersion = promos[`${version}-${latest ? "latest" : "recommended"}`];

  if (!loaderVersion) loaderVersion = promos[`${version}-latest`];

  return `https://maven.minecraftforge.net/net/minecraftforge/forge/${version}-${loaderVersion}/forge-${version}-${loaderVersion}-installer.jar`;
};
