Spaces:
Paused
Paused
Update shop.py
Browse files
shop.py
CHANGED
|
@@ -1,58 +1,90 @@
|
|
| 1 |
import discord
|
| 2 |
from discord import app_commands
|
| 3 |
import asyncio
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 16 |
async def shop(interaction: discord.Interaction, item: str = None):
|
| 17 |
user_id = interaction.user.id
|
| 18 |
balance = user_cash.get(user_id, 0)
|
| 19 |
|
| 20 |
if item is None:
|
| 21 |
-
embed = discord.Embed(
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
await interaction.response.send_message(embed=embed)
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
else:
|
| 34 |
-
await interaction.response.send_message("You don't have enough money.")
|
| 35 |
elif item == "100":
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
user_cash[user_id] -= 999000000
|
| 39 |
-
code = robux_codes.pop(0)
|
| 40 |
-
await interaction.user.send(f"Here's your 100 Robux code: {code}")
|
| 41 |
-
await interaction.response.send_message("Code sent to your DMs.")
|
| 42 |
-
else:
|
| 43 |
-
await interaction.response.send_message("You don't have enough money to purchase this get richer fool")
|
| 44 |
-
else:
|
| 45 |
-
await interaction.response.send_message("This item is gone wait for a restock.")
|
| 46 |
elif item.lower() == "steam":
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
user_cash[user_id] -= 1000000000
|
| 50 |
-
code = steam_game_codes.pop(0) # Redeem the first available code
|
| 51 |
-
await interaction.user.send(f"Here's your Steam game code: {code}")
|
| 52 |
-
await interaction.response.send_message("Code sent to your DMs.")
|
| 53 |
-
else:
|
| 54 |
-
await interaction.response.send_message("You don't have enough money to purchase this get richer fool")
|
| 55 |
-
else:
|
| 56 |
-
await interaction.response.send_message("All codes are redeemed wait for a restock.")
|
| 57 |
else:
|
| 58 |
-
await interaction.response.send_message("Invalid item. Use /shop to see available items.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import discord
|
| 2 |
from discord import app_commands
|
| 3 |
import asyncio
|
| 4 |
+
|
| 5 |
+
# Bot setup
|
| 6 |
+
class ShopBot(discord.Client):
|
| 7 |
+
def __init__(self):
|
| 8 |
+
super().__init__(intents=discord.Intents.default())
|
| 9 |
+
self.tree = app_commands.CommandTree(self)
|
| 10 |
+
|
| 11 |
+
async def setup_hook(self):
|
| 12 |
+
await self.tree.sync()
|
| 13 |
+
|
| 14 |
+
# Initialize bot and user cash dictionary
|
| 15 |
+
client = ShopBot()
|
| 16 |
+
user_cash = {} # Stores user balances
|
| 17 |
+
|
| 18 |
+
# Empty inventory lists to show everything is out of stock
|
| 19 |
+
robux_codes = []
|
| 20 |
+
steam_game_codes = []
|
| 21 |
+
|
| 22 |
+
@client.tree.command(name="shop", description="View and buy items from the shop")
|
| 23 |
async def shop(interaction: discord.Interaction, item: str = None):
|
| 24 |
user_id = interaction.user.id
|
| 25 |
balance = user_cash.get(user_id, 0)
|
| 26 |
|
| 27 |
if item is None:
|
| 28 |
+
embed = discord.Embed(
|
| 29 |
+
title="Shop",
|
| 30 |
+
description="All items are currently out of stock",
|
| 31 |
+
color=0xFF0000
|
| 32 |
+
)
|
| 33 |
+
|
| 34 |
+
embed.add_field(
|
| 35 |
+
name="@everyone Ping",
|
| 36 |
+
value="Price: $300,000,000\nStatus: Out of Stock",
|
| 37 |
+
inline=False
|
| 38 |
+
)
|
| 39 |
+
embed.add_field(
|
| 40 |
+
name="Robux Code (100 R$)",
|
| 41 |
+
value="Price: $999,000,000\nStatus: Out of Stock",
|
| 42 |
+
inline=False
|
| 43 |
+
)
|
| 44 |
+
embed.add_field(
|
| 45 |
+
name="Steam Game Code",
|
| 46 |
+
value="Price: $1,000,000,000\nStatus: Out of Stock",
|
| 47 |
+
inline=False
|
| 48 |
+
)
|
| 49 |
+
|
| 50 |
+
embed.set_footer(text="Use /shop <item> to attempt purchase")
|
| 51 |
await interaction.response.send_message(embed=embed)
|
| 52 |
+
return
|
| 53 |
+
|
| 54 |
+
# Handle purchase attempts
|
| 55 |
+
if item.lower() == "@everyone":
|
| 56 |
+
await interaction.response.send_message("This item is currently out of stock.")
|
| 57 |
+
|
|
|
|
|
|
|
| 58 |
elif item == "100":
|
| 59 |
+
await interaction.response.send_message("Robux codes are currently out of stock.")
|
| 60 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
elif item.lower() == "steam":
|
| 62 |
+
await interaction.response.send_message("Steam game codes are currently out of stock.")
|
| 63 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
else:
|
| 65 |
+
await interaction.response.send_message("Invalid item. Use /shop to see available items.")
|
| 66 |
+
|
| 67 |
+
@client.tree.command(name="balance", description="Check your balance")
|
| 68 |
+
async def balance(interaction: discord.Interaction):
|
| 69 |
+
user_id = interaction.user.id
|
| 70 |
+
balance = user_cash.get(user_id, 0)
|
| 71 |
+
|
| 72 |
+
embed = discord.Embed(
|
| 73 |
+
title="💰 Balance",
|
| 74 |
+
description=f"Your current balance: ${balance:,}",
|
| 75 |
+
color=0x00FF00
|
| 76 |
+
)
|
| 77 |
+
await interaction.response.send_message(embed=embed)
|
| 78 |
+
|
| 79 |
+
@client.tree.command(name="addmoney", description="Add money to a user (Admin only)")
|
| 80 |
+
@app_commands.checks.has_permissions(administrator=True)
|
| 81 |
+
async def addmoney(interaction: discord.Interaction, user: discord.Member, amount: int):
|
| 82 |
+
user_id = user.id
|
| 83 |
+
user_cash[user_id] = user_cash.get(user_id, 0) + amount
|
| 84 |
+
|
| 85 |
+
embed = discord.Embed(
|
| 86 |
+
title="💵 Money Added",
|
| 87 |
+
description=f"Added ${amount:,} to {user.mention}'s balance\nNew balance: ${user_cash[user_id]:,}",
|
| 88 |
+
color=0x00FF00
|
| 89 |
+
)
|
| 90 |
+
await interaction.response.send_message(embed=embed)
|