fix server showing error on invalid server
Some checks failed
Deploy App / docker (ubuntu-latest) (push) Has been cancelled

This commit is contained in:
Lee 2024-04-16 18:58:10 +01:00
parent 15bc010394
commit 50f2e26187
2 changed files with 5 additions and 5 deletions

@ -14,7 +14,7 @@ type Params = {
export async function generateMetadata({ params: { id } }: Params): Promise<Metadata> { export async function generateMetadata({ params: { id } }: Params): Promise<Metadata> {
const player = await getData(id); const player = await getData(id);
if (!player) { if (player == null) {
return generateEmbed({ title: "Unknown Player", description: "Player not found" }); return generateEmbed({ title: "Unknown Player", description: "Player not found" });
} }

@ -19,7 +19,7 @@ type Params = {
export async function generateMetadata({ params: { platform, hostname } }: Params): Promise<Metadata> { export async function generateMetadata({ params: { platform, hostname } }: Params): Promise<Metadata> {
const server = await getData(platform, hostname); const server = await getData(platform, hostname);
if (!server) { if (server == null) {
return generateEmbed({ title: "Unknown Server", description: "Server not found" }); return generateEmbed({ title: "Unknown Server", description: "Server not found" });
} }
@ -27,8 +27,8 @@ export async function generateMetadata({ params: { platform, hostname } }: Param
let favicon = null; // Server favicon let favicon = null; // Server favicon
// Java specific
if (platform === ServerPlatform.Java) { if (platform === ServerPlatform.Java) {
// Java specific
const javaServer = server as JavaMinecraftServer; const javaServer = server as JavaMinecraftServer;
favicon = javaServer.favicon && javaServer.favicon.url; favicon = javaServer.favicon && javaServer.favicon.url;
} }
@ -60,8 +60,8 @@ export default async function Page({ params: { platform, hostname } }: Params) {
let favicon = null; // Server favicon let favicon = null; // Server favicon
if (platform === ServerPlatform.Java) { // Java specific
// Java specific if (server && platform === ServerPlatform.Java) {
const javaServer = server as JavaMinecraftServer; const javaServer = server as JavaMinecraftServer;
favicon = javaServer.favicon && javaServer.favicon.url; favicon = javaServer.favicon && javaServer.favicon.url;
} }