mirror of
https://gitlab.com/pancakes1234/wdiscordbotserver.git
synced 2025-06-16 07:14:21 -06:00
Refactor: Update WHOIS query method to use 'whois.whois' for improved data retrieval
This commit is contained in:
parent
c3500cdaad
commit
a315244e31
@ -12,17 +12,17 @@ class Whois(commands.Cog):
|
||||
async def whois(self, interaction: discord.Interaction, domain: str):
|
||||
await interaction.response.defer()
|
||||
try:
|
||||
w = await self.bot.loop.run_in_executor(None, whois.query, domain)
|
||||
w = await self.bot.loop.run_in_executor(None, whois.whois, domain)
|
||||
except Exception as e:
|
||||
await interaction.followup.send(f"Failed to fetch WHOIS info: {e}")
|
||||
return
|
||||
if not w or not w.domain_name:
|
||||
if not w or not w.get("domain_name"):
|
||||
await interaction.followup.send("Could not find WHOIS info for that domain.")
|
||||
return
|
||||
# Prepare a summary of WHOIS info
|
||||
info = []
|
||||
for key in ["domain_name", "registrar", "creation_date", "expiration_date", "name_servers", "status"]:
|
||||
value = getattr(w, key, None)
|
||||
value = w.get(key)
|
||||
if value:
|
||||
info.append(f"**{key.replace('_', ' ').title()}:** {value}")
|
||||
text = "\n".join(info)
|
||||
|
Loading…
x
Reference in New Issue
Block a user