coollsd commited on
Commit
bc53674
·
verified ·
1 Parent(s): 3bc9cf3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
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("errer")
33
  return
34
 
35
- matching_pets = [pet for pet in collection_data['data'] if petname.lower() in pet['configName'].lower()]
36
 
37
  if not matching_pets:
38
- await interaction.followup.send(f"No pets found with '{petname}'.")
39
  return
40
 
41
  if len(matching_pets) == 1:
42
- pet = matching_pets[0]
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 name, the one you put does not exist.")
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("errer")
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="Best Bot Ever")
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