Spaces:
Building
Building
Update app.py
Browse files
app.py
CHANGED
@@ -29,23 +29,22 @@ async def petsimgo(interaction: discord.Interaction, petname: str):
|
|
29 |
collection_data = await fetch_data("https://petsgo.biggamesapi.io/api/collection/Pets")
|
30 |
|
31 |
if not collection_data:
|
32 |
-
await interaction.followup.send("
|
33 |
return
|
34 |
|
35 |
-
matching_pets = [pet for pet in collection_data['data'] if petname.lower() in pet['
|
36 |
|
37 |
if not matching_pets:
|
38 |
-
await interaction.followup.send(f"No pets found
|
39 |
return
|
40 |
|
41 |
if len(matching_pets) == 1:
|
42 |
-
|
43 |
-
await show_pet_details(interaction, pet)
|
44 |
else:
|
45 |
pet_names = [pet['configData']['name'] for pet in matching_pets]
|
46 |
embed = discord.Embed(title="Matching Pets", color=0x787878)
|
47 |
-
embed.description = "\n".join(pet_names)
|
48 |
-
embed.set_footer(text=f"Found {len(pet_names)} matching
|
49 |
await interaction.followup.send(embed=embed)
|
50 |
|
51 |
async def show_pet_details(interaction, pet_info):
|
@@ -56,7 +55,7 @@ async def show_pet_details(interaction, pet_info):
|
|
56 |
pet_rap = next((p for p in rap_data['data'] if p['configData']['id'] == pet_info['configData']['id']), None)
|
57 |
|
58 |
if not pet_exists or not pet_rap:
|
59 |
-
await interaction.followup.send("
|
60 |
return
|
61 |
|
62 |
exists_value = pet_exists['value']
|
@@ -80,7 +79,7 @@ async def show_pet_details(interaction, pet_info):
|
|
80 |
embed.add_field(name="Difficulty", value=format_difficulty(pet_info['configData']['difficulty']), inline=True)
|
81 |
embed.add_field(name="Category", value=pet_info['category'], inline=True)
|
82 |
embed.set_thumbnail(url=thumbnail_url)
|
83 |
-
embed.set_footer(text="
|
84 |
|
85 |
await interaction.followup.send(embed=embed)
|
86 |
|
|
|
29 |
collection_data = await fetch_data("https://petsgo.biggamesapi.io/api/collection/Pets")
|
30 |
|
31 |
if not collection_data:
|
32 |
+
await interaction.followup.send("Error fetching pet data.")
|
33 |
return
|
34 |
|
35 |
+
matching_pets = [pet for pet in collection_data['data'] if petname.lower() in pet['configData']['name'].lower()]
|
36 |
|
37 |
if not matching_pets:
|
38 |
+
await interaction.followup.send(f"No pets found matching '{petname}'.")
|
39 |
return
|
40 |
|
41 |
if len(matching_pets) == 1:
|
42 |
+
await show_pet_details(interaction, matching_pets[0])
|
|
|
43 |
else:
|
44 |
pet_names = [pet['configData']['name'] for pet in matching_pets]
|
45 |
embed = discord.Embed(title="Matching Pets", color=0x787878)
|
46 |
+
embed.description = "\n".join(pet_names[:25]) # Limit to 25 results to avoid hitting Discord's character limit
|
47 |
+
embed.set_footer(text=f"Found {len(pet_names)} matching pets. Please use a more specific name.")
|
48 |
await interaction.followup.send(embed=embed)
|
49 |
|
50 |
async def show_pet_details(interaction, pet_info):
|
|
|
55 |
pet_rap = next((p for p in rap_data['data'] if p['configData']['id'] == pet_info['configData']['id']), None)
|
56 |
|
57 |
if not pet_exists or not pet_rap:
|
58 |
+
await interaction.followup.send("Error fetching detailed pet information.")
|
59 |
return
|
60 |
|
61 |
exists_value = pet_exists['value']
|
|
|
79 |
embed.add_field(name="Difficulty", value=format_difficulty(pet_info['configData']['difficulty']), inline=True)
|
80 |
embed.add_field(name="Category", value=pet_info['category'], inline=True)
|
81 |
embed.set_thumbnail(url=thumbnail_url)
|
82 |
+
embed.set_footer(text="Hello everyone, can I please get a burrito now?")
|
83 |
|
84 |
await interaction.followup.send(embed=embed)
|
85 |
|