PYCON   55

Untitled

Guest on 24th April 2022 07:56:27 PM

  1. """π•„π•’π•šπ•Ÿ.𝕑π•ͺ"""
  2. import discord
  3. from discord.ext import commands
  4. import json
  5. import os
  6. import random
  7. import exception
  8. import instance
  9. import aiohttp
  10. import time
  11.  
  12. from keep_alive import keep_alive
  13. client=commands.Bot(command_prefix=";")
  14.  
  15. @client.event
  16. async def on_ready():
  17.   print("im ready")
  18.   await client.change_presence(activity=discord.Game(name="Economy"))
  19.  
  20. @client.event
  21. async def on_command_error(ctx, error):
  22.     if isinstance(error, commands.CommandOnCooldown):
  23.         em=discord.Embed(title='This command is on a %.2fs cooldown' % error.retry_after)
  24.         await ctx.send(embed=em)
  25.     raise error
  26.        
  27.  
  28.  
  29.  
  30. @client.command()
  31. async def cmd(ctx):
  32.   em=discord.Embed(title="moNey baStard",description="my prefix is '-'",color=0xfc0303)
  33.   em.add_field(name="**currency**",value="**πŸ’Έ  withdraw {amount}**\n> withdraws money from bank\n**πŸ’°  deposite {amount}**\n> deposites money from bank\n**πŸ’³  balance**\n> shows your money\n**:palms_up_together:     beg**\n> gives you money \n**πŸ›’  buy {item name}**\n> you can buy items from the shop\n**:dollar:  sell {item name}**\n> you can sell items\n**:fishing_pole_and_fish:  fish**\n> gives you fishes which you can sell for earning money\n**πŸ—‘οΈ  hunt**\n> gives you animals or birds which you can sell later for earning money\n**πŸŽ’  bag**\n> shows your inventory\n**πŸ›οΈ  shop**\n> shows the items with prices\n**:pick: mine**\n> gives you ores which you can sell later for earning money\n**:axe: chop**\n> gives you woods which you can sell later for earning money\n**Ⓜ️ pm**\n> you can post memes and gain some moneys from ad revenue\n**πŸ—“οΈ daily**\n> gives you money every time you use the command")
  34.   await ctx.send(embed=em)
  35.  
  36. mainshop=[
  37.   {"name": "watch", "price": 2500,"description":"time"},
  38.   {"name": "laptop", "price": 50000,"description":"me"},
  39.   {"name": "pc", "price": 100000,"description":"se"},
  40.   {"name": "fishingpole", "price": 10000,"description":"you can catch fish and sell them"},
  41.   {"name": "woodensword", "price": 10000,"description":"can hunt down some animals and sell them"},
  42.   {"name": "axe", "price": 20000,"description":"you can chop down woods with an axe"},
  43.   {"name": "pickaxe", "price": 35000,"description":"Pickaxe can mine ores using it"},
  44.   {"name": "phone", "price": 50000,"description":"call"}
  45. ]
  46. sellable_items=[
  47.   {"name": "boar", "price": 1000},
  48.   {"name": "snake", "price": 5000},
  49.   {"name": "deer", "price": 800},
  50.   {"name": "rabbit", "price": 200},
  51.   {"name": "duck", "price": 50},
  52.   {"name": "common-fish", "price": 100},
  53.   {"name": "uncommon-fish", "price": 300},
  54.   {"name": "rare-fish", "price": 500},
  55.   {"name": "epic-fish", "price": 1000},
  56.   {"name": "stone","price": 100},
  57.   {"name": "oak-wood", "price":100},
  58.   {"name": "coal", "price":200},
  59.   {"name": "birch-wood", "price":200},
  60.   {"name": "copper", "price":300},
  61.   {"name": "jungle-wood", "price":300},
  62.   {"name": "iron-ore", "price": 500},
  63.   {"name": "dark-wood", "price":500},
  64.   {"name": "quartz", "price":1000},
  65.   {"name": "maple-wood", "price":1000}
  66. ]
  67. #================balance================================
  68. @client.command(aliases=["bal"])
  69. async def balance(ctx, member:discord.Member = None):
  70.    if member == None:
  71.         member = ctx.author
  72.  
  73.    await open_account(member)
  74.    user = member
  75.    users = await get_bank_data()
  76.  
  77.    wallet_amt = users[str(user.id)]["wallet"]
  78.    bank_amt = users[str(user.id)]["bank"]
  79.  
  80.    embed = discord.Embed(title=f"{member.name}'s balance ", color=0xFFD700)
  81.    embed.add_field(name="Wallet balance", value=wallet_amt)
  82.    embed.add_field(name="bank balance", value=bank_amt)
  83.    await ctx.reply(embed=embed)
  84.  
  85. @client.command(pass_context=True)
  86. async def meme(ctx):
  87.     embed = discord.Embed(title="meme", description=None)
  88.  
  89.     async with aiohttp.ClientSession() as cs:
  90.         async with cs.get('https://www.reddit.com/r/dankmemes/new.json?sort=hot') as r:
  91.             res = await r.json()
  92.             embed.set_image(url=res['data']['children'] [random.randint(0, 25)]['data']['url'])
  93.             await ctx.send(embed=embed)
  94.  
  95. #================helper function================================
  96. async def open_account(user):
  97.     users = await get_bank_data()
  98.     if str(user.id) in users:
  99.         return False
  100.     else:
  101.        
  102.         users[str(user.id)] = {}
  103.         users[str(user.id)]["wallet"] = 0
  104.         users[str(user.id)]["bank"] = 0
  105.         users[str(user.id)]["bag"]={}
  106.        
  107.        
  108.        
  109.     with open('mainbank.json', 'w') as f:
  110.         json.dump(users, f)
  111.     return True
  112.  
  113. async def get_bank_data():
  114.     with open('mainbank.json', 'r') as f:
  115.         users = json.load(f)
  116.     return users
  117. #================withdraw================================
  118.  
  119. @client.command(aliases=["with"])
  120. async def withdraw(ctx, amount=None):
  121.     await open_account(ctx.author)
  122.  
  123.     if amount == None:
  124.         await ctx.send("please enter the amount")
  125.         return
  126.     bal=await update_bank(ctx.author)
  127.     amount = int(amount)
  128.     if amount > bal[1]:
  129.         await ctx.reply("you dont have enough money")
  130.         return
  131.     if amount == "all":
  132.       amount = bal[0]
  133.     if amount < 0:
  134.         await ctx.reply("Can't withdraw negative money")
  135.         return
  136.  
  137.     await update_bank(ctx.author, amount)
  138.     await update_bank(ctx.author,-1*amount, "bank")
  139.  
  140.     await ctx.reply(f"you withdrawed {amount} money")
  141. #================deposite================================
  142. @client.command(aliases=['dep'])
  143. async def deposite(ctx,amount=None,aliases=["dep"]):
  144.   await open_account(ctx.author)
  145.   if amount == None:
  146.     await ctx.reply("please enter the amount")
  147.     return
  148.   bal=await update_bank(ctx.author)
  149.   amount= int(amount)
  150.   if amount>bal[0]:
  151.     await ctx.reply("you dont have enough money")
  152.     return
  153.   if amount == "all":
  154.       amount = bal[0]
  155.   if amount < 0:
  156.         await ctx.reply("Can't withdraw negative money")
  157.         return
  158.  
  159.   await update_bank(ctx.author,-1*amount,"wallet")
  160.   await update_bank(ctx.author,amount,"bank")
  161.   await ctx.reply(f"you deposited {amount} money")
  162. #================give money cmd================================
  163. @client.command()
  164. async def give(ctx,member:discord.Member,amount=None):
  165.   await open_account(ctx.author)
  166.   await open_account(member)
  167.   if amount == None:
  168.     await ctx.reply("please enter the amount")
  169.     return
  170.   bal=await update_bank(ctx.author)
  171.   amount= int(amount)
  172.   if amount>bal[1]:
  173.     await ctx.reply("you dont have enough money")
  174.     return
  175.   if amount < 0:
  176.         await ctx.reply("Can't withdraw negative money")
  177.         return
  178.   await update_bank(ctx.author,-1*amount,"bank")
  179.   await update_bank(member,amount,"bank")
  180.   await ctx.reply(f"you gave {amount} money")
  181. #================rob command================================
  182. @client.command()
  183. async def rob(ctx,member:discord.Member,amount=None):
  184.   await open_account(ctx.author)
  185.   await open_account(member)
  186.   bal=await update_bank(ctx.author)
  187.   if int(amount)>bal[0]<100:
  188.     await ctx.send("Not worth it man,the guys has less than 100")
  189.     return
  190.   if int(amount) < 0:
  191.         await ctx.send("Can't withdraw negative money")
  192.         return
  193.   earnings=random.randrange(0,bal[0])
  194.   await update_bank(ctx.author,earnings)
  195.   await update_bank(member,-1*earnings)
  196.   await ctx.send(f"you robbed{member.mention} and got {earnings} money")
  197. #================beg command================================
  198. @client.command()
  199. @commands.cooldown(1, 30, commands.BucketType.user)
  200. async def beg(ctx):
  201.     await open_account(ctx.author)
  202.     user = ctx.author
  203.     users = await get_bank_data()
  204.     this = random.randrange(101)
  205.     await ctx.send(f"{ctx.author.mention} Someone gave you {this} coins and your shame level wen't up!")
  206.     users[str(user.id)]["wallet"] += this
  207.     with open('mainbank.json', 'w') as f:
  208.         json.dump(users, f)
  209. #================helper function================================
  210. async def update_bank(user,change = 0, mode = "wallet"):
  211.   users = await get_bank_data()
  212.   users[str(user.id)][mode]+= change
  213.   with open("mainbank.json","w") as f:
  214.     json.dump(users,f)
  215.   bal = users[str(user.id)]["wallet"],users[str(user.id)]["bank"]
  216.   return bal
  217. #================test================================
  218. @client.command()
  219. async def reply(ctx):
  220.   await ctx.reply("sup")
  221. #================fishing command================================
  222. @client.command()
  223. @commands.cooldown(1, 45, commands.BucketType.user)
  224. async def fish(ctx):
  225.     await open_account(ctx.author)
  226.     user = ctx.author
  227.     users = await get_bank_data()
  228.     inv = users[str(user.id)]["bag"]
  229.     for thing in inv:
  230.         reqitem = "fishingpole"
  231.         if thing["item"] == reqitem:
  232.             if thing["amount"]>0:
  233.                 a = random.randrange(1,10000)
  234.                 if a<= 9500 and a>9000:
  235.                     await ctx.reply("You went to catch some fish but came back empty handed, Feels bad man")
  236.                     await update_bank(ctx.author,0)
  237.                     return
  238.                 elif a <= 4000:
  239.                     await ctx.reply("You went to catch some fish and you caught a common fish!")
  240.                     await get_item(ctx.author, 'common-fish', 1)
  241.                     return
  242.                 elif a <= 6000 and a>4000 :
  243.                     await ctx.reply("You went to catch some fish and you found a uncommon fish!")
  244.                     await get_item(ctx.author, 'uncommon-fish', 1)
  245.                     return
  246.                 elif a <= 9500 and a>9000:
  247.                     await ctx.reply("You went to catch some fish and you found a rare fish!")
  248.                     await get_item(ctx.author, 'rare-fish', 1)
  249.                     return
  250.                 elif a<= 9900 and a> 9800:
  251.                     await ctx.reply("You went to catch some fish and you caught a epic fish!")
  252.                     await get_item(ctx.author, 'epic-fish', 1)
  253.                     return
  254.                 elif a == 6:
  255.                        await ctx.send('TEST')
  256.             if thing["amount"]<1:
  257.                 ctx.command.reset_cooldown(ctx)
  258.                 await ctx.send(f"{ctx.author.mention}, Buy a fishing rod to start fishing")
  259. async def get_item(user,item_name,amount):
  260.     item_name = item_name.lower()
  261.     name_ = None
  262.     for item in sellable_items:
  263.         name = item["name"].lower()
  264.         if name == item_name:
  265.             name_ = name
  266.             price = item["price"]
  267.             break
  268.  
  269.     if name_ == None:
  270.         return [False,1]
  271.  
  272.     users = await get_bank_data()
  273.  
  274.     try:
  275.         index = 0
  276.         t = None
  277.         for thing in users[str(user.id)]["bag"]:
  278.             n = thing["item"]
  279.             if n == item_name:
  280.                 old_amt = thing["amount"]
  281.                 new_amt = old_amt + amount
  282.                 users[str(user.id)]["bag"][index]["amount"] = new_amt
  283.                 t = 1
  284.                 break
  285.             index+=1
  286.         if t == None:
  287.             obj = {"item":item_name , "amount" : amount}
  288.             users[str(user.id)]["bag"].append(obj)
  289.     except:
  290.         obj = {"item":item_name , "amount" : amount}
  291.         users[str(user.id)]["bag"] = [obj]        
  292.  
  293.     with open("mainbank.json","w") as f:
  294.         json.dump(users,f)
  295.  
  296. #================hunting command================================
  297.     return [True,"Worked"]
  298. @client.command()
  299. @commands.cooldown(1, 45, commands.BucketType.user)
  300. async def hunt(ctx):
  301.     await open_account(ctx.author)
  302.     user = ctx.author
  303.     users = await get_bank_data()
  304.     inv = users[str(user.id)]["bag"]
  305.     for thing in inv:
  306.         reqitem = "woodensword"
  307.         if thing["item"] == reqitem:
  308.             if thing["amount"]>0:
  309.                 a = random.randrange(1,10000)
  310.                 if a<= 9500 and a>9000:
  311.                     await ctx.reply("You went to hunt some animals but came back empty handed, Feels bad man")
  312.                     await update_bank(ctx.author,0)
  313.                     return
  314.                 elif a<= 9900 and a> 9800:
  315.                     await ctx.reply("You went to hunt some animals and caught a boar!")
  316.                     await get_item(ctx.author, 'boar', 1)
  317.                     return
  318.                 elif  a<=9900 and a> 9800:
  319.                     await ctx.reply("You went to hunt some animals and caught a Snake holy freak!!")
  320.                     await get_item(ctx.author, 'snake', 1)
  321.                     return
  322.                 elif a <= 9500 and a>9000:
  323.                     await ctx.reply("You went to hunt some animals and caught a deer!")
  324.                     await get_item(ctx.author, 'deer', 1)
  325.                     return
  326.                 elif a <= 6000 and a>4000:
  327.                     await ctx.reply("You went to hunt some animals and caught a rabbit!")
  328.                     await get_item(ctx.author, 'rabbit', 1)
  329.                     return
  330.                 elif a <= 4000:
  331.                     await ctx.reply("You went to hunt some animals and caught a duck!")
  332.                     await get_item(ctx.author, 'duck', 1)
  333.                     return
  334.             if thing["amount"]<1:
  335.                 ctx.command.reset_cooldown(ctx)
  336.                 await ctx.send(f"{ctx.author.mention}, Buy a wooden sword to start fishing")
  337. #================choping commands================================
  338. @client.command()
  339. @commands.cooldown(1, 45, commands.BucketType.user)
  340. async def chop(ctx):
  341.     await open_account(ctx.author)
  342.     user = ctx.author
  343.     users = await get_bank_data()
  344.     inv = users[str(user.id)]["bag"]
  345.     for thing in inv:
  346.         reqitem = "axe"
  347.         if thing["item"] == reqitem:
  348.             if thing["amount"]>0:
  349.                 a = random.randrange(1,10000)
  350.                 if a<= 9500 and a>9000:
  351.                     await ctx.reply("You went to chop some trees but came back empty handed, Feels bad man")
  352.                     await update_bank(ctx.author,0)
  353.                     return
  354.                 elif a <= 4000:
  355.                     await ctx.reply("You went to chop some trees and you found a oak tree and chop it for a oak-wood")
  356.                     await get_item(ctx.author, 'oak-wood', 1)
  357.                     return
  358.                 elif a <= 6000 and a>4000 :
  359.                     await ctx.reply("You went to chop some trees and you found a birch tree and chop it for a birch-wood")
  360.                     await get_item(ctx.author, 'brich-wood', 1)
  361.                     return
  362.                 elif a <= 9500 and a>9000:
  363.                     await ctx.reply("You went to chop some trees and you found a jungle tree and chop it for a jungle-wood")
  364.                     await get_item(ctx.author, 'jungle-wood', 1)
  365.                     return
  366.                 elif a<= 9900 and a> 9800:
  367.                     await ctx.reply("You went to chop some trees and you found a dark tree and chop it for a dark-wood")
  368.                     await get_item(ctx.author, 'dark-wood', 1)
  369.                     return
  370.                 elif a<= 9900 and a> 9800:
  371.                     await ctx.reply("You went to chop some trees and you found a maple tree and chop it for a maple-wood")
  372.                     await get_item(ctx.author, 'maple-wood', 1)
  373.                     return
  374.                 elif a == 6:
  375.                        await ctx.send('TEST')
  376.             if thing["amount"]<1:
  377.                 ctx.command.reset_cooldown(ctx)
  378.                 await ctx.send(f"{ctx.author.mention}, Buy a fishing rod to start fishing")
  379. #================mining commands================================
  380. @client.command()
  381. async def mine(ctx):
  382.     await open_account(ctx.author)
  383.     user = ctx.author
  384.     users = await get_bank_data()
  385.     inv = users[str(user.id)]["bag"]
  386.     for thing in inv:
  387.         reqitem = "pickaxe"
  388.         if thing["item"] == reqitem:
  389.             if thing["amount"]>0:
  390.                 a = random.randrange(1,10000)
  391.                 if a<= 9500 and a>9000:
  392.                     await ctx.reply("You went to mine some ores but came back empty handed, Feels bad man")
  393.                     await update_bank(ctx.author,0)
  394.                     return
  395.                 elif a <= 4000:
  396.                     await ctx.reply("You went to mine some ores and found 1 stone")
  397.                     await get_item(ctx.author, 'stone', 1)
  398.                     return
  399.                 elif a <= 6000 and a>4000 :
  400.                     await ctx.reply("You went to mine some ores and found a coal")
  401.                     await get_item(ctx.author, 'coal', 1)
  402.                     return
  403.                 elif a <= 9500 and a>9000:
  404.                     await ctx.reply("You went to mine some ores and found a copper ore")
  405.                     await get_item(ctx.author, 'copper-ore', 1)
  406.                     return
  407.                 elif a<= 9900 and a> 9800:
  408.                     await ctx.reply("You went to mine some ores and found a iron ore a")
  409.                     await get_item(ctx.author, 'iron-ore', 1)
  410.                     return
  411.                 elif a<= 9900 and a> 9800:
  412.                     await ctx.reply("You went to mine some crystals and found a quartz")
  413.                     await get_item(ctx.author, 'quartz', 1)
  414.                     return
  415.                 elif a == 6:
  416.                        await ctx.send('TEST')
  417.             if thing["amount"]>1:
  418.                 ctx.command.reset_cooldown(ctx)
  419.                 await ctx.send(f"{ctx.author.mention}, Buy a fishing rod to start fishing")
  420. #================admin commands================================
  421. @client.command(aliases=["rm","takemoney","tm"])
  422. async def removemoney(ctx,member:discord.Member,amount = None):
  423.     if ctx.author.id == 671635704811618305:
  424.         await open_account(member)
  425.  
  426.         if amount == None:
  427.             await ctx.send(f"How much money do you want me to remove from {member.name}'s account?")
  428.             return
  429.  
  430.         bal = await update_bank(ctx.author)
  431.        
  432.         amount = int(amount)
  433.         if amount < 0:
  434.             await ctx.send("amount MUST be positive...")
  435.             return
  436.  
  437.         await update_bank(member,-1*amount, "bank")
  438.     else:
  439.         await ctx.send("You are not allowed to execute this command")
  440. #================shop command================================
  441. @client.command()
  442. async def shop(ctx):
  443.   em=discord.Embed(title="Shop", color=(0x25f7e2))
  444.   for item in mainshop:
  445.     name=item["name"]
  446.     price=item["price"]
  447.     desc=item["description"]
  448.     em.add_field(name=f"{name}- ${price}", value=f" | {desc}", inline=False)
  449.   await ctx.send(embed=em)
  450. @client.command()
  451. async def buy(ctx,item,amount = 1):
  452.     await open_account(ctx.author)
  453.  
  454.     res = await buy_this(ctx.author,item,amount)
  455.  
  456.     if not res[0]:
  457.         if res[1]==1:
  458.             await ctx.send("That Object isn't there!")
  459.             return
  460.         if res[1]==2:
  461.             await ctx.send(f"You don't have enough money in your wallet to buy {amount} {item}")
  462.             return
  463.  
  464.  
  465.     await ctx.send(f"You just bought {amount} {item}")
  466. #================test================================
  467. @client.command()
  468. async def sup(ctx):
  469.     global times_used
  470.     await ctx.send(f"y or n")
  471.  
  472.     # This will make sure that the response will only be registered if the following
  473.     # conditions are met:
  474.     def check(msg):
  475.         return msg.author == ctx.author and msg.channel == ctx.channel and \
  476.         msg.content.lower() in ["f","r","n","c","w"]
  477.  
  478.     msg = await client.wait_for("message", check=check)
  479.     if msg.content.lower() == "f":
  480.         await ctx.send("you chosed fresh meme")
  481.     elif msg.content.lower() == "r":
  482.         await ctx.send("you chosed reposted meme")
  483.     elif msg.content.lower() == "n":
  484.         await ctx.send("you chosed nerdy meme")
  485.     elif msg.content.lower() == "c":
  486.         await ctx.send("you chosed cursed meme")
  487.     elif msg.content.lower() == "w":
  488.         await ctx.send("you chosed Wholesome meme")
  489.    
  490. #================inventory command================================
  491.     times_used = times_used + 1
  492. @client.command()
  493. async def bag(ctx):
  494.     await open_account(ctx.author)
  495.     user = ctx.author
  496.     users = await get_bank_data()
  497.  
  498.     try:
  499.         bag = users[str(user.id)]["bag"]
  500.     except:
  501.         bag = []
  502.  
  503.  
  504.     em = discord.Embed(title = "Bag", description="item name | quantity")
  505.     for item in bag:
  506.         name = item["item"]
  507.         amount = item["amount"]
  508.         em.add_field(name = f"{name} | {amount}", value ="danm",inline=False)    
  509.  
  510.     await ctx.send(embed = em)    
  511. async def buy_this(user,item_name,amount):
  512.     item_name = item_name.lower()
  513.     name_ = None
  514.     for item in mainshop:
  515.         name = item["name"].lower()
  516.         if name == item_name:
  517.             name_ = name
  518.             price = item["price"]
  519.             break
  520.  
  521.     if name_ == None:
  522.         return [False,1]
  523.  
  524.     cost = price*amount
  525.  
  526.     users = await get_bank_data()
  527.  
  528.     bal = await update_bank(user)
  529.  
  530.     if bal[0]<cost:
  531.         return [False,2]
  532.  
  533.  
  534.     try:
  535.         index = 0
  536.         t = None
  537.         for thing in users[str(user.id)]["bag"]:
  538.             n = thing["item"]
  539.             if n == item_name:
  540.                 old_amt = thing["amount"]
  541.                 new_amt = old_amt + amount
  542.                 users[str(user.id)]["bag"][index]["amount"] = new_amt
  543.                 t = 1
  544.                 break
  545.             index+=1
  546.         if t == None:
  547.             obj = {"item":item_name , "amount" : amount}
  548.             users[str(user.id)]["bag"].append(obj)
  549.     except:
  550.         obj = {"item":item_name , "amount" : amount}
  551.         users[str(user.id)]["bag"] = [obj]        
  552.  
  553.     with open("mainbank.json","w") as f:
  554.         json.dump(users,f)
  555.  
  556.     await update_bank(user,cost*-1,"wallet")
  557.  
  558.     return [True,"Worked"]
  559. #================sell command================================
  560. @client.command()
  561. async def sell(ctx,item,amount = 1):
  562.     await open_account(ctx.author)
  563.  
  564.     res = await sell_this(ctx.author,item,amount)
  565.  
  566.     if not res[0]:
  567.         if res[1]==1:
  568.             await ctx.send("That Object isn't there!")
  569.             return
  570.         if res[1]==2:
  571.             await ctx.send(f"You don't have {amount} {item} in your bag.")
  572.             return
  573.         if res[1]==3:
  574.             await ctx.send(f"You don't have {item} in your bag.")
  575.             return
  576.  
  577.     await ctx.send(f"You just sold {amount} {item}.")
  578.  
  579. async def sell_this(user,item_name,amount,price = None):
  580.     item_name = item_name.lower()
  581.     name_ = None
  582.     for item in mainshop:
  583.         name = item["name"].lower()
  584.         if name == item_name:
  585.             name_ = name
  586.             if price==None:
  587.                 price = 0.9* item["price"]
  588.             break
  589.  
  590.     for item in sellable_items:
  591.         name = item["name"].lower()
  592.         if name == item_name:
  593.             name_ = name
  594.             price = item["price"]
  595.             break
  596.     if name_ == None:
  597.         return [False,1]
  598.  
  599.     cost = price*amount
  600.  
  601.     users = await get_bank_data()
  602.  
  603.     bal = await update_bank(user)
  604.  
  605.     try:
  606.         index = 0
  607.         t = None
  608.         for thing in users[str(user.id)]["bag"]:
  609.             n = thing["item"]
  610.             if n == item_name:
  611.                 old_amt = thing["amount"]
  612.                 new_amt = old_amt - amount
  613.                 if new_amt < 0:
  614.                     return [False,2]
  615.                 users[str(user.id)]["bag"][index]["amount"] = new_amt
  616.                 t = 1
  617.                 break
  618.             index+=1
  619.         if t == None:
  620.             return [False,3]
  621.     except:
  622.         return [False,3]    
  623.  
  624.     with open("mainbank.json","w") as f:
  625.         json.dump(users,f)
  626.  
  627.     await update_bank(user,cost,"wallet")
  628.  
  629.     return [True,"Worked"]
  630. #================leader board command================================
  631. @client.command(aliases = ["lb"])
  632. async def leaderboard(ctx,x = 1):
  633.     users = await get_bank_data()
  634.     leader_board = {}
  635.     total = []
  636.     for user in users:
  637.         name = int(user)
  638.         total_amount = users[user]["wallet"] + users[user]["bank"]
  639.         leader_board[total_amount] = name
  640.         total.append(total_amount)
  641.  
  642.     total = sorted(total,reverse=True)    
  643.  
  644.     em = discord.Embed(title = f"Top {x} Richest People" , description = "This is decided on the basis of raw money in the bank and wallet",color = discord.Color(0xfa43ee))
  645.     index = 1
  646.     for amt in total:
  647.         id_ = leader_board[amt]
  648.         member = client.get_user(id_)
  649.         name = member.name
  650.         em.add_field(name = f"{index}. {name}" , value = f"{amt}",  inline = False)
  651.         if index == x:
  652.             break
  653.         else:
  654.             index += 1
  655.  
  656.     await ctx.send(embed = em)
  657. @client.command()
  658. #================post meme command================================
  659. async def pm(ctx):
  660.   global times_used
  661.   em=discord.Embed(title="choose the meme you want to post")
  662.   em.add_field(name="type '''f'''", value="fresh meme",inline=False)
  663.   em.add_field(name="type '''r'''", value="Reposted meme",inline=False)
  664.   em.add_field(name="type '''n'''", value="nerdy meme",inline=False)
  665.   em.add_field(name="type '''c'''", value="cursed meme",inline=False)
  666.   em.add_field(name="type '''w'''", value="Wholesome ",inline=False)
  667.   await ctx.reply(embed=em)
  668.   def check(msg):
  669.         return msg.author == ctx.author and msg.channel == ctx.channel and \
  670.         msg.content.lower() in ["f","r","n","c","w"]
  671.  
  672.   msg = await client.wait_for("message", check=check)
  673.  
  674.   await open_account(ctx.author)
  675.   random_number=random.randrange(200,300)
  676.   random_number2=random.randrange(700,1500)
  677.   user = ctx.author
  678.   users = await get_bank_data()
  679.   inv = users[str(user.id)]["bag"]
  680.   for thing in inv:
  681.       reqitem = "laptop"
  682.       if thing["item"] == reqitem:
  683.           if thing["amount"]>0:
  684.               a = random.randint(1,3)
  685.               if a == 1:
  686.                 await ctx.reply(f"Your meme went Viral! You got {random_number2} dollars from the Ad revenue!")
  687.                 await update_bank(ctx.author,random_number2)
  688.                 return
  689.               if a == 2:
  690.                 await ctx.reply(f"Your meme got a decent response. You earned {random_number} dollars from the Ad Revenue.")
  691.                 await update_bank(ctx.author,random_number)
  692.                 return
  693.               if a == 3:
  694.                 await ctx.reply("Bruh your meme sucks. You got nothingπŸ‘Ž")
  695.                 await update_bank(ctx.author,0)
  696.                 return
  697.              
  698.              
  699.  
  700.  
  701.                
  702.  
  703. #================admin command================================
  704. @client.command(aliases=["am","givemoney","gm"])
  705. async def addmoney(ctx,member:discord.Member = None,amount = None):
  706.     if ctx.author.id == 671635704811618305:
  707.         if member == ctx.author:
  708.             await ctx.send("No :)")
  709.             return
  710.         await open_account(member)
  711.  
  712.         if amount == None:
  713.             await ctx.send(f"How much money do you want me to add to {member.name}'s account?")
  714.             return
  715.  
  716.         if member == None:
  717.             await ctx.send("who do you want to give the money to?")
  718.  
  719.         bal = await update_bank(ctx.author)
  720.  
  721.         amount = int(amount)
  722.         if amount < 0:
  723.             await ctx.send("amount MUST be positive...")
  724.             return
  725.  
  726.         await update_bank(member,amount, "bank")
  727.  
  728.         await ctx.send(f"you just added {amount} to {member} balance!")
  729.     else:
  730.         await ctx.send("You are not allowed to execute this command")
  731. #=====================daily commands=========================================
  732. @client.command(aliases=["daily"])
  733. async def daily_money(ctx):
  734.     await open_account(ctx.author)
  735.     users = await get_bank_data()
  736.     user = ctx.author
  737.     if users[str(user.id)]["last_daily"] == 0:
  738.         users[str(user.id)]["last_daily"] = int(time.time())
  739.         users[str(user.id)]["wallet"] += 100
  740.         with open("mainbank.json","w") as f:
  741.             json.dump(users,f)
  742.         await ctx.send("You just got 100 dollars from the daily money!")
  743.     else:
  744.         last_daily = users[str(user.id)]["last_daily"]
  745.         now = int(time.time())
  746.         if now - last_daily < 86400:
  747.             await ctx.send("You already got your daily money!")
  748.         else:
  749.             users[str(user.id)]["last_daily"] = int(time.time())
  750.             users[str(user.id)]["wallet"] += 100
  751.             with open("mainbank.json","w") as f:
  752.                 json.dump(users,f)
  753.             await ctx.send("You just got 100 dollars from the daily money!")
  754.    
  755. keep_alive()
  756. client.run("token")
  757.  
  758. """π•„π•’π•šπ•Ÿπ•“π•’π•Ÿπ•œ.π•›π•€π• π•Ÿ"""
  759. {"620182789173542922": {"wallet": 871499, "bank": 8900078, "last_daily": 0, "bag": [{"item": "fishingpole", "amount": 1}, {"item": "woodensword", "amount": 1}, {"item": "laptop", "amount": 1}, {"item": "watch", "amount": 1}, {"item": "pc", "amount": 1}, {"item": "phone", "amount": 1}, {"item": "axe", "amount": 2}, {"item": "pickaxe", "amount": 2}, {"item": "uncommon-fish", "amount": 2}, {"item": "stone", "amount": 1}, {"item": "oak-wood", "amount": 1}, {"item": "rabbit", "amount": 1}, {"item": "epic-fish", "amount": 1}, {"item": "coal", "amount": 1}]}, "671635704811618305": {"wallet": 105764.0, "bank": 78632394, "last_daily": 1650742799, "bag": [{"item": "laptop", "amount": 1}, {"item": "fishingpole", "amount": 1}, {"item": "woodensword", "amount": 1}, {"item": "pickaxe", "amount": 1}, {"item": "axe", "amount": 1}, {"item": "phone", "amount": 1}, {"item": "common-fish", "amount": 3}, {"item": "uncommon-fish", "amount": 4}, {"item": "duck", "amount": 0}, {"item": "rabbit", "amount": 1}, {"item": "oak-wood", "amount": 1}, {"item": "stone", "amount": 0}]}, "724275771278884906": {"wallet": 100, "bank": 90100, "last_daily": 0, "bag": [{"item": "fishingpole", "amount": 1}]}, "795607989921906728": {"wallet": -112, "bank": 100000000, "last_daily": 0}, "370910692989206542": {"wallet": 165.0, "bank": 990000, "last_daily": 0, "bag": [{"item": "fishingpole", "amount": 0}, {"item": "uncommon-fish", "amount": 0}, {"item": "common-fish", "amount": 0}, {"item": "woodensword", "amount": 1}, {"item": "duck", "amount": 0}]}, "580087537822072842": {"wallet": 0, "bank": 90000, "last_daily": 0, "bag": [{"item": "fishingpole", "amount": 1}]}, "713557264107176019": {"wallet": 45000, "bank": 0, "last_daily": 0, "bag": [{"item": "pickaxe", "amount": 1}, {"item": "axe", "amount": 1}]}, "713119457471627325": {"wallet": 100, "bank": 0, "last_daily": 1650742749,"bag":[]}

Raw Paste


Login or Register to edit or fork this paste. It's free.