diff --git a/app/cogs/palworld.py b/app/cogs/palworld.py index ffd35e12..8709f030 100755 --- a/app/cogs/palworld.py +++ b/app/cogs/palworld.py @@ -9,6 +9,48 @@ class PalWorld(commands.Cog): palworld = discord.SlashCommandGroup("palworld", "Palworld related commands") + async def get_all_pals(ctx: discord.AutocompleteContext): + """ + returns a list of all pals in the game, which can then be passed to the /ship command for auto complete + """ + import requests + from bs4 import BeautifulSoup + + url = "https://game8.co/games/Palworld/archives/439556" + response = requests.get(url) + + soup = BeautifulSoup(response.text, "html.parser") + + all_pals = [] + + table = soup.find("table", class_="a-table a-table a-table flexible-cell") + if table: + rows = table.find_all("tr") + for row in rows: + first_a = row.find("a") + if first_a: + all_pals.append(first_a.text.strip()) + else: + pass + + return all_pals + + @palworld.command( + guild_ids=None, + name="paldeck", + description="Looks up data about a pal", + ) + async def pal_lookup( + self, + ctx: commands.Context, + pal: discord.Option( + str, + autocomplete=discord.utils.basic_autocomplete(get_all_pals), + description="Pal to look up", + ), + ): + await ctx.respond("https://palpedia.net/pals/%s" % pal.replace(" ", "+")) + @palworld.command( guild_ids=None, name="elements", diff --git a/app/cogs/star_citizen.py b/app/cogs/star_citizen.py index 52a88ca8..8f017694 100755 --- a/app/cogs/star_citizen.py +++ b/app/cogs/star_citizen.py @@ -93,7 +93,9 @@ class StarCitizen(commands.Cog): self, ctx: commands.Context, ship: discord.Option( - str, autocomplete=discord.utils.basic_autocomplete(get_all_ships) + str, + autocomplete=discord.utils.basic_autocomplete(get_all_ships), + description="The ship to look up", ), ): await ctx.defer()