src/mcsrvstat/base

Types

ConnectionError = object of HttpRequestError
Raised when an attempt to connect with the API has failed. This mainly happens when the user passes an incorrect IP address.
DataError = object of KeyError
An internal exception primarily related to the library itself. Raised when the given key for accessing a particular data is not found.
Mod = object
  name*, version*: string
Represents a mod of a Minecraft server.
NotInitializedError = object of KeyError
Raised when the data required is missing from an instance of the Server object. This typically happens when Server.refreshData() has not been executed anywhere before interacting with the package.
Platform {.pure.} = enum
  JAVA, BEDROCK
Represents the platform / edition of a Minecraft server.
Player = object
  name*, uuid*: string
Represents a player of a Minecraft server.
PlayerCount = object
  online*, max*: int
Represents the total amount of online players (and the maximum player capacity) of a Minecraft server.
PlayerNotFoundError = object of DataError
Raised when a player could not be found within the list of online players.
Plugin = object
  name*, version*: string
Represents a plugin of a Minecraft server.
Protocol = object
  name*: string
  version*: int
Represents the protocol of a Minecraft server.
QueryError = object of DataError
Raised when a particular part of the data could not be queried properly depending on the server platforms and other factors.
Server = ref object
  address*: string
  platform*: Platform
Represents an object reference of a Minecraft server. You will primarily use this object to interact with the API.
ServerDebugValues = object
  ping*, query*, srv*, querymismatch*, ipinsrv*, cnameinsrv*, animatedmotd*,
  cachehit*: bool
  cachetime*, cacheexpire*: string
  apiversion*: int
Represents the debug values related to a Minecraft server.
ServerInfo = object
  raw*, clean*, html*: seq[string]
Represents certain information related to a Minecraft server. Only included if the server uses player samples for gathering information.
ServerMap = object
  raw*, clean*, html*: string
Represents the map name of a Minecraft server.
ServerMOTD = object
  raw*, clean*, html*: seq[string]
Represents the MOTD (Message of The Day) of a Minecraft server.

Procs

proc debug(self: Server): ServerDebugValues {.
    ...raises: [NotInitializedError, DataError, KeyError], tags: [], forbids: [].}
Returns the debug values related to the Minecraft server.
proc gamemode(self: Server): Option[string] {....raises: [NotInitializedError],
    tags: [], forbids: [].}
(Bedrock-only) Returns the game mode used inside the server (Survival / Creative / Adventure).
proc getPlayerByName(self: Server; name: string): seq[Player] {.
    ...raises: [QueryError], tags: [], forbids: [].}
(Query-dependant) Returns a sequence of players currently online on the server matching the name given.
proc getPlayerByUUID(self: Server; uuid: string): Player {.
    ...raises: [PlayerNotFoundError, QueryError], tags: [], forbids: [].}
(Query-dependant) Returns the data associated with a player through a Player object.
proc hostname(self: Server): Option[string] {....raises: [NotInitializedError],
    tags: [], forbids: [].}
(If detected) Returns the hostname of the server.
proc icon(self: Server): string {....raises: [], tags: [], forbids: [].}
Returns the icon of the server in BASE64 string format.
proc info(self: Server): Option[ServerInfo] {.
    ...raises: [NotInitializedError, KeyError], tags: [], forbids: [].}
(If detected) Returns a ServerInfo object representing some extra bits of information related to the server.
proc ip(self: Server): string {....raises: [NotInitializedError, DataError],
                                tags: [], forbids: [].}
Returns the IP address of the server.
proc isEulaBlocked(self: Server): Option[bool] {....raises: [NotInitializedError],
    tags: [], forbids: [].}
(Java-only) Returns a boolean value depending on if the Minecraft server has blocked EULA or not.
proc isOnline(self: Server): bool {....raises: [NotInitializedError, DataError],
                                    tags: [], forbids: [].}
Returns a boolean value depending on if the Minecraft server is online or not.
proc map(self: Server): Option[ServerMap] {....raises: [], tags: [], forbids: [].}
(If detected) Returns a ServerMap object representing the map name of the server.
proc mods(self: Server): Option[seq[Mod]] {.
    ...raises: [NotInitializedError, KeyError], tags: [], forbids: [].}
(If detected) Returns a sequence of Mod objects, representing the mods currently in use on the server.
proc motd(self: Server): Option[ServerMOTD] {.
    ...raises: [NotInitializedError, KeyError], tags: [], forbids: [].}
(If detected) Returns a ServerMOTD object representing the MOTD (Message of the Day) for the server.
proc playerCount(self: Server): Option[PlayerCount] {.
    ...raises: [NotInitializedError, KeyError], tags: [], forbids: [].}
(If detected) Returns a PlayerCount object representing the total amount of active players (and the maximum player capacity) of the server.
proc players(self: Server): Option[seq[Player]] {....raises: [], tags: [],
    forbids: [].}
Returns a sequence of Player objects representing currently online (and queried) players on the server.
proc plugins(self: Server): Option[seq[Plugin]] {.
    ...raises: [NotInitializedError, KeyError], tags: [], forbids: [].}
(If detected) Returns a sequence of Plugin objects, representing the plugins currently installed on the server.
proc port(self: Server): int {....raises: [NotInitializedError, DataError],
                               tags: [], forbids: [].}
Returns the port of the server.
proc protocol(self: Server): Option[Protocol] {.
    ...raises: [NotInitializedError, KeyError], tags: [], forbids: [].}
(Optional) Returns the protocol of the server. Only returned if ping is set to True within the debug values.
proc refreshData(self: Server): Future[void] {....stackTrace: false,
    raises: [Exception],
    tags: [ReadIOEffect, WriteIOEffect, RootEffect, TimeEffect], forbids: [].}
Connect to the API and load the data related to the given Minecraft server into the Server object.
proc serverid(self: Server): Option[string] {....raises: [NotInitializedError],
    tags: [], forbids: [].}
(Bedrock-only) Returns the ID of the server.
proc software(self: Server): Option[string] {....raises: [NotInitializedError],
    tags: [], forbids: [].}
(If detected) Returns the software used for the server.
proc version(self: Server): string {....raises: [NotInitializedError, DataError],
                                     tags: [], forbids: [].}
Returns the version of software used for running the Minecraft server. This can include multiple versions or additional text depending on the server.