This repository was archived by the owner on Sep 9, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Expand file tree Collapse file tree 1 file changed +14
-4
lines changed Original file line number Diff line number Diff line change 10
10
from .converters import SubdomainNameConverter
11
11
12
12
13
+ class DomainNotExistError (commands .CommandError ):
14
+ """Error raised when domain cannot be found."""
15
+
16
+
13
17
class LinkView (nextcord .ui .View ):
14
18
def __init__ (self ):
15
19
super ().__init__ ()
@@ -35,6 +39,8 @@ def __init__(self):
35
39
async def request (* args , ** kwargs ):
36
40
async with aiohttp .ClientSession () as session :
37
41
async with session .request (* args , ** kwargs ) as ans :
42
+ if ans .status == 404 :
43
+ raise DomainNotExistError ("imagine" )
38
44
return await ans .json (content_type = None )
39
45
40
46
@@ -237,10 +243,14 @@ async def whois(
237
243
label = "Edit this subdomain?" ,
238
244
)
239
245
)
240
- data = await request (
241
- "GET" ,
242
- f"https://raw.githubusercontent.com/is-a-dev/register/main/domains/{ domain } .json" ,
243
- )
246
+ try :
247
+ data = await request (
248
+ "GET" ,
249
+ f"https://raw.githubusercontent.com/is-a-dev/register/main/domains/{ domain } .json" ,
250
+ )
251
+ except DomainNotExistError :
252
+ await ctx .send ("The domain queried cannot be found. Aborting." )
253
+ return
244
254
embed = nextcord .Embed (
245
255
color = nextcord .Color .red (),
246
256
title = f"Info about { domain } .is-a.dev" ,
You can’t perform that action at this time.
0 commit comments