Skip to content

Instantly share code, notes, and snippets.

@masecla22
Created March 30, 2018 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masecla22/ee3ae0b16da64a5ff76adbdaee1a982f to your computer and use it in GitHub Desktop.
Save masecla22/ee3ae0b16da64a5ff76adbdaee1a982f to your computer and use it in GitHub Desktop.
Simple REQ
# If you know the host and port, you may skip this and use MinecraftServer("example.org", 1234)
server = MinecraftServer("doge.bitquest.co",25565)
# 'status' is supported by all Minecraft servers that are version 1.7 or higher.
status = server.status()
print("The server has {0} players and replied in {1} ms".format(status.players.online, status.latency))
# 'ping' is supported by all Minecraft servers that are version 1.7 or higher.
# It is included in a 'status' call, but is exposed separate if you do not require the additional info.
latency = server.ping()
print("The server replied in {0} ms".format(latency))
# 'query' has to be enabled in a servers' server.properties file.
# It may give more information than a ping, such as a full player list or mod information.
query = server.query()
print("The server has the following players online: {0}".format(", ".join(query.players.names)))
ERROR CODE
The server has 5 players and replied in 416.592 ms
The server replied in 374.217 ms
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py",
line 307, in _run_event yield from getattr(self, event)(*args, **kwargs)
File "C:\Users\super\Desktop\BOTPY\DogeBit\bot.py", line 104, in on_message query = server.query()
File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\server.py", line 82, in query raise exception
File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\server.py", line 77, in query querier.handshake()
File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\querier.py", line 32, in handshake packet = self._read_packet()
File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\querier.py", line 25, in _read_packet packet.receive(self.connection.read(self.connection.remaining()))
File "C:\Users\super\AppData\Local\Programs\Python\Python36-32\lib\site-packages\mcstatus\protocol\connection.py", line 175, in read result.extend(self.socket.recvfrom(self.remaining())[0])
socket.timeout: timed out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment