[Dictionary] Not everything has an entry

This commit is contained in:
aikaterna
2021-04-07 11:54:21 -07:00
committed by GitHub
parent f4c0dfb69d
commit 4cd51a9775

View File

@@ -51,7 +51,10 @@ class Dictionary(commands.Cog):
if not data:
return await ctx.send("Error fetching data.")
section = data.find_all("ul", {"class": "css-1dnnh8h e1ccqdb60"})
antonyms = section[0].text.split()
if len(section) > 0:
antonyms = section[0].text.split()
else:
antonyms = []
return antonyms
@commands.command()
@@ -112,7 +115,10 @@ class Dictionary(commands.Cog):
if not data:
return await ctx.send("Error fetching data.")
section = data.find_all("ul", {"class": "css-1l7o0dd e1ccqdb60"})
synonyms = section[0].text.split()
if len(section) > 0:
synonyms = section[0].text.split()
else:
synonyms = []
return synonyms
@commands.command()