Advertisement
Dojnaz

Get ping

Dec 11th, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.46 KB | None | 0 0
  1. Ping pingSender = new Ping();
  2. PingOptions options = new PingOptions();
  3. options.DontFragment = true;
  4. byte[] buffer = Encoding.ASCII.GetBytes("ping");
  5. int timeout = 1200;
  6. PingReply reply = pingSender.Send("discordapp.com", timeout, buffer, options);
  7. if (reply.Status == IPStatus.Success)
  8.     await message.Channel.SendMessageAsync("Pong! Latency is: " + reply.RoundtripTime);
  9. else
  10.     await message.Channel.SendMessageAsync("Something went wrong :thinking:");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement