coollsd commited on
Commit
a372ce3
·
verified ·
1 Parent(s): 420abad

Create petsimgo.py

Browse files
Files changed (1) hide show
  1. petsimgo.py +56 -0
petsimgo.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import discord
2
+ from discord import app_commands
3
+ import aiohttp
4
+
5
+ @app_commands.command(name="petsimgo", description="get info on pet on petsgo u")
6
+ async def petsimgo(interaction: discord.Interaction, petname: str):
7
+ await interaction.response.defer()
8
+
9
+ async def fetch_data(url):
10
+ async with aiohttp.ClientSession() as session:
11
+ async with session.get(url) as response:
12
+ if response.status == 200:
13
+ return await response.json()
14
+ return None
15
+
16
+ exists_data = await fetch_data("https://petsgo.biggamesapi.io/api/exists")
17
+ rap_data = await fetch_data("https://petsgo.biggamesapi.io/api/Rap")
18
+ collection_data = await fetch_data("https://petsgo.biggamesapi.io/api/collection/Pets")
19
+
20
+ if not exists_data or not rap_data or not collection_data:
21
+ await interaction.followup.send("error")
22
+ return
23
+
24
+ pet_exists = next((pet for pet in exists_data['data'] if pet['configData']['id'].lower() == petname.lower()), None)
25
+ pet_rap = next((pet for pet in rap_data['data'] if pet['configData']['id'].lower() == petname.lower()), None)
26
+ pet_info = next((pet for pet in collection_data['data'] if pet['configName'].lower() == petname.lower()), None)
27
+
28
+ if not pet_exists or not pet_rap or not pet_info:
29
+ await interaction.followup.send(f"Pet '{petname}' not found.")
30
+ return
31
+
32
+ exists_value = pet_exists['value']
33
+ rap_value = pet_rap['value']
34
+ thumbnail_id = pet_info['configData']['thumbnail'].split('://')[1]
35
+
36
+ thumbnail_url = f"https://api.rbxgleaks1.workers.dev/asset/{thumbnail_id}"
37
+
38
+ def format_difficulty(difficulty):
39
+ if difficulty >= 1_000_000_000:
40
+ return f"{difficulty / 1_000_000_000:.1f}B ({difficulty:,})"
41
+ elif difficulty >= 1_000_000:
42
+ return f"{difficulty / 1_000_000:.1f}M ({difficulty:,})"
43
+ elif difficulty >= 1_000:
44
+ return f"{difficulty / 1_000:.1f}K ({difficulty:,})"
45
+ else:
46
+ return f"{difficulty} ({difficulty:,})"
47
+
48
+ embed = discord.Embed(title=f"PetsGo: {pet_info['configData']['name']}", color=0x787878)
49
+ embed.add_field(name="value", value=f"{rap_value:,} diamonds", inline=True)
50
+ embed.add_field(name="existing", value=f"{exists_value:,}", inline=True)
51
+ embed.add_field(name="difficulty", value=format_difficulty(pet_info['configData']['difficulty']), inline=True)
52
+ embed.add_field(name="category", value=pet_info['category'], inline=True)
53
+ embed.set_thumbnail(url=thumbnail_url)
54
+ embed.set_footer(text="hello everyone can i please get a burrito now")
55
+
56
+ await interaction.followup.send(embed=embed)