Spaces:
Paused
Paused
Create shop.py
Browse files
shop.py
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import discord
|
| 2 |
+
from discord import app_commands
|
| 3 |
+
import asyncio
|
| 4 |
+
|
| 5 |
+
user_cash = {}
|
| 6 |
+
|
| 7 |
+
@app_commands.command(name="shop", description="Buy items from the shop")
|
| 8 |
+
@app_commands.describe(item="The item you want to buy")
|
| 9 |
+
async def shop(interaction: discord.Interaction, item: str = None):
|
| 10 |
+
user_id = interaction.user.id
|
| 11 |
+
balance = user_cash.get(user_id, 0)
|
| 12 |
+
|
| 13 |
+
if item is None:
|
| 14 |
+
embed = discord.Embed(title="Shop", description="Available items:", color=0x787878)
|
| 15 |
+
embed.add_field(name="@everyone ping", value="Price: $300,000,000", inline=False)
|
| 16 |
+
embed.set_footer(text="Use /shop @everyone to purchase")
|
| 17 |
+
await interaction.response.send_message(embed=embed)
|
| 18 |
+
elif item.lower() == "@everyone":
|
| 19 |
+
if balance >= 300000000:
|
| 20 |
+
user_cash[user_id] -= 300000000
|
| 21 |
+
await interaction.response.send_message("Item purchased! @everyone ping will be sent in 2 seconds.")
|
| 22 |
+
await asyncio.sleep(2)
|
| 23 |
+
await interaction.channel.send("@everyone")
|
| 24 |
+
else:
|
| 25 |
+
await interaction.response.send_message("You don't have enough money to purchase this item.")
|
| 26 |
+
else:
|
| 27 |
+
await interaction.response.send_message("Invalid item. Use /shop to see available items.")
|