Almost no servers return MOTD on ping
j5155 opened this issue · 2 comments
j5155 commented
I'm trying to make a python discord bot that pings servers using this library, but for some reason it only sends MOTD or description of the server for very few servers.
My code:
@bot.command()
async def ping(ctx, ip):
pingedServer = MinecraftServer.lookup(ip)
try:
status = pingedServer.status()
await ctx.channel.send(f'{ip} has {status.players.online} players online and responded in {status.latency}ms. It runs {status.version.name}. \n MOTD: ```\n{str(status.description)}\n```')
except:
await ctx.channel.send('Server did not respond to request.')
When I ping most servers with this command (example: cubecraft.net), it returns
cubecraft.net has 6704 players online and responded in 101.289ms. It runs §cWe support: 1.12.2 - 1.17.
MOTD:
but when I ping hypixel.net it returns
hypixel.net has 0 players online and responded in 92.341ms. It runs Requires MC 1.8 / 1.17.
MOTD:
§aHypixel Network §c[Maintenance]
§cFor More Information, §bhttps://hypixel.net
Is this an issue with the library or with my code? If it's my code, how can I fix this?
Iapetus-11 commented
It appears to be an issue with how the library handles server motds. Some servers return a dictionary if the text has colors or other formatting in it, and the library just ignores all that.
https://github.com/Dinnerbone/mcstatus/blob/master/mcstatus/pinger.py#L207-L210
if isinstance(raw["description"], dict):
self.description = raw["description"]["text"]
else:
self.description = raw["description"]
I'll make and submit a PR soon!
kevinkjt2000 commented
Should be resolved in v6.4.0