Guest User

Untitled

a guest
Dec 5th, 2021
22
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.35 KB | None | 0 0
  1. class shop(commands.Cog):
  2.     def __init__(self, client):
  3.         self.client = client
  4.  
  5.     @commands.command()
  6.     @commands.cooldown(1,10,commands.BucketType.channel)
  7.     async def shop(self,ctx):
  8.         embed = discord.Embed(title="SHOP!",description="Stone Pickaxe - 20 coins\nIron Pickaxe - 100 coins\nRuby Pickaxe - 1000 coins")
  9.         embed.set_footer(f"requested by {ctx.message.author}")
  10.         await ctx.send(embed=embed)
  11.  
  12.     @commands.command()
  13.     @commands.cooldown(1,2,commands.BucketType.member)
  14.     async def buy(self,ctx,*,item):
  15.         db = sqlite3.connect("./MiningRPG/main.mysql")
  16.         cur = db.cursor()
  17.         cur.execute(f"SELECT coins,current_pick FROM rocks WHERE user_id = '{ctx.message.author.id}'")
  18.         result = cur.fetchone()
  19.         if result is None:
  20.             sql = ("INSERT INTO rocks(user_id,mined,curren_pick,coins) VALUES(?,?,?,?)")
  21.             var = (str(ctx.message.author.id),0,"Wooden Pickaxe",0)
  22.             cur.execute(sql,var)
  23.             db.commit()
  24.         cur.execute(f"SELECT coins,current_pick FROM rocks WHERE user_id = '{ctx.message.author.id}'")
  25.         result = cur.fetchone()
  26.         if item.lower() == "stone pickaxe":
  27.             if result[1].lower() == item.lower():
  28.                 await ctx.send("You already own this item!")
  29.             elif result[1].lower() == "iron pickaxe" or result[1].lower() == "ruby pickaxe":
  30.                 await ctx.send("You already own a better pickaxe!")
  31.             elif result[0] < 20:
  32.                 await ctx.send("You can't afford that!")
  33.             else:
  34.                 current_pick = result[1]
  35.                 coins = result[0]
  36.                 sql = (f"UPDATE rocks SET coins = ?, current_pick = ?, user_id = ? WHERE user_id = ?")
  37.                 var = (coins - 20, current_pick = "Stone Pickaxe",str(ctx.message.author.id))
  38.                 await ctx.send("You have bought an **Stone Pickaxe** for 20 coins!")
  39.  
  40.             if item.lower() == "iron pickaxe":
  41.                 if result[1].lower() == item.lower():
  42.                     await ctx.send("You already own this item!")
  43.                 elif result[1].lower() == "ruby pickaxe":
  44.                     await ctx.send("You already own a better pickaxe!")
  45.                 elif result[0] < 100:
  46.                     await ctx.send("You can't afford that!")
  47.                 else:
  48.                     current_pick = result[1]
  49.                     coins = result[0]
  50.                     sql = (f"UPDATE rocks SET coins = ?, current_pick = ? WHERE user_id = ?")
  51.                     var = (coins - 100, current_pick = "Iron Pickaxe",str(ctx.message.author.id))
  52.                     await ctx.send("You have bought an **Iron Pickaxe** for **100 coins**!")
  53.  
  54.             if item.lower() == "ruby pickaxe":
  55.                 if result[1].lower() == item.lower():
  56.                     await ctx.send("You already own this item!")
  57.                 elif result[0] < 1000:
  58.                     await ctx.send("You can't afford that!")
  59.                 else:
  60.                     current_pick = result[1]
  61.                     coins = result[0]
  62.                     sql = (f"UPDATE rocks SET coins = ?, current_pick = ? WHERE user_id = ?")
  63.                     var = (coins - 1000, current_pick = "Ruby Pickaxe",str(ctx.message.author.id))
  64.                     await ctx.send("You have bought an **Ruby Pickaxe** for **1000 coins***!")
Advertisement
Add Comment
Please, Sign In to add comment