Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Merge pull request #48 from is-a-dev/developments
Browse files Browse the repository at this point in the history
dev stuff
  • Loading branch information
MaskDuck authored May 18, 2024
2 parents 944b9cb + 0eb364d commit a9f7023
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions _orangcbot/extensions/dns.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
19 changes: 15 additions & 4 deletions _orangcbot/extensions/nonsense.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__()
Expand All @@ -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)


Expand Down Expand Up @@ -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:
Expand All @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions _orangcbot/extensions/testing_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")

Expand Down

0 comments on commit a9f7023

Please sign in to comment.