mineping/types/lib/bedrock.d.ts

62 lines
1.3 KiB
TypeScript
Raw Normal View History

/**
* @param port The server port (1-65535).
* @param timeout The read/write socket timeout in milliseconds.
*/
export type BedrockPingOptions = {
port?: number & { _brand: "Port" }; // 1-65535
timeout?: number & { _brand: "Timeout" }; // > 0
};
2022-01-10 23:21:47 +03:00
export type BedrockPingResponse = {
edition: string;
name: string;
version: {
protocolVersion: number;
minecraftVersion: string;
};
players: {
online: number;
max: number;
};
serverId: string;
mapName: string;
gameMode: string;
2022-01-10 23:21:47 +03:00
};
/**
* Asynchronously ping Minecraft Bedrock server.
*
2022-01-10 23:21:47 +03:00
* @param host The Bedrock server address.
2023-12-09 22:38:37 +09:00
* @param options The configuration for pinging Minecraft Bedrock server.
*
2022-01-10 23:21:47 +03:00
* ```js
* import { pingBedrock } from '@minescope/mineping';
*
2022-01-10 23:21:47 +03:00
* const data = await pingBedrock('mco.mineplex.com');
* console.log(data);
* ```
*
2022-01-10 23:21:47 +03:00
* The resulting output will resemble:
* ```console
* {
* edition: "MCPE",
* name: "Mineplex",
* version: {
* protocolVersion: 475,
* minecraftVersion: "1.18.0"
* },
* players: {
* online: 5206,
* max: 5207
* },
* serverId: "12345678",
* mapName: "Lobby",
* gameMode: "Survival"
2022-01-10 23:21:47 +03:00
* }
* ```
*/
export function pingBedrock(
host: string,
options?: BedrockPingOptions
): Promise<BedrockPingResponse>;