Rifat Azad commited on
Commit
90c0c34
·
1 Parent(s): a73c447
Files changed (1) hide show
  1. pydvpl_bot.py +17 -0
pydvpl_bot.py CHANGED
@@ -3,6 +3,7 @@ import time
3
  import json
4
  import asyncio
5
  import psutil
 
6
  import discord
7
  import requests
8
  from datetime import datetime
@@ -410,6 +411,22 @@ async def ping(ctx):
410
  await ctx.send(f"The command `ping` was executed by - {ctx.author.mention}")
411
 
412
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
413
 
414
  # FUNCTION ------------------------------------------------------ SPLIT
415
 
 
3
  import json
4
  import asyncio
5
  import psutil
6
+ import socket
7
  import discord
8
  import requests
9
  from datetime import datetime
 
411
  await ctx.send(f"The command `ping` was executed by - {ctx.author.mention}")
412
 
413
 
414
+ # FUNCTION ------------------------------------------------------ SPLIT
415
+
416
+
417
+ @bot.hybrid_command(help="Pings custom nameservers")
418
+ async def ping_web(ctx, *nameservers):
419
+ if not nameservers:
420
+ await ctx.send("Please provide at least one nameserver to ping.")
421
+ return
422
+
423
+ for nameserver in nameservers:
424
+ try:
425
+ response = await bot.loop.run_in_executor(None, lambda: socket.gethostbyname(nameserver))
426
+ await ctx.send(f"Ping to {nameserver} successful. IP Address: {response}")
427
+ except socket.gaierror:
428
+ await ctx.send(f"Unable to resolve {nameserver}.")
429
+
430
 
431
  # FUNCTION ------------------------------------------------------ SPLIT
432