async def give(self, ctx, mentioned_user: discord.Member = discord.Member, amount="0"): """Give a user money [Format: %give (@user) (amount)]""" try: amount = ex.remove_commas(amount) check = True except Exception as e: await ctx.send(f"> **{amount} is not a proper value.**") check = False try: if check: user_id = ctx.author.id if not await ex.check_in_game(user_id, ctx): await ex.register_user(user_id) if mentioned_user.id != user_id: current_amount = await ex.get_balance(user_id) if amount == 0: await ctx.send("> **Please specify an amount [Format: %give (@user) (amount)]**", delete_after=60) if amount > 0: if amount > current_amount: await ctx.send("> **You do not have enough money to give!**", delete_after=60) if amount <= current_amount: mentioned_money = await ex.get_balance(mentioned_user.id) new_amount = mentioned_money + amount subtracted_amount = current_amount - amount await ex.update_balance(mentioned_user.id, str(new_amount)) await ex.update_balance(user_id, str(subtracted_amount)) await ctx.send("> **Your money has been transferred.**") elif mentioned_user.id == user_id: await ctx.send("> **You can not give money to yourself!**") except Exception as e: log.console(e)
async def joingame(self, ctx, game_id=0, amount="0"): """Join a game [Format: %joingame (gameid) (bid)] [Aliases: jg]""" try: amount = ex.remove_commas(amount) user_id = ctx.author.id if await ex.process_bj_game(ctx, amount, user_id): game = await ex.get_game(game_id) if game is None: await ctx.send(f"> **{ctx.author}, {game_id} is not a valid game.**") else: if game[5] == ctx.channel.id: # Did not use already existing function due to incompatibility. await ex.add_player_two(game_id, user_id, amount) await ex.start_game(game_id) else: await ctx.send(f"> **{ctx.author}, that game ({game_id}) is not available in this text channel.**") except Exception as e: log.console(e)
async def blackjack(self, ctx, amount="0", versus="player"): """Start a game of BlackJack [Format: %blackjack (amount)] [Aliases: bj]""" try: amount = ex.remove_commas(amount) user_id = ctx.author.id if versus != "bot": if await ex.process_bj_game(ctx, amount, user_id): await ex.add_bj_game(user_id, amount, ctx, "player") else: if await ex.process_bj_game(ctx, amount, user_id): await ex.add_bj_game(user_id, amount, ctx, "bot") game_id = await ex.get_game_by_player(user_id) fake_bot_id = int(f"{ex.get_int_index(bot_id, 9)}{randint(1,999999999)}") await ex.add_player_two(game_id, fake_bot_id, amount) await ex.start_game(game_id) except Exception as e: log.console(e) pass
async def bet(self, ctx, *, balance="1"): """Bet your money [Format: %bet (amount)]""" try: balance = ex.remove_commas(balance) check = True except Exception as e: await ctx.send(f"> **{balance} is not a proper value.**") check = False try: if check: user_id = ctx.author.id if not await ex.check_in_game(user_id, ctx): keep_going = True if balance == 0: await ctx.send("> **You are not allowed to bet 0.**") keep_going = False if balance > 0: if keep_going: await ex.register_user(user_id) amount = await ex.get_balance(user_id) if balance > amount: await ctx.send(embed=await ex.create_embed(title="Not Enough Money", title_desc=f"**You do not have enough money to bet {balance:,}. You have {amount:,} Dollars.**" )) if balance <= amount: a = randint(1, 100) if a <= 50: if a <= 10: new_balance = round(balance) new_amount = round(amount - balance) await ctx.send(embed=await ex.create_embed(title="Bet Loss", title_desc=f"**<@{user_id}> Got Super Unlucky! You lost {new_balance:,} out of {balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) if a > 10: new_balance = round(balance - (balance / 2)) new_amount = round(amount - new_balance) await ctx.send(embed=await ex.create_embed(title="Bet Loss", title_desc=f"**<@{user_id}> Lost! You lost {new_balance:,} out of {balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) if a > 50: if a <= 60: new_balance = round(balance / 5) new_amount = round(amount + new_balance) await ctx.send(embed=await ex.create_embed(title="Bet Win", title_desc=f"**<@{user_id}> Won! You bet {balance:,} and received {new_balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) if a > 60: if a <= 70: new_balance = round(balance / 4) new_amount = round(amount + new_balance) await ctx.send(embed=await ex.create_embed(title="Bet Win", title_desc=f"**<@{user_id}> Won! You bet {balance:,} and received {new_balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) if a > 70: if a <= 80: new_balance = round(balance / 2) new_amount = round(amount + new_balance) await ctx.send(embed=await ex.create_embed(title="Bet Win", title_desc=f"**<@{user_id}> Won! You bet {balance:,} and received {new_balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) if a > 80: if a <= 90: new_balance = round(balance * 1.5) new_amount = round((amount - balance) + new_balance) await ctx.send(embed=await ex.create_embed(title="Bet Win", title_desc=f"**<@{user_id}> Won! You bet {balance:,} and received {new_balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) if a > 90: if a <= 99: new_balance = round(balance * 2) new_amount = round((amount - balance) + new_balance) await ctx.send(embed=await ex.create_embed(title="Bet Win", title_desc=f"**<@{user_id}> Won! You bet {balance:,} and received {new_balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) if a == 100: new_balance = round(balance * 3) new_amount = round((amount - balance) + new_balance) await ctx.send(embed=await ex.create_embed(title="Bet Win", title_desc=f"**<@{user_id}> Won! You bet {balance:,} and received {new_balance:,}. Your updated balance is {new_amount:,}.**")) await ex.update_balance(user_id, str(new_amount)) except Exception as e: log.console(e)
async def rps(self, ctx, choice='', amount="0"): """Play Rock Paper Scissors for Money [Format: %rps (r/p/s)(amount)][Aliases: rockpaperscissors]""" try: amount = ex.remove_commas(amount) check = True except Exception as e: await ctx.send(f"> **{amount} is not a proper value.**") check = False try: if check: if amount < 0: await ctx.send("> **You can't bet a negative number!**") elif amount >= 0: user_id = ctx.author.id await ex.register_user(user_id) if not await ex.check_in_game(user_id, ctx): current_balance = await ex.get_balance(user_id) if amount > current_balance: await ctx.send("> ** You do not have enough money **", delete_after=60) if amount <= current_balance: rps = ['rock', 'paper', 'scissors'] a = randint(0, 2) b = randint(0, 2) cd = int(amount // (1/1.5)) # using floor division instead of multiplication if amount == 0: cd = 0 if choice == '': choice = rps[a] compchoice = rps[b] if compchoice == 'rock': if choice == 'rock' or choice == 'r': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**We Both Chose {compchoice} and Tied! You get nothing!**")) if choice == 'paper' or choice == 'p': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**You Won {cd:,} Dollars! I chose {compchoice} while you chose {choice}!**")) await ex.update_balance(user_id, str(current_balance + cd)) if choice == 'scissors' or choice == 's': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors",title_desc=f"**You Lost {amount:,} Dollars! I chose {compchoice} while you chose {choice}!**")) await ex.update_balance(user_id, str(current_balance - amount)) if compchoice == 'paper': if choice == 'rock' or choice == 'r': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**You Lost {amount:,} Dollars! I chose {compchoice} while you chose {choice}!**")) await ex.update_balance(user_id, str(current_balance - amount)) check_amount = str(current_balance - amount) await ex.update_balance(user_id, check_amount) if choice == 'paper' or choice == 'p': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**We Both Chose {compchoice} and Tied! You get nothing!**")) if choice == 'scissors' or choice == 's': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**You Won {cd:,} Dollars! I chose {compchoice} while you chose {choice}!**")) await ex.update_balance(user_id, str(current_balance + cd)) if compchoice == 'scissors': if choice == 'rock' or choice == 'r': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**You Won {cd:,} Dollars! I chose {compchoice} while you chose {choice}!**")) await ex.update_balance(user_id, str(current_balance + cd)) if choice == 'paper' or choice == 'p': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**You Lost {amount:,} Dollars! I chose {compchoice} while you chose {choice}!**")) await ex.update_balance(user_id, str(current_balance - amount)) if choice == 'scissors' or choice == 's': await ctx.send(embed=await ex.create_embed(title="Rock Paper Scissors", title_desc=f"**We Both Chose {compchoice} and Tied! You get nothing!**")) await ctx.message.delete(delay=15) except Exception as e: log.console(e)