coollsd commited on
Commit
4b66121
·
verified ·
1 Parent(s): bc53674

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -31
app.py CHANGED
@@ -15,7 +15,7 @@ tree = app_commands.CommandTree(bot)
15
  async def read_root():
16
  return {"Hello": "World"}
17
 
18
- @tree.command(name="petsimgo", description="Get info on pets in PetsGo")
19
  async def petsimgo(interaction: discord.Interaction, petname: str):
20
  await interaction.response.defer()
21
 
@@ -26,41 +26,26 @@ async def petsimgo(interaction: discord.Interaction, petname: str):
26
  return await response.json()
27
  return None
28
 
 
 
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):
51
- exists_data = await fetch_data("https://petsgo.biggamesapi.io/api/exists")
52
- rap_data = await fetch_data("https://petsgo.biggamesapi.io/api/Rap")
53
-
54
- pet_exists = next((p for p in exists_data['data'] if p['configData']['id'] == pet_info['configData']['id']), None)
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']
62
  rap_value = pet_rap['value']
63
  thumbnail_id = pet_info['configData']['thumbnail'].split('://')[1]
 
64
  thumbnail_url = f"https://api.rbxgleaks1.workers.dev/asset/{thumbnail_id}"
65
 
66
  def format_difficulty(difficulty):
@@ -74,12 +59,12 @@ async def show_pet_details(interaction, pet_info):
74
  return f"{difficulty} ({difficulty:,})"
75
 
76
  embed = discord.Embed(title=f"PetsGo: {pet_info['configData']['name']}", color=0x787878)
77
- embed.add_field(name="Value", value=f"{rap_value:,} diamonds", inline=True)
78
- embed.add_field(name="Existing", value=f"{exists_value:,}", inline=True)
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
 
 
15
  async def read_root():
16
  return {"Hello": "World"}
17
 
18
+ @tree.command(name="petsimgo", description="get info on pet on petsgo u")
19
  async def petsimgo(interaction: discord.Interaction, petname: str):
20
  await interaction.response.defer()
21
 
 
26
  return await response.json()
27
  return None
28
 
29
+ exists_data = await fetch_data("https://petsgo.biggamesapi.io/api/exists")
30
+ rap_data = await fetch_data("https://petsgo.biggamesapi.io/api/Rap")
31
  collection_data = await fetch_data("https://petsgo.biggamesapi.io/api/collection/Pets")
32
 
33
+ if not exists_data or not rap_data or not collection_data:
34
+ await interaction.followup.send("errer")
 
 
 
 
 
 
35
  return
36
 
37
+ pet_exists = next((pet for pet in exists_data['data'] if pet['configData']['id'].lower() == petname.lower()), None)
38
+ pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'].lower() == petname.lower()), None)
39
+ pet_info = next((pet for pet in collection_data['data'] if pet['configName'].lower() == petname.lower()), None)
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ if not pet_exists or not pet_rap or not pet_info:
42
+ await interaction.followup.send(f"Pet '{petname}' not found.")
43
  return
44
 
45
  exists_value = pet_exists['value']
46
  rap_value = pet_rap['value']
47
  thumbnail_id = pet_info['configData']['thumbnail'].split('://')[1]
48
+
49
  thumbnail_url = f"https://api.rbxgleaks1.workers.dev/asset/{thumbnail_id}"
50
 
51
  def format_difficulty(difficulty):
 
59
  return f"{difficulty} ({difficulty:,})"
60
 
61
  embed = discord.Embed(title=f"PetsGo: {pet_info['configData']['name']}", color=0x787878)
62
+ embed.add_field(name="value", value=f"{rap_value:,} diamonds", inline=True)
63
+ embed.add_field(name="existing", value=f"{exists_value:,}", inline=True)
64
+ embed.add_field(name="difficulty", value=format_difficulty(pet_info['configData']['difficulty']), inline=True)
65
+ embed.add_field(name="category", value=pet_info['category'], inline=True)
66
  embed.set_thumbnail(url=thumbnail_url)
67
+ embed.set_footer(text="hello everyone can i please get a burrito now")
68
 
69
  await interaction.followup.send(embed=embed)
70