import { ImageResponse } from "@vercel/og"; import { scoresaberService } from "@ssr/common/service/impl/scoresaber"; import React from "react"; import { formatNumberWithCommas, formatPp } from "@ssr/common/utils/number-utils"; export class ImageService { /** * Generates the OpenGraph image for the player * * @param id the player's id */ public static async generatePlayerImage(id: string) { const player = await scoresaberService.lookupPlayer(id); if (player == undefined) { return undefined; } return new ImageResponse( (
Player's Avatar

{player.name}

{formatPp(player.pp)}pp

#{formatNumberWithCommas(player.rank)}

{/* eslint-disable-next-line @next/next/no-img-element */} Player's Country

#{formatNumberWithCommas(player.countryRank)}

), { width: 1200, height: 630, emoji: "twemoji", } ); } }