From c322258a558b18251766bd709ff2ba33763b8cf9 Mon Sep 17 00:00:00 2001 From: maskduck Date: Fri, 17 May 2024 22:41:56 +0700 Subject: [PATCH 1/4] Fix error when trying to dig nonexistent domains --- _orangcbot/extensions/dns.py | 3 +++ 1 file changed, 3 insertions(+) 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) From b7f714c4db96d4db239459d7315802fc8511cf2a Mon Sep 17 00:00:00 2001 From: maskduck Date: Fri, 17 May 2024 22:42:35 +0700 Subject: [PATCH 2/4] Fix records title not being shown --- _orangcbot/extensions/nonsense.py | 1 + 1 file changed, 1 insertion(+) diff --git a/_orangcbot/extensions/nonsense.py b/_orangcbot/extensions/nonsense.py index 5fd0c71..545fc59 100644 --- a/_orangcbot/extensions/nonsense.py +++ b/_orangcbot/extensions/nonsense.py @@ -216,6 +216,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: From dfd13b0d5757c919580ef68027261672a7db23a2 Mon Sep 17 00:00:00 2001 From: maskduck Date: Fri, 17 May 2024 22:48:18 +0700 Subject: [PATCH 3/4] Raise error when domains cannot be found --- _orangcbot/extensions/nonsense.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/_orangcbot/extensions/nonsense.py b/_orangcbot/extensions/nonsense.py index 545fc59..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) @@ -237,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", From 0eb364de64ffb1afbc621e07305b776cec943479 Mon Sep 17 00:00:00 2001 From: maskduck Date: Fri, 17 May 2024 22:50:22 +0700 Subject: [PATCH 4/4] Fix when cmd to hinder is not found --- _orangcbot/extensions/testing_functions.py | 3 +++ 1 file changed, 3 insertions(+) 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.")