aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Hassan Abouelela <[email protected]>2021-05-09 22:54:11 +0300
committerGravatar Hassan Abouelela <[email protected]>2021-05-09 22:54:11 +0300
commit8e5a38fc9be2bac83ed327cfbfdfcfe099f3b6b4 (patch)
tree36808909f8c611bdfd792715a51d5209225ca44e
parentAdds Warning For Desynced Clock In Ping Command (diff)
Adds Warning For Permission Error In Ping
Mostly affects linux machines not running as root. Signed-off-by: Hassan Abouelela <[email protected]>
-rw-r--r--bot/exts/utils/ping.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/bot/exts/utils/ping.py b/bot/exts/utils/ping.py
index 95490d5a9..750ff46d2 100644
--- a/bot/exts/utils/ping.py
+++ b/bot/exts/utils/ping.py
@@ -42,8 +42,12 @@ class Latency(commands.Cog):
try:
url = urllib.parse.urlparse(URLs.site_schema + URLs.site).hostname
- delay = await aioping.ping(url, family=socket.AddressFamily.AF_INET) * 1000
- site_ping = f"{delay:.{ROUND_LATENCY}f} ms"
+ try:
+ delay = await aioping.ping(url, family=socket.AddressFamily.AF_INET) * 1000
+ site_ping = f"{delay:.{ROUND_LATENCY}f} ms"
+ except OSError:
+ # Some machines do not have permission to run ping
+ site_ping = "Permission denied, could not ping."
except TimeoutError:
site_ping = f"{Emojis.cross_mark} Connection timed out."