Fix pals with multiple element types and also dynamically color the embed
This commit is contained in:
parent
9e2b513273
commit
1b4dabad6c
@ -52,22 +52,38 @@ class PalWorld(commands.Cog):
|
|||||||
response = requests.get(pal_url)
|
response = requests.get(pal_url)
|
||||||
soup = BeautifulSoup(response.text, "html.parser")
|
soup = BeautifulSoup(response.text, "html.parser")
|
||||||
|
|
||||||
color_lookup = {"Fire": discord.Color.red()}
|
elements = {}
|
||||||
|
|
||||||
pal_element_badge = soup.find("img", class_="rounded-full w-12 px-2 py-2")
|
pal_elements = soup.find("div", class_="flex flex-row flex-wrap gap-3")
|
||||||
element_text = pal_element_badge.find_next("p").text
|
for div in pal_elements:
|
||||||
element_icon = "https://paldex.io" + pal_element_badge["src"]
|
pal_element_badge = div.find("img", class_="rounded-full w-12 px-2 py-2")
|
||||||
|
element_type = pal_element_badge.find_next("p").text
|
||||||
|
element_icon = "https://paldex.io" + pal_element_badge["src"]
|
||||||
|
elements[element_type] = element_icon
|
||||||
|
|
||||||
|
primary_element = list(elements.keys())[0]
|
||||||
|
|
||||||
|
color_lookup = {
|
||||||
|
"Fire": discord.Color.red(),
|
||||||
|
"Grass": discord.Color.green(),
|
||||||
|
"Earth": discord.Color.greyple(),
|
||||||
|
"Water": discord.Color.dark_blue(),
|
||||||
|
"Ice": discord.Color.blue(),
|
||||||
|
"Dragon": discord.Color.purple(),
|
||||||
|
"Neutral": discord.Color.lighter_grey(),
|
||||||
|
"Electricity": discord.Color.yellow(),
|
||||||
|
}
|
||||||
|
|
||||||
embed = discord.Embed(
|
embed = discord.Embed(
|
||||||
description="-------",
|
description="-------",
|
||||||
color=discord.Color.blue(),
|
color=color_lookup[primary_element],
|
||||||
type="rich",
|
type="rich",
|
||||||
title=pal,
|
title=pal,
|
||||||
)
|
)
|
||||||
|
|
||||||
embed.set_author(
|
embed.set_author(
|
||||||
name=element_text,
|
name=", ".join(elements.keys()),
|
||||||
icon_url=element_icon,
|
icon_url=elements[primary_element],
|
||||||
url=pal_url,
|
url=pal_url,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user