Refactor: Update WHOIS query method to use 'whois.whois' for improved data retrieval

This commit is contained in:
pancakes-proxy 2025-05-21 03:53:45 +09:00
parent c3500cdaad
commit a315244e31

View File

@ -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)