fix server embed
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 56s
All checks were successful
Deploy App / docker (ubuntu-latest) (push) Successful in 56s
This commit is contained in:
parent
31accee7f7
commit
77d03e79e9
@ -16,6 +16,7 @@ type Params = {
|
|||||||
|
|
||||||
export async function generateMetadata({ params: { id } }: Params): Promise<Metadata> {
|
export async function generateMetadata({ params: { id } }: Params): Promise<Metadata> {
|
||||||
try {
|
try {
|
||||||
|
// No id provided
|
||||||
if (!id || id.length === 0) {
|
if (!id || id.length === 0) {
|
||||||
return generateEmbed({
|
return generateEmbed({
|
||||||
title: "Player Lookup",
|
title: "Player Lookup",
|
||||||
@ -35,6 +36,7 @@ export async function generateMetadata({ params: { id } }: Params): Promise<Meta
|
|||||||
image: headPartUrl,
|
image: headPartUrl,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// An error occurred
|
||||||
return generateEmbed({
|
return generateEmbed({
|
||||||
title: "Player Not Found",
|
title: "Player Not Found",
|
||||||
description: (err as McUtilsAPIError).message,
|
description: (err as McUtilsAPIError).message,
|
||||||
|
@ -52,12 +52,14 @@ function checkPlatform(platform: ServerPlatform): boolean {
|
|||||||
export async function generateMetadata({ params: { platform, hostname } }: Params): Promise<Metadata> {
|
export async function generateMetadata({ params: { platform, hostname } }: Params): Promise<Metadata> {
|
||||||
try {
|
try {
|
||||||
if (checkPlatform(platform) === false) {
|
if (checkPlatform(platform) === false) {
|
||||||
|
// Invalid platform
|
||||||
return generateEmbed({
|
return generateEmbed({
|
||||||
title: "Server Not Found",
|
title: "Server Not Found",
|
||||||
description: "Invalid platform",
|
description: "Invalid platform",
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (!hostname || hostname.length === 0) {
|
if (!hostname || hostname.length === 0) {
|
||||||
|
// No hostname
|
||||||
return generateEmbed({
|
return generateEmbed({
|
||||||
title: "Server Lookup",
|
title: "Server Lookup",
|
||||||
description: `Click to lookup a ${capitalizeFirstLetter(platform)} server.`,
|
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 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({
|
return generateEmbed({
|
||||||
title: `${hostname}`,
|
title: `${hostname}`,
|
||||||
@ -76,6 +80,7 @@ export async function generateMetadata({ params: { platform, hostname } }: Param
|
|||||||
image: favicon,
|
image: favicon,
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
// An error occurred
|
||||||
return generateEmbed({
|
return generateEmbed({
|
||||||
title: "Server Not Found",
|
title: "Server Not Found",
|
||||||
description: (err as McUtilsAPIError).message,
|
description: (err as McUtilsAPIError).message,
|
||||||
|
Loading…
Reference in New Issue
Block a user