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