import { generateEmbed } from "@/common/embed"; import { capitalizeFirstLetter } from "@/common/string-utils"; import { LookupServer } from "@/components/lookup-server"; import { NotFound } from "@/components/not-found"; import { Card } from "@/components/ui/card"; import { getServer } from "mcutils-library"; import JavaMinecraftServer from "mcutils-library/dist/types/server/javaServer"; import { ServerPlatform } from "mcutils-library/dist/types/server/platform"; import { MinecraftServer } from "mcutils-library/dist/types/server/server"; import { Metadata } from "next"; type Params = { params: { platform: ServerPlatform; hostname: string; }; }; export async function generateMetadata({ params: { platform, hostname } }: Params): Promise { const server = await getData(platform, hostname); if (!server) { return generateEmbed({ title: "Unknown Server", description: "Server not found" }); } const { hostname: serverHostname, players } = server; let favicon = null; // Server favicon if (platform === ServerPlatform.Java) { // Java specific const javaServer = server as JavaMinecraftServer; favicon = javaServer.favicon && javaServer.favicon.url; } const description = ` ${capitalizeFirstLetter(platform)} Server Hostname: ${serverHostname} ${players.online}/${players.max} players online`; return generateEmbed({ title: `${serverHostname}`, description: description, image: favicon, }); } async function getData(platform: ServerPlatform, id: string): Promise { console.log(platform, id); try { const cachedServer = await getServer(platform, id); return cachedServer.server; } catch (error) { return null; // Server not found } } export default async function Page({ params: { platform, hostname } }: Params) { const server = await getData(platform, hostname); return (

Lookup a Server

You can enter a server hostname to get information about the server.

{server == null && } {server != null && (

Hostname: {server.hostname}

)}
); }