diff --git a/Lib/src/lib/restfulmc.ts b/Lib/src/lib/restfulmc.ts index 9aaf0b4..c0030d8 100644 --- a/Lib/src/lib/restfulmc.ts +++ b/Lib/src/lib/restfulmc.ts @@ -55,3 +55,26 @@ export const getMinecraftServer = ( } }); }; + +/** + * Check if the server with the + * given hostname is blocked by Mojang. + * + * @param hostname the server hostname to check + * @returns the promised blocked status + */ +export const isMojangBlocked = (hostname: string): Promise => { + return new Promise(async (resolve, reject) => { + const response: Response = await fetch( + `${ENDPOINT}/server/blocked/${hostname}` + ); // Request the server + const json: any = await response.json(); + + // Resolve the blocked status + if (response.ok) { + resolve(json.blocked as boolean); + } else { + reject(json as ErrorResponse); // The request failed + } + }); +};