fix server embed
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 56s

This commit is contained in:
Lee 2024-04-17 17:41:55 +01:00
parent 31accee7f7
commit 77d03e79e9
2 changed files with 8 additions and 1 deletions

View File

@ -16,6 +16,7 @@ type Params = {
export async function generateMetadata({ params: { id } }: Params): Promise<Metadata> {
try {
// No id provided
if (!id || id.length === 0) {
return generateEmbed({
title: "Player Lookup",
@ -35,6 +36,7 @@ export async function generateMetadata({ params: { id } }: Params): Promise<Meta
image: headPartUrl,
});
} catch (err) {
// An error occurred
return generateEmbed({
title: "Player Not Found",
description: (err as McUtilsAPIError).message,

View File

@ -52,12 +52,14 @@ function checkPlatform(platform: ServerPlatform): boolean {
export async function generateMetadata({ params: { platform, hostname } }: Params): Promise<Metadata> {
try {
if (checkPlatform(platform) === false) {
// Invalid platform
return generateEmbed({
title: "Server Not Found",
description: "Invalid platform",
});
}
if (!hostname || hostname.length === 0) {
// No hostname
return generateEmbed({
title: "Server Lookup",
description: `Click to lookup a ${capitalizeFirstLetter(platform)} server.`,
@ -68,7 +70,9 @@ export async function generateMetadata({ params: { platform, hostname } }: Param
const favicon = server ? getFavicon(platform, server) : undefined;
const description = `Hostname: ${serverHostname}\n${players.online}/${players.max} players online\n\nClick to view more information about the player.`;
let description = `Hostname:${serverHostname}\n`;
description += `${players.online}/${players.max} players online\n\n`;
description += "Click to view more information about the server.";
return generateEmbed({
title: `${hostname}`,
@ -76,6 +80,7 @@ export async function generateMetadata({ params: { platform, hostname } }: Param
image: favicon,
});
} catch (err) {
// An error occurred
return generateEmbed({
title: "Server Not Found",
description: (err as McUtilsAPIError).message,