diff --git a/Dockerfile b/Dockerfile index 7d57c602..eca17918 100755 --- a/Dockerfile +++ b/Dockerfile @@ -10,4 +10,5 @@ RUN apt update && \ rm -rf /var/lib/apt/lists/* /root COPY --from=0 /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages ADD app /app +RUN mkdir -p /root/.cache/py-finance CMD python /app/bot.py diff --git a/app/cogs/game_apis.py b/app/cogs/game_apis.py index 67351522..f967ce32 100755 --- a/app/cogs/game_apis.py +++ b/app/cogs/game_apis.py @@ -1,5 +1,8 @@ +from bs4 import BeautifulSoup from discord import option from discord.ext import commands +import discord +import requests class Games(commands.Cog): @@ -21,6 +24,27 @@ class Games(commands.Cog): except Exception as e: await ctx.send(e) + async def get_ffxiv_worlds(ctx: discord.AutocompleteContext): + url = "https://na.finalfantasyxiv.com/lodestone/worldstatus/" + + # Send an HTTP GET request to the URL + response = requests.get(url) + soup = BeautifulSoup(response.text, "html.parser") + + # Find all elements with class "world-list__world_name" + world_name_elements = soup.find_all(class_="world-list__world_name") + + # Initialize an empty list to store the contents of the elements + worlds = [] + + # Loop through each element and extract its contents + for element in world_name_elements: + # Extract the text content of the element + element_content = element.get_text(strip=True) + worlds.append(element_content) + + return worlds + @commands.slash_command( guild_ids=None, name="ffxiv", @@ -29,13 +53,14 @@ class Games(commands.Cog): @option( "player_name", description="Your player's first and last name", required=True ) - @option( - "server", - description="Your player's data center", - required=True, - input_type="str", - ) - async def ffxiv(self, ctx: commands.Context, player_name: str, server: str): + async def ffxiv( + self, + ctx: commands.Context, + player_name: str, + server: discord.Option( + str, autocomplete=discord.utils.basic_autocomplete(get_ffxiv_worlds) + ), + ): import ffxiv try: