I am trying to make my Discord bot ping a server and reply “{time} ms” but failed. I searched google but all the codes are just replying “Network Active” or “Network Error”.
Here is my code (Copied on Stack Overflow)(I use linux as server so I use “-c 1 ”
import os
@commands.command()
async def ping(self, ctx, ip):
host = ip
response = os.system(“ping “ + “-c 1 ” + host)
if response == 0:
ping_status = “Network Active”
else:
ping_status = “Network Error”
await ctx.send(ping_status)