Final Store Commit
This commit is contained in:
parent
e455af564d
commit
f41798184c
3
bot.py
3
bot.py
@ -1,4 +1,4 @@
|
||||
from commands import help, ticket
|
||||
from commands import help, ticket, store
|
||||
|
||||
# pip install imports
|
||||
import discord, aiofiles
|
||||
@ -55,6 +55,7 @@ class MyBot(commands.Bot):
|
||||
self.add_view(ticket.CreateButton())
|
||||
self.add_view(ticket.CloseButton())
|
||||
self.add_view(ticket.TrashButton())
|
||||
self.add_view(store.SelectView())
|
||||
print(f'\33[32mLogged in as {self.user} (ID: {self.user.id})')
|
||||
print('------')
|
||||
|
||||
|
@ -84,105 +84,87 @@ class Select(discord.ui.Select):
|
||||
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "silver"}})
|
||||
await interaction.followup.send("You bought the silver ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
|
||||
return
|
||||
elif self.values[0] == "Gold Ticket":
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
client = pymongo.MongoClient(os.getenv("mongo_url"))
|
||||
db = client.servers
|
||||
coll = db.economy
|
||||
|
||||
cost = 400
|
||||
guild = interaction.guild
|
||||
user = interaction.user
|
||||
|
||||
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
|
||||
|
||||
if not userColl:
|
||||
await interaction.followup.send("You don't have any coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] < cost:
|
||||
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] >= cost:
|
||||
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
|
||||
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "gold"}})
|
||||
await interaction.followup.send("You bought the gold ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
|
||||
return
|
||||
elif self.values[0] == "Diamond Ticket":
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
client = pymongo.MongoClient(os.getenv("mongo_url"))
|
||||
db = client.servers
|
||||
coll = db.economy
|
||||
|
||||
cost = 800
|
||||
guild = interaction.guild
|
||||
user = interaction.user
|
||||
|
||||
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
|
||||
|
||||
if not userColl:
|
||||
await interaction.followup.send("You don't have any coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] < cost:
|
||||
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] >= cost:
|
||||
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
|
||||
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "diamond"}})
|
||||
await interaction.followup.send("You bought the diamond ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
|
||||
return
|
||||
elif self.values[0] == "Emerald Ticket":
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
client = pymongo.MongoClient(os.getenv("mongo_url"))
|
||||
db = client.servers
|
||||
coll = db.economy
|
||||
|
||||
cost = 1600
|
||||
guild = interaction.guild
|
||||
user = interaction.user
|
||||
|
||||
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
|
||||
|
||||
if not userColl:
|
||||
await interaction.followup.send("You don't have any coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] < cost:
|
||||
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] >= cost:
|
||||
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
|
||||
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "emerald"}})
|
||||
await interaction.followup.send("You bought the emerald ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
|
||||
return
|
||||
|
||||
class SelectView(discord.ui.View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
self.add_item(Select())
|
||||
|
||||
class GoldButton(View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
|
||||
@button(label="Buy Gold", style=discord.ButtonStyle.blurple, custom_id="gold")
|
||||
async def gold(self, interaction: discord.Interaction, button: Button):
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
client = pymongo.MongoClient(os.getenv("mongo_url"))
|
||||
db = client.servers
|
||||
coll = db.economy
|
||||
|
||||
cost = 400
|
||||
guild = interaction.guild
|
||||
user = interaction.user
|
||||
|
||||
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
|
||||
|
||||
if not userColl:
|
||||
await interaction.followup.send("You don't have any coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] < cost:
|
||||
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] >= cost:
|
||||
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
|
||||
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "gold"}})
|
||||
await interaction.followup.send("You bought the gold ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
|
||||
return
|
||||
|
||||
class DiamondButton(View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
|
||||
@button(label="Buy Diamond", style=discord.ButtonStyle.blurple, custom_id="diamond")
|
||||
async def diamond(self, interaction: discord.Interaction, button: Button):
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
client = pymongo.MongoClient(os.getenv("mongo_url"))
|
||||
db = client.servers
|
||||
coll = db.economy
|
||||
|
||||
cost = 800
|
||||
guild = interaction.guild
|
||||
user = interaction.user
|
||||
|
||||
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
|
||||
|
||||
if not userColl:
|
||||
await interaction.followup.send("You don't have any coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] < cost:
|
||||
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] >= cost:
|
||||
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
|
||||
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "diamond"}})
|
||||
await interaction.followup.send("You bought the diamond ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
|
||||
return
|
||||
|
||||
class EmeraldButton(View):
|
||||
def __init__(self):
|
||||
super().__init__(timeout=None)
|
||||
|
||||
@button(label="Buy Emerald", style=discord.ButtonStyle.blurple, custom_id="emerald")
|
||||
async def bronze(self, interaction: discord.Interaction, button: Button):
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
client = pymongo.MongoClient(os.getenv("mongo_url"))
|
||||
db = client.servers
|
||||
coll = db.economy
|
||||
|
||||
cost = 1600
|
||||
guild = interaction.guild
|
||||
user = interaction.user
|
||||
|
||||
userColl = coll.find_one({"_id": {'author_id': user.id, 'guild_id': guild.id}})
|
||||
|
||||
if not userColl:
|
||||
await interaction.followup.send("You don't have any coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] < cost:
|
||||
await interaction.followup.send("You don't have enough coins!", ephemeral=True)
|
||||
return
|
||||
|
||||
if userColl["coins"] >= cost:
|
||||
coll.update_one({"_id": {'author_id': user.id, 'guild_id': guild.id}}, {"$inc":{"coins":-cost}})
|
||||
coll.update_one({"_id": {"author_id": user.id, "guild_id": guild.id}}, {"$set": {"bought": "emerald"}})
|
||||
await interaction.followup.send("You bought the emerald ticket! Redeem it in the Blob support server for rewards!", ephemeral=True)
|
||||
return
|
||||
|
||||
class store(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
@ -192,9 +174,8 @@ class store(commands.Cog):
|
||||
print('Tickets Online')
|
||||
|
||||
@commands.hybrid_command(name="store", description="View the store")
|
||||
@commands.has_permissions(administrator=True)
|
||||
@commands.check(is_enabled)
|
||||
async def ticket(self, ctx):
|
||||
async def store(self, ctx):
|
||||
em = discord.Embed(title="Shop!", description="Spend some Bloboons to get cool rewards! Redeem in supported servers!", color=ctx.author.color)
|
||||
em.add_field(name="Bronze Ticket", value="100 Bloboons", inline=False)
|
||||
em.add_field(name="Silver Ticket", value="200 Bloboons", inline=False)
|
||||
|
Loading…
Reference in New Issue
Block a user