Adding a /paldeck command
This commit is contained in:
parent
21d1db750d
commit
67e06340c1
@ -9,6 +9,48 @@ class PalWorld(commands.Cog):
|
|||||||
|
|
||||||
palworld = discord.SlashCommandGroup("palworld", "Palworld related commands")
|
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(
|
@palworld.command(
|
||||||
guild_ids=None,
|
guild_ids=None,
|
||||||
name="elements",
|
name="elements",
|
||||||
|
@ -93,7 +93,9 @@ class StarCitizen(commands.Cog):
|
|||||||
self,
|
self,
|
||||||
ctx: commands.Context,
|
ctx: commands.Context,
|
||||||
ship: discord.Option(
|
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()
|
await ctx.defer()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user