faster server pinging
@@ -113,12 +113,17 @@ class Minecraft(commands.Cog):
self.bot.loop.create_task(self.unified_mc_ping(ip, port, "be"))
]
+ done = 0
+
+ while done < 3:
for task in tasks:
- while not task.done():
- await asyncio.sleep(.05)
+ if task.done():
+ result = task.result()
+
+ if result.get("online") is True:
+ return result
- if task.result().get("online") is True:
- return task.result()
+ done += 1
return {"online": False, "player_count": 0, "players": None, "ping": None, "version": None}
