Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class shop(commands.Cog):
- def __init__(self, client):
- self.client = client
- @commands.command()
- @commands.cooldown(1,10,commands.BucketType.channel)
- async def shop(self,ctx):
- embed = discord.Embed(title="SHOP!",description="Stone Pickaxe - 20 coins\nIron Pickaxe - 100 coins\nRuby Pickaxe - 1000 coins")
- embed.set_footer(f"requested by {ctx.message.author}")
- await ctx.send(embed=embed)
- @commands.command()
- @commands.cooldown(1,2,commands.BucketType.member)
- async def buy(self,ctx,*,item):
- db = sqlite3.connect("./MiningRPG/main.mysql")
- cur = db.cursor()
- cur.execute(f"SELECT coins,current_pick FROM rocks WHERE user_id = '{ctx.message.author.id}'")
- result = cur.fetchone()
- if result is None:
- sql = ("INSERT INTO rocks(user_id,mined,curren_pick,coins) VALUES(?,?,?,?)")
- var = (str(ctx.message.author.id),0,"Wooden Pickaxe",0)
- cur.execute(sql,var)
- db.commit()
- cur.execute(f"SELECT coins,current_pick FROM rocks WHERE user_id = '{ctx.message.author.id}'")
- result = cur.fetchone()
- if item.lower() == "stone pickaxe":
- if result[1].lower() == item.lower():
- await ctx.send("You already own this item!")
- elif result[1].lower() == "iron pickaxe" or result[1].lower() == "ruby pickaxe":
- await ctx.send("You already own a better pickaxe!")
- elif result[0] < 20:
- await ctx.send("You can't afford that!")
- else:
- current_pick = result[1]
- coins = result[0]
- sql = (f"UPDATE rocks SET coins = ?, current_pick = ?, user_id = ? WHERE user_id = ?")
- var = (coins - 20, current_pick = "Stone Pickaxe",str(ctx.message.author.id))
- await ctx.send("You have bought an **Stone Pickaxe** for 20 coins!")
- if item.lower() == "iron pickaxe":
- if result[1].lower() == item.lower():
- await ctx.send("You already own this item!")
- elif result[1].lower() == "ruby pickaxe":
- await ctx.send("You already own a better pickaxe!")
- elif result[0] < 100:
- await ctx.send("You can't afford that!")
- else:
- current_pick = result[1]
- coins = result[0]
- sql = (f"UPDATE rocks SET coins = ?, current_pick = ? WHERE user_id = ?")
- var = (coins - 100, current_pick = "Iron Pickaxe",str(ctx.message.author.id))
- await ctx.send("You have bought an **Iron Pickaxe** for **100 coins**!")
- if item.lower() == "ruby pickaxe":
- if result[1].lower() == item.lower():
- await ctx.send("You already own this item!")
- elif result[0] < 1000:
- await ctx.send("You can't afford that!")
- else:
- current_pick = result[1]
- coins = result[0]
- sql = (f"UPDATE rocks SET coins = ?, current_pick = ? WHERE user_id = ?")
- var = (coins - 1000, current_pick = "Ruby Pickaxe",str(ctx.message.author.id))
- await ctx.send("You have bought an **Ruby Pickaxe** for **1000 coins***!")
Advertisement
Add Comment
Please, Sign In to add comment