Fixing the code that gets all ships for /ship
This commit is contained in:
parent
72346ff2c4
commit
564e79b3f9
@ -65,32 +65,15 @@ class StarCitizen(commands.Cog):
|
||||
"""
|
||||
returns a list of all ships in the game, which can then be passed to the /ship command for auto complete
|
||||
"""
|
||||
url = "https://starcitizen.tools/List_of_pledge_vehicles"
|
||||
url = "https://starcitizen.tools/Category:Ships"
|
||||
|
||||
response = requests.get(url).text
|
||||
soup = BeautifulSoup(response, "html.parser")
|
||||
|
||||
# Find the table with the "Name" row
|
||||
table = soup.find("table", {"class": "wikitable"})
|
||||
name_column_index = None
|
||||
all_ships = [
|
||||
a.text for a in soup.select("div.mw-category.mw-category-columns a")
|
||||
]
|
||||
|
||||
# Find the index of the "Name" column
|
||||
header_row = table.find("tr")
|
||||
headers = header_row.find_all("th")
|
||||
for i, header in enumerate(headers):
|
||||
if header.text.strip() == "Name":
|
||||
name_column_index = i
|
||||
break
|
||||
|
||||
if name_column_index is not None:
|
||||
# Extract all the items in the "Name" column
|
||||
all_ships = []
|
||||
rows = table.find_all("tr")
|
||||
for row in rows[1:]: # Skip the header row
|
||||
columns = row.find_all("td")
|
||||
if len(columns) > name_column_index:
|
||||
name = columns[name_column_index].text.strip()
|
||||
all_ships.append(name)
|
||||
return all_ships
|
||||
|
||||
@commands.slash_command(
|
||||
@ -269,7 +252,7 @@ class StarCitizen(commands.Cog):
|
||||
url="https://media.robertsspaceindustries.com/t0q21kbb3zrpt/source.png"
|
||||
)
|
||||
embed.set_author(
|
||||
name="⚠️ THERE HAS BEEN AN UPDATE TO THE ONGOING INCIDENT ⚠️\n"
|
||||
name="⚠️ THERE HAS BEEN AN UPDATE TO THE ONGOING INCIDENT ⚠️"
|
||||
)
|
||||
# embed.set_image(
|
||||
# url="https://media.giphy.com/media/WWIZJyXHXscn8JC1e0/giphy.gif"
|
||||
|
Loading…
x
Reference in New Issue
Block a user