ADDING autocomplete to ffxiv server selection
This commit is contained in:
parent
73aeb78b8d
commit
5abddc620e
@ -10,4 +10,5 @@ RUN apt update && \
|
|||||||
rm -rf /var/lib/apt/lists/* /root
|
rm -rf /var/lib/apt/lists/* /root
|
||||||
COPY --from=0 /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
COPY --from=0 /usr/local/lib/python3.10/site-packages /usr/local/lib/python3.10/site-packages
|
||||||
ADD app /app
|
ADD app /app
|
||||||
|
RUN mkdir -p /root/.cache/py-finance
|
||||||
CMD python /app/bot.py
|
CMD python /app/bot.py
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
|
from bs4 import BeautifulSoup
|
||||||
from discord import option
|
from discord import option
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
|
import discord
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
class Games(commands.Cog):
|
class Games(commands.Cog):
|
||||||
@ -21,6 +24,27 @@ class Games(commands.Cog):
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
await ctx.send(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(
|
@commands.slash_command(
|
||||||
guild_ids=None,
|
guild_ids=None,
|
||||||
name="ffxiv",
|
name="ffxiv",
|
||||||
@ -29,13 +53,14 @@ class Games(commands.Cog):
|
|||||||
@option(
|
@option(
|
||||||
"player_name", description="Your player's first and last name", required=True
|
"player_name", description="Your player's first and last name", required=True
|
||||||
)
|
)
|
||||||
@option(
|
async def ffxiv(
|
||||||
"server",
|
self,
|
||||||
description="Your player's data center",
|
ctx: commands.Context,
|
||||||
required=True,
|
player_name: str,
|
||||||
input_type="str",
|
server: discord.Option(
|
||||||
)
|
str, autocomplete=discord.utils.basic_autocomplete(get_ffxiv_worlds)
|
||||||
async def ffxiv(self, ctx: commands.Context, player_name: str, server: str):
|
),
|
||||||
|
):
|
||||||
import ffxiv
|
import ffxiv
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user