From 6d3663ccb981b0a17e4ceccf3890bb6a09d8c8c0 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 17 Apr 2024 17:26:10 +0100 Subject: [PATCH] update embeds --- src/app/(pages)/player/[[...id]]/page.tsx | 6 ++++++ .../(pages)/server/[platform]/[[...hostname]]/page.tsx | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app/(pages)/player/[[...id]]/page.tsx b/src/app/(pages)/player/[[...id]]/page.tsx index 32bda6f..ff7e82f 100644 --- a/src/app/(pages)/player/[[...id]]/page.tsx +++ b/src/app/(pages)/player/[[...id]]/page.tsx @@ -16,6 +16,12 @@ type Params = { export async function generateMetadata({ params: { id } }: Params): Promise { try { + if (!id || id.length === 0) { + return generateEmbed({ + title: "Player Not Found", + description: "Click to lookup a player.", + }); + } const player = await getPlayer(id); const { username, uniqueId, skin } = player; diff --git a/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx b/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx index 6064cda..974c712 100644 --- a/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx +++ b/src/app/(pages)/server/[platform]/[[...hostname]]/page.tsx @@ -57,6 +57,12 @@ export async function generateMetadata({ params: { platform, hostname } }: Param description: "Invalid platform", }); } + if (!hostname || hostname.length === 0) { + return generateEmbed({ + title: "Server Lookup", + description: `Click to lookup a ${capitalizeFirstLetter(platform)} server.`, + }); + } const server = await getServer(platform, hostname); const { hostname: serverHostname, players } = server as CachedJavaMinecraftServer | CachedBedrockMinecraftServer; @@ -80,7 +86,7 @@ export async function generateMetadata({ params: { platform, hostname } }: Param export default async function Page({ params: { platform, hostname } }: Params): Promise { let error: string | undefined = undefined; // The error to display let server: CachedJavaMinecraftServer | CachedBedrockMinecraftServer | undefined = undefined; // The server to display - let invalidPlatform = checkPlatform(platform) === false; + let invalidPlatform = checkPlatform(platform) === false; // Whether the platform is invalid // Try and get the player to display try {