diff --git a/_orangcbot/extensions/dns.py b/_orangcbot/extensions/dns.py index 5d82dc1..d418348 100644 --- a/_orangcbot/extensions/dns.py +++ b/_orangcbot/extensions/dns.py @@ -107,6 +107,9 @@ async def dig(self, ctx: commands.Context, url: str): answer = "\n".join([str(ans) for ans in answers]) except _dnsresolver.NoAnswer: answer = "NOT FOUND" + except _dnsresolver.NXDOMAIN: + await ctx.send("Domain requested does not exist. Aborting.") + return k = DNSView(url, ctx.author.id) msg = await ctx.send(embed=construct_embed(url, answer, "CNAME"), view=k) k.update_msg(msg) diff --git a/_orangcbot/extensions/nonsense.py b/_orangcbot/extensions/nonsense.py index 5fd0c71..c1a52de 100644 --- a/_orangcbot/extensions/nonsense.py +++ b/_orangcbot/extensions/nonsense.py @@ -10,6 +10,10 @@ from .converters import SubdomainNameConverter +class DomainNotExistError(commands.CommandError): + """Error raised when domain cannot be found.""" + + class LinkView(nextcord.ui.View): def __init__(self): super().__init__() @@ -35,6 +39,8 @@ def __init__(self): async def request(*args, **kwargs): async with aiohttp.ClientSession() as session: async with session.request(*args, **kwargs) as ans: + if ans.status == 404: + raise DomainNotExistError("imagine") return await ans.json(content_type=None) @@ -216,6 +222,7 @@ def fetch_description_about_a_domain(self, data: Dict): # do not ask about the description of this thing my_description = f""" {contact_desc} + {record_desc} """ if domain_desc is not None: @@ -236,10 +243,14 @@ async def whois( label="Edit this subdomain?", ) ) - data = await request( - "GET", - f"https://raw.githubusercontent.com/is-a-dev/register/main/domains/{domain}.json", - ) + try: + data = await request( + "GET", + f"https://raw.githubusercontent.com/is-a-dev/register/main/domains/{domain}.json", + ) + except DomainNotExistError: + await ctx.send("The domain queried cannot be found. Aborting.") + return embed = nextcord.Embed( color=nextcord.Color.red(), title=f"Info about {domain}.is-a.dev", diff --git a/_orangcbot/extensions/testing_functions.py b/_orangcbot/extensions/testing_functions.py index 1e3c298..872315f 100644 --- a/_orangcbot/extensions/testing_functions.py +++ b/_orangcbot/extensions/testing_functions.py @@ -13,6 +13,9 @@ async def hinder(self, ctx: commands.Context, cmd: str): await ctx.send("I did not expect you to be such a fool") else: command = self._bot.get_command(cmd) + if command is None: + await ctx.send("Command not found.") + return command.enabled = not command.enabled await ctx.send("Request satisfied, master.")