async def give(self, ctx, who, value): "Share some love by giving it to others <3" message = ctx.message their_id = message.mentions[0].id value = int(value) if ctx.author.id == message.mentions[0].id: await ctx.send("You cant send worms to yourself dummy") return else: balance = db.get_user_balance(message.author.id) if int(value) < 10: await ctx.send("You need to transfer a minimum of 10 worms.") return elif balance < value: await ctx.send("You dont have {} worms, you only have {} worms" ).format(value, balance) return # not enough money else: #give_gif db.modify_user_balance(ctx.author.id, value * -1) db.modify_user_balance(their_id, value) await ctx.send(love_gif_list[random.randint( 0, len(love_gif_list) - 1)]) await ctx.send("{} has sent {} worms to {}".format( message.author.mention, value, message.mentions[0].mention)) return
async def on_raw_reaction_add(self, payload): key = await self.http.get_message(payload.channel_id, payload.message_id) if ( payload.emoji.name in worm_emojis_list ): # and payload.user_id != int(key["author"]["id"]) and 749486563691593740 != int(key["author"]["id"]): db.modify_user_balance(payload.user_id, worm_emoji_amount)
async def daily(self, ctx): "Does your daily check in - works every 24 hours" db.modify_user_balance(ctx.author.id, int(db.get_config("daily_worms"))) await ctx.send(thumb_gif_list[random.randint(0, len(thumb_gif_list) - 1)]) await ctx.send("You collected {} worms for today :D".format( db.get_config("daily_worms")))
async def roulette(self, ctx, amount: int, *spaces): user_id = ctx.author.id balance = db.get_user_balance(user_id) #Validate user balance is sufficient and space is valid try: num_bets = len(spaces) total_amount = amount * num_bets except: total_amount = amount num_bets = 1 spaces = [spaces] if total_amount > balance: await ctx.send( "That would cost {} but you only have {} u broke ass bitch". format(total_amount, balance)) return for space in spaces: if str(space) not in outside_dict: try: if int(space) not in range(1, 37): await ctx.send( "{} is not a valid number, please choose 1-36". format(space)) return except: await ctx.send( "{} is not a valid space u mook".format(space)) return #Initiate new game if no current game, add wager to current game otherwise. db.modify_user_balance(user_id, -1 * total_amount) if self.game is not None: await self.game.add_wagers(user_id, amount, spaces) output_brackets = ["{}"] * num_bets output_string = "{} bet {:,} on {}".format( ctx.author, amount, ', '.join(output_brackets)) await ctx.send(output_string.format(*spaces)) else: output_brackets = ["{}"] * num_bets output_string = "{} bet {:,} on {}".format( ctx.author, amount, ', '.join(output_brackets)) await ctx.send(output_string.format(*spaces)) self.game = RouletteGame(self.bot, ctx) await self.game.add_wagers(user_id, amount, spaces) await ctx.send( "A new game of Not Rigged Roulette has started! User $roulette <amount> <space> to raise your bets!" ) await ctx.send("31s remaining!") async with ctx.typing(): await asyncio.sleep(21) await ctx.send("10 seconds remaining, RAISE UR BETS!") async with ctx.typing(): await asyncio.sleep(10) await self.game.resolve() self.game = None
async def prepare_cock(self, ctx): user_id = ctx.author.id balance = db.get_user_balance(user_id) cock_status = db.get_cock_status(user_id) cock_power = get_cock_power(cock_status) if cock_status != -1: await ctx.send("Your c**k is already prepared for battle, currently at {:.1f}% hardness".format(cock_power * 100)) return if balance < self.cock_price: await ctx.send("Your c**k is too mangled and bruised to battle, please wait until you can afford 100 for a c**k doctor before battling again.") return else: db.modify_user_balance(user_id, -1 * self.cock_price) db.set_cock_status(user_id, 0) await ctx.send("Your c**k is ready for battle, you tip your fluffer {} for their service".format(self.cock_price))
async def battlebet(self, ctx, amount: int, user_string: str): if self.cock_battle is None: await ctx.send("There is not active battle u w***e") return if not self.cock_battle.accepted: await ctx.send("The battle has not been accepted by {} yet".format(self.cock_battle.challenged.name)) return try: player_to_bet_on = match_string_to_user(self.bot, ctx, user_string) except: await ctx.send("No user found matching {}".format(user_string)) return if player_to_bet_on in [self.cock_battle.challenger, self.cock_battle.challenged]: user_id = ctx.author.id balance = db.get_user_balance(user_id) if amount > balance: await ctx.send("That would cost {}, you only have {} you chode".format(amount, balance)) return else: new_balance = db.modify_user_balance(user_id, -1 * amount) if player_to_bet_on == self.cock_battle.challenger: odds = 1/self.cock_battle.odds else: odds = self.cock_battle.odds amount_to_win = (amount * odds) + amount self.cock_battle.add_wager(ctx.author, player_to_bet_on, amount_to_win) await ctx.send("{} bet {:,} to win {:,} on {}s c**k, good luck!".format(ctx.author.name, amount, round(amount_to_win,2), player_to_bet_on)) else: await ctx.send("{} is not participating in the current battle you mook".format(player_to_bet_on)) return
async def resolve(self): winning_number = spin() results = determine_outside(winning_number) table = gfx.Table() table.add_wagers(self.wager_dict) table.mark_winning_space(winning_number) image_url = await table.render() results_string = "Winning number: {}".format(winning_number) embed_dict = { 'colour': discord.Colour(0x006400), 'author_name': results_string, 'fields': {}, 's3_image_url': image_url } for user_id, wager_list in self.wager_dict.items(): payout = 0 for wager in wager_list: if str(wager.space) in results: payout += outside_dict[str(wager.space)][1] * wager.amount elif wager.space == str(winning_number): payout += 36 * wager.amount new_balance = db.modify_user_balance(user_id, payout) user = await self.bot.fetch_user(user_id) text1 = user.name if payout > 0: text2 = "won {:,} worms, new balance is {:,}".format( payout, new_balance) else: text2 = "Better luck next time!" field_dict = {'name': text1, 'value': text2, 'inline': True} embed_dict['fields'][user_id] = field_dict await self.roulette_message.edit(embed=build_embed(embed_dict))
async def prepare_worm(self, ctx): '''Buy a fight worm''' user_id = ctx.author.id balance = db.get_user_balance(user_id) cock_status = db.get_cock_status(user_id) cock_power = get_cock_power(cock_status) if cock_status != -1: await ctx.send("Your battle worm is already prepared for battle, currently at {:.1f}% toughness".format(cock_power * 100)) return if balance < self.cock_price: await ctx.send("You don't have any worms!") return else: db.modify_user_balance(user_id, -1 * self.cock_price) db.set_cock_status(user_id, 0) await ctx.send("You exchanged {} worms for a rookie battle worm! Win fights and battles to level him up!".format(self.cock_price))
async def qp(self, ctx, number_of_tickets=1): """ Quickpick tickets, enter a number to choose how many you want! """ lottory_id = db.get_current_lottory() user_balance = db.get_user_balance(ctx.author.id) total_cost = ticket_cost * number_of_tickets if user_balance < total_cost: await ctx.send("That would cost {:,}, your balance is {:,}. Broke ass bitch".format(total_cost, user_balance)) return else: async with ctx.typing(): ticket_list = quickpick(number_of_tickets) progressive_add = number_of_tickets * ticket_cost * .1 db.add_ticket_to_user(ticket_list, lottory_id, ctx.author.id) new_balance = db.modify_user_balance(ctx.author.id, -1 * total_cost) db.modify_lottory_jackpot_prog(lottory_id, progressive_add) new_progressive = db.get_lottory_jackpot_prog(lottory_id) ticket_obj_list = list(map(lambda x: Ticket(x), ticket_list)) #Convert list of tickets to Ticket objects if len(ticket_list) <= 5: output_line_list = [] for ticket in ticket_list: output_line_list.append('Quickpick ticket {} purchased by {}, good luck!'.format(Ticket(ticket), ctx.author.name)) await ctx.send("\n".join(output_line_list)) if number_of_tickets > 500: await ctx.author.send("You bought {} tickets. I'm not going to send you all of them.".format(number_of_tickets)) else: for n in range(0, len(ticket_list), 50): await ctx.author.send("Lottory {} Quickpick tickets {}".format(lottory_id, ticket_list[n:n+50])) await ctx.send("{} spent {:,} on {:,} tickets, new balance is {:,}. The jackpot is now {:,}".format(ctx.author.name, total_cost, number_of_tickets, round(new_balance,2), payout_table[True][4]+new_progressive))
async def wormfight(self, ctx, amount:int): '''Test your worm in a fight to the death, each win increases your worms toughness and odds of winning! Buy a fightworm with !bw and then bet on the outcome of a fight with !wf <amount>''' user_id = ctx.author.id balance = db.get_user_balance(user_id) cock_status = db.get_cock_status(user_id) if self.cock_battle: if ctx.author == self.cock_battle.challenger or ctx.author == self.cock_battle.challenged: await ctx.send("You cannot participate in wormfights while your worm is preparing for battle") return if cock_status == -1: await ctx.send("Your worm is not ready for battle, prepare your worm with !prepare_worm first.") return if amount > balance: await ctx.send("That would cost {}, you only have {} :(".format(amount, balance)) return else: new_balance = db.modify_user_balance(user_id, -1 * amount) result = random.random() cock_power = get_cock_power(cock_status) if result < cock_power: amount_won = amount * 2 new_cock_status = cock_status + 1 new_balance = db.modify_user_balance(user_id, amount_won) db.set_cock_status(user_id, new_cock_status) result_msg = "Your worm made you {:,} worms richer".format(amount) hardness_msg= "Now at {:.1f}% toughness".format(get_cock_power(new_cock_status) * 100) embed_dict = {'colour':discord.Colour(0x00e553), 'author_name':ctx.author.name, 'fields': {1:{'name': result_msg, 'value': hardness_msg}}} await ctx.send(embed=build_embed(embed_dict)) else: db.set_cock_status(user_id, -1) result_msg = "Your worm got smoosh :(" embed_dict = {'colour':discord.Colour(0xe10531), 'author_name':ctx.author.name, 'fields': {1:{'name': 'Ouch', 'value': result_msg}}} await ctx.send(embed=build_embed(embed_dict))
async def withdraw(self,ctx,amount:int): '''Withdraws from Lotto balance, to be deposited manually to Ubeleivaboat balance''' balance = db.get_user_balance(ctx.author.id) if amount <= 0: ctx.send("You're broke u bitch") return if amount > balance: amount = balance new_balance = db.modify_user_balance(ctx.author.id, -1 * amount) await ctx.send("{} withdrew {:,}. Your new balance is {:,}. An admin will credit your RiggBott acount soon!".format(ctx.author.name, amount, new_balance)) admin = await self.bot.get_user_info(154415714411741185) await admin.send("Please run --> !add-money cash {} {} <--".format(ctx.author.name, amount))
async def buy_ticket(self, ctx, first: int, second: int, third: int, fourth: int, mega: int): """ Purchase a lottory ticket, enter all 5 numbers seperated by spaces. Valid tickets must have first 4 numbes between 1-23, and last number between 1-11. Use !bt qp <number> to purchase a number of quickpick tickets. Good luck! """ lottory_id = db.get_current_lottory() user_balance = db.get_user_balance(ctx.author.id) ticket = [first, second, third, fourth, mega] ticket_print = Ticket(ticket) if user_balance < ticket_cost: await ctx.send( "That would cost {:,}, your balance is {:,}. Broke ass bitch". format(ticket_cost, user_balance)) return #Validate ticket entry for number in ticket[:4]: if number not in numbers: await ctx.send( "{} is not a valid ticket, first 4 numbers must be between {}-{}}" .format(ticket, numbers[0], numbers[-1])) return if ticket[4] not in range(1, 12): await ctx.send( "{} is not a valid ticket, megaball must be between 1-11". format(ticket)) return for i in range(3): if ticket[i] in ticket[:i]: await ctx.send( "{} is not a valid ticket, first four numbers must be unique" .format(ticket_print)) return if ticket[i] in ticket[i + 1:4]: await ctx.send( "{} is not a valid ticket, first four numbers must be unique" .format(ticket_print)) return progressive_add = ticket_cost * .1 db.add_ticket_to_user([ticket], lottory_id, ctx.author.id) new_balance = db.modify_user_balance(ctx.author.id, -1 * ticket_cost) db.modify_lottory_jackpot_prog(lottory_id, progressive_add) new_progressive = db.get_lottory_jackpot_prog( lottory_id) + payout_table[True][4] await ctx.send( "{} purchased ticket {}, your balance is now {:,}. The progressive jackpot is now {:,}." .format(ctx.author.name, Ticket(ticket), new_balance, new_progressive))
async def cockfight(self, ctx, amount:int): user_id = ctx.author.id balance = db.get_user_balance(user_id) cock_status = db.get_cock_status(user_id) if self.cock_battle: if ctx.author == self.cock_battle.challenger or ctx.author == self.cock_battle.challenged: await ctx.send("You cannot participate in cockfights while your c**k is preparing for battle") return if cock_status == -1: await ctx.send("Your c**k is not ready for battle, prepare your lil c**k with $prepare_cock first.") return if amount > balance: await ctx.send("That would cost {}, you only have {} you chode".format(amount, balance)) return else: new_balance = db.modify_user_balance(user_id, -1 * amount) result = random.random() cock_power = get_cock_power(cock_status) if result < cock_power: amount_won = amount * 2 new_cock_status = cock_status + 1 new_balance = db.modify_user_balance(user_id, amount_won) db.set_cock_status(user_id, new_cock_status) result_msg = "Your lil c**k made you {:,} richer".format(amount) hardness_msg= "Now at {:.1f}% hardness <:peen:456499857759404035>".format(get_cock_power(new_cock_status) * 100) embed_dict = {'colour':discord.Colour(0x00e553), 'author_name':ctx.author.name, 'fields': {1:{'name': result_msg, 'value': hardness_msg}}} await ctx.send(embed=build_embed(embed_dict)) else: db.set_cock_status(user_id, -1) result_msg = "Your c**k snapped in half <:sad:455866480454533120>" embed_dict = {'colour':discord.Colour(0xe10531), 'author_name':ctx.author.name, 'fields': {1:{'name': 'Ouch', 'value': result_msg}}} await ctx.send(embed=build_embed(embed_dict))
async def resolve(self): winning_number = spin() results = determine_outside(winning_number) await self.ctx.send("Result is: {}{}".format(winning_number, ', '.join(results))) for user_id, wager_list in self.wager_dict.items(): payout = 0 for wager in wager_list: if str(wager.space) in results: payout += outside_dict[str(wager.space)][1] * wager.amount elif wager.space == str(winning_number): payout += 36 * wager.amount new_balance = db.modify_user_balance(user_id, payout) user = await self.bot.get_user_info(user_id) await self.ctx.send("{} won {:,}, new balance is {:,}".format( user.name, payout, new_balance))
async def money_please(self, ctx, amount: int): '''Adds amount to all non bot users balances''' if ctx.author.id != 154415714411741185: #My user.id await ctx.send("You're not my real dad bitch!") return user_id_list = db.get_user() #Returns a list of all users for user_id in user_id_list: user = await self.bot.get_user_info(user_id[0]) if not user.bot: new_balance = db.modify_user_balance(user_id[0], amount) await ctx.send( 'Added {} to {}\'s balance. New balance is {}'.format( amount, user.name, new_balance))
async def on_message(self, message): '''Accepts deposits from Unbeleivaboat''' channel = message.channel if message.author.id == 292953664492929025: #Unbeleivaboat user.id try: sender_url = message.embeds[0].author.icon_url description = message.embeds[0].description receiver_id = int(re.findall(r'<@!(\d+)>', description)[0]) amount = int( re.findall(r'your .(\d{1,3}(,\d{3})*(\.\d+)?)', description)[0][0].replace(',', '')) sender_id = int(re.findall(r'tars/(\d+)/', sender_url)[0]) except: return if receiver_id == 456460945074421781: #Lotto-bot user.id new_balance = db.modify_user_balance(sender_id, amount) sender = await self.bot.get_user_info(sender_id) await channel.send( "{:,} received from {}. Your balance is now {:,}".format( amount, sender.name, new_balance))
async def roulette(self, ctx, amount: int, *spaces): '''Plays a game of worm roulette. Add bets with !roulette <amount> <space>''' user_id = ctx.author.id balance = db.get_user_balance(user_id) #Validate user balance is sufficient and space is valid try: num_bets = len(spaces) total_amount = amount * num_bets except: total_amount = amount num_bets = 1 spaces = [spaces] if total_amount > balance: await ctx.send( "That would cost {} worms but you only have {} worms".format( total_amount, balance)) return for space in spaces: if str(space) not in outside_dict: try: if int(space) not in range(1, 37): await ctx.send( "{} is not a valid number, please choose 1-36". format(space)) return except: await ctx.send( "{} is not a valid space u mook".format(space)) return #Initiate new game if no current game, add wager to current game otherwise. db.modify_user_balance(user_id, -1 * total_amount) if self.game is not None: image_url = await self.game.add_wagers(user_id, amount, spaces) new_game_string = "A new game of Worm Roulette started!" embed_dict = { 'colour': discord.Colour(0x006400), 'author_name': new_game_string, 'fields': {}, } embed_dict['fields'][0] = { 'name': 'Type !roulette <wager> <space> to bet!', 'value': '------------' } for user_id, wager_list in self.game.wager_dict.items(): user = await self.bot.fetch_user(user_id) output_string = "" embed_dict['fields'][user.id] = {'inline': True} for wager in wager_list: output_string += "Bet {:,} on {} \n".format( wager.amount, wager.space) embed_dict['fields'][user.id]['value'] = output_string embed_dict['fields'][user.id]['name'] = user.name embed_dict['s3_image_url'] = image_url await self.game.roulette_message.edit(embed=build_embed(embed_dict) ) else: output_brackets = ["{}"] * num_bets output_string = "Bet {:,} on {}".format(amount, ', '.join(output_brackets)) new_game_string = "Worm Roulette started!" embed_dict = { 'colour': discord.Colour(0x006400), 'author_name': new_game_string, 'fields': {}, } embed_dict['fields'][0] = { 'name': 'Type !roulette <wager> <space> to bet!', 'value': '------------' } embed_dict['fields'][ctx.author.id] = { 'name': ctx.author.name, 'value': output_string.format(*spaces), 'inline': True } self.game = RouletteGame(self.bot, ctx) image_url = await self.game.add_wagers(user_id, amount, spaces) text2 = "30s remaining!" embed_dict['fields']['0'] = { 'name': 'Place your bets!', 'value': text2, 'inline': True } embed_dict['s3_image_url'] = image_url self.game.roulette_message = await ctx.send( embed=build_embed(embed_dict)) async with ctx.typing(): await asyncio.sleep(20) async with ctx.typing(): await asyncio.sleep(10) await self.game.resolve() self.game = None
async def wormbattle(self, ctx, user, purse=0): '''Challenge another users worm to a battle to the death, anyone can bet on the outcome''' if purse > db.get_user_balance(ctx.author.id): ctx.send("You don't have {} worms!".format(purse)) if self.cock_battle is not None: await ctx.send("Only one worm battle at a time, wait for {} and {} to finish their battle!".format(self.cock_battle.challenger.name, self.cock_battle.challenged.name)) return if db.get_cock_status(ctx.author.id) == -1: await ctx.send("You don't have a battleworm") return try: challenged_user = ctx.message.mentions[0] except: await ctx.send("You need to mention a user to challenge them!") if db.get_cock_status(challenged_user.id) == -1: await ctx.send("{} doesn't have a battleworm!".format(challenged_user.name)) return if challenged_user == ctx.author: await ctx.send("Try punching yourself in the face instead?") return self.cock_battle = CockBattle(self.bot, ctx, ctx.author, challenged_user, purse=purse) embed_dict = {'colour':discord.Colour(0xffa500), 'author_name':"Worm Battle Challenge!", 'fields': {1:{'name': self.cock_battle.challenger.name, 'value': "{:.1f}% <:Worm:752975370231218178> @{:.2f}:1 odds".format(get_cock_power(self.cock_battle.challenger_cock_status)*100, 1/self.cock_battle.odds), 'inline': True}, 2:{'name': "VS", 'value': '-', 'inline': True}, 3:{'name': self.cock_battle.challenged.name, 'value': "{:.1f}% <:Worm:752975370231218178> @{:.2f}:1 odds".format(get_cock_power(self.cock_battle.challenged_cock_status)*100, self.cock_battle.odds), 'inline': True}, 4:{'name': "```{} has 60s to accept the challenge!```".format(self.cock_battle.challenged.name), 'value': 'Use <!challenge_accepted> to accept!', 'inline': False} } } battle_message = await ctx.send(embed = build_embed(embed_dict)) wait_cycles = 0 while self.cock_battle.accepted == False and wait_cycles < 60: await asyncio.sleep(time_to_accept_battle//60) wait_cycles += 1 if wait_cycles in [50, 30, 15]: embed_dict['fields'][4] = {'name': "```{} has {}s to accept the challenge!```".format(self.cock_battle.challenged.name, (time_to_accept_battle/60) * (60 - wait_cycles)), 'value': 'Use <!challenge_accepted> to accept!', 'inline': False} await battle_message.edit(embed=build_embed(embed_dict)) if self.cock_battle.accepted: embed_dict['colour'] = discord.Colour(0x00e553) embed_dict['author_name'] = "Worm Battle Accepted!" embed_dict['fields'][4] = {'name': "```60s until the battle!```", 'value': 'Type !bb <amount> <user> to place your bets!', 'inline': False} await battle_message.edit(embed=build_embed(embed_dict)) wait_cycles = 0 while wait_cycles < 12: await asyncio.sleep(time_to_battle//12) wait_cycles += 1 if wait_cycles in [10, 6, 3]: embed_dict['fields'][4] = {'name': "```{}s until the battle!```".format((time_to_battle/12) * (12 - wait_cycles)), 'value': 'Type !bb <amount> <user> to place your bets!', 'inline': False} await battle_message.edit(embed=build_embed(embed_dict)) embed_dict['author_name'] = "Battle Results Below!" embed_dict['colour'] = discord.Colour(0xd3d3d3) embed_dict['fields'][4] = {'name': "```Battle!```", 'value': 'Results below!', 'inline': False} await battle_message.edit(embed=build_embed(embed_dict)) rounds, winner, loser = self.cock_battle.resolve_battle() db.modify_user_balance(winner.id, self.cock_battle.purse) db.set_cock_status(loser.id, -1) if loser == self.cock_battle.challenger: donated_cock_power = ((self.cock_battle.challenger_cock_status) / 2) + 1 embed_dict['fields'][3]['name'] = "{}:white_check_mark:".format(self.cock_battle.challenged.name) db.set_cock_status(winner.id, self.cock_battle.challenged_cock_status + donated_cock_power) else: donated_cock_power = ((self.cock_battle.challenged_cock_status) / 2) + 1 embed_dict['fields'][1]['name'] = "{}:white_check_mark:".format(self.cock_battle.challenger.name) db.set_cock_status(winner.id, self.cock_battle.challenger_cock_status + donated_cock_power) results = [] for user, amount_won in self.cock_battle.wagers[winner].items(): new_user_balance = db.modify_user_balance(user.id, amount_won) results.append("{} won {:,} worms, new balance is {:,}".format(user, round(amount_won,2), round(new_user_balance,2))) embed_dict['author_name'] = "{}s battleworm won the battle!".format(winner.name) embed_dict['colour'] = discord.Colour(0x0077be) embed_dict['fields'][4] = {'name': "{} battleworm was victorious in round {} and wins {} from the purse!".format(winner.name, rounds, self.cock_battle.purse), 'value': "{}\% is added to his battleworms toughness".format(donated_cock_power), 'inline': False} await ctx.send(embed=build_embed(embed_dict)) self.cock_battle = None await ctx.send("\n".join(results)) else: embed_dict['author_name'] = "Worm Battle Aborted!" embed_dict['colour'] = discord.Colour(0xe10531) embed_dict['fields'][4] = {'name': "```{} did not accept, the battle is cancelled!```".format(self.cock_battle.challenged.name), 'value': 'Challenge someone awake next time!', 'inline': False} await battle_message.edit(embed=build_embed(embed_dict)) self.cock_battle = None
async def draw(self,ctx): '''Start the next drawing''' lottory_id = db.get_current_lottory() progressive = db.get_lottory_jackpot_prog(lottory_id) total_jackpot = progressive + payout_table[True][4] ticket_list = db.get_lottory_tickets(lottory_id) #List of tuples (user_id, ticket_value) if len(ticket_list) < 1: #Verify there is at least 1 ticket sold before allowing drawing await ctx.send("There are no tickets sold for this drawing yet!") return db.add_lottory() #increment current when drawing starts winning_numbers = quickpick()[0] #Choose winning numbers balls = {0:'First', 1:'Second', 2:'Third', 3:'Fourth', 4:'MEGA'} embed_dict = {'colour':discord.Colour(0x006400), 'author_name':"Drawing for lottory {}! Jackpot is currently {:,}".format(lottory_id,total_jackpot), 'fields': {} } lottory_message = await ctx.send(embed=build_embed(embed_dict)) async with ctx.typing(): winning_ticket_display = [] for ball_number, ball_name in balls.items(): await asyncio.sleep(3) winning_ticket_display.append(str(winning_numbers[ball_number])) embed_dict['fields'][1] = {'name': "{} Ball".format(ball_name), 'value': winning_numbers[ball_number], 'inline': True} winning_numbers_value = "-".join(winning_ticket_display) if len(winning_ticket_display) < 5 else Ticket(winning_numbers) embed_dict['fields'][2] = {'name': 'Winning Numbers' , 'value': winning_numbers_value, 'inline': True} await lottory_message.edit(embed=build_embed(embed_dict)) num_tickets = len(ticket_list) progressive_split = [] winner_dict = {} loser_dict = {} total_payout = 0 async with ctx.typing(): for ticket_tuple in ticket_list: ticket_value = eval(ticket_tuple[0]) #ticket value stored as a string, convert back to list user_id = ticket_tuple[1] mega, match = parse_ticket(winning_numbers, ticket_value) ticket_payout = determine_payout(mega, match) if ticket_payout != 0: winner_dict = add_ticket_to_dict(winner_dict, user_id, ticket_value, ticket_payout) else: loser_dict = add_ticket_to_dict(loser_dict, user_id, ticket_value, ticket_payout) results = {} async with ctx.typing(): for user_id, list_of_winning_tickets in winner_dict.items(): balance_modifier = 0 for ticket_tuple in list_of_winning_tickets: ticket_value = Ticket(ticket_tuple[0]) ticket_payout = ticket_tuple[1] if ticket_payout == payout_table[True][4]: progressive_split.append([user_id, ticket_value]) else: balance_modifier += ticket_payout new_user_balance = db.modify_user_balance(user_id, balance_modifier) results[user_id] = [balance_modifier, new_user_balance, list_of_winning_tickets] total_payout += balance_modifier jackpot_results = {} if len(progressive_split) > 0: jackpot_progressive_share = round(progressive / len(progressive_split), 2) jackpot_payout = round(payout_table[True][4] + jackpot_progressive_share, 2) for ticket_tuple in progressive_split: user_id = ticket_tuple[0] ticket_value = ticket_tuple[1] total_payout += jackpot_payout new_user_balance = db.modify_user_balance(user_id, jackpot_payout) if user_id not in jackpot_results: jackpot_results[user_id] = [jackpot_payout, new_user_balance, [ticket_value], jackpot_progressive_share] else: jackpot_results[user_id][0] += jackpot_payout jackpot_results[user_id][1] = new_user_balance jackpot_results[user_id][2].append(ticket_value) jackpot_results[user_id][3] += jackpot_progressive_share split_won = 'won' if len(jackpot_results) == 1 else 'split' await ctx.send("------------JACKPOT WINNAR!!!!!!-------------") for user_id, result in jackpot_results.items(): jackpot_payout = result[0] new_user_balance = result[1] ticket_values = result[2] if len(result[2]) <= 10 else len(result[2]) progressive_split = result[3] user = await self.bot.get_user_info(user_id) await ctx.send('{} {} the Jackpot! Payout {:,}, your share of the progressive is {:,}! with {} tickets!!'.format(user.name, split_won, round(jackpot_payout,2), round(progressive_split,2), ticket_values)) await user.send('You {} the Jackpot for lottory {} with ticket {}! {:,} has been deposited into your account. Your new balance is {}.'.format(split_won, lottory_id, ticket_value, round(jackpot_payout,2), new_user_balance)) for user_id, result in results.items(): jackpot_balance_modifier = jackpot_results[user_id][0] if user_id in jackpot_results else 0 balance_modifier = result[0] + jackpot_balance_modifier new_user_balance = result[1] winning_tickets = result[2] user = await self.bot.get_user_info(user_id) embed_dict['fields'][user_id] = {'name': user.name, 'value': "Won a total of {:,} on {:,} winning tickers!".format(balance_modifier, len(winning_tickets)), 'inline': False} await user.send("Lottory {} Results: You won {:,}. Your new balance is {:,}.".format(lottory_id, balance_modifier, new_user_balance)) if len(winning_tickets) < 100: for n in range(0, len(winning_tickets), 50): await user.send("Your winnings tickets for Lottory {}: Winning Numbers:{} Your winners: {}".format(lottory_id, winning_numbers, winning_tickets[n:n+50])) await lottory_message.edit(embed=build_embed(embed_dict)) income = ticket_cost * num_tickets payout_ratio = 100 * (total_payout - income) / income db.update_lottory_stats(lottory_id, income, total_payout) embed_dict['author_name'] = "Lottory {} ended!".format(lottory_id) embed_dict['fields'][0] = {"name": "{:,} tickets were sold for {:,}".format(num_tickets, income), 'value':"{:,} was paid out for a payout ratio of {}%".format(round(total_payout, 2), round(payout_ratio, 2))} await lottory_message.edit(embed=build_embed(embed_dict)) if len(progressive_split) == 0: lottory_id = db.get_current_lottory() #Add progressive to next lottory db.modify_lottory_jackpot_prog(lottory_id, progressive) else: await ctx.send("Jackpot has been reseeded to {:,}".format(payout_table[True][4]))
async def cockbattle(self, ctx, user_string: str, purse=0): if purse > db.get_user_balance(ctx.author.id): ctx.send( "You don't have {} to fund the purse you broke ass bitch!". format(purse)) if self.cock_battle is not None: await ctx.send( "Only one c**k battle at a time u s**t, wait for {} and {} to finish their battle!" .format(self.cock_battle.challenger.name, self.cock_battle.challenged.name)) return if db.get_cock_status(ctx.author.id) == -1: await ctx.send("You don't have a c**k") return try: challenged_user = match_string_to_user(self.bot, ctx, user_string) except: await ctx.send("No user found matching that name") if db.get_cock_status(challenged_user.id) == -1: await ctx.send("{} doesn't have a c**k!".format( challenged_user.name)) return if challenged_user == ctx.author: await ctx.send("Try punching yourself in the face instead") return self.cock_battle = CockBattle(self.bot, ctx, ctx.author, challenged_user, purse=purse) embed_dict = { 'colour': discord.Colour(0xffa500), 'author_name': "C**k Battle Challenge!", 'fields': { 1: { 'name': self.cock_battle.challenger.name, 'value': "{:.1f}% <:peen:456499857759404035> @{:.2f}:1 odds".format( get_cock_power(self.cock_battle.challenger_cock_status) * 100, 1 / self.cock_battle.odds), 'inline': True }, 2: { 'name': "VS", 'value': '-', 'inline': True }, 3: { 'name': self.cock_battle.challenged.name, 'value': "{:.1f}% <:peen:456499857759404035> @{:.2f}:1 odds".format( get_cock_power(self.cock_battle.challenged_cock_status) * 100, self.cock_battle.odds), 'inline': True }, 4: { 'name': "```{} has 60s to accept the challenge!```".format( self.cock_battle.challenged.name), 'value': 'Use <$challenge_accepted> to accept!', 'inline': False } } } battle_message = await ctx.send(embed=build_embed(embed_dict)) wait_cycles = 0 while self.cock_battle.accepted == False and wait_cycles < 60: await asyncio.sleep(time_to_accept_battle // 60) wait_cycles += 1 if wait_cycles in [50, 30, 15]: embed_dict['fields'][4] = { 'name': "```{} has {}s to accept the challenge!```".format( self.cock_battle.challenged.name, (time_to_accept_battle / 60) * (60 - wait_cycles)), 'value': 'Use <$challenge_accepted> to accept!', 'inline': False } await battle_message.edit(embed=build_embed(embed_dict)) if self.cock_battle.accepted: embed_dict['colour'] = discord.Colour(0x00e553) embed_dict['author_name'] = "C**k Battle Accepted!" embed_dict['fields'][4] = { 'name': "```60s until the battle!```", 'value': 'Use <$bb amount user> to raise your bets!', 'inline': False } await battle_message.edit(embed=build_embed(embed_dict)) wait_cycles = 0 while wait_cycles < 12: await asyncio.sleep(time_to_battle // 12) wait_cycles += 1 if wait_cycles in [10, 6, 3]: embed_dict['fields'][4] = { 'name': "```{}s until the battle!```".format( (time_to_battle / 12) * (12 - wait_cycles)), 'value': 'Use <$bb amount user> to raise your bets!', 'inline': False } await battle_message.edit(embed=build_embed(embed_dict)) embed_dict['author_name'] = "Battle Results Below!" embed_dict['colour'] = discord.Colour(0xd3d3d3) embed_dict['fields'][4] = { 'name': "```Battle!```", 'value': 'Results below!', 'inline': False } await battle_message.edit(embed=build_embed(embed_dict)) rounds, winner, loser = self.cock_battle.resolve_battle() db.modify_user_balance(winner.id, self.cock_battle.purse) db.set_cock_status(loser.id, -1) if loser == self.cock_battle.challenger: donated_cock_power = ( (self.cock_battle.challenger_cock_status) / 2) + 1 embed_dict['fields'][3][ 'name'] = "{}:white_check_mark:".format( self.cock_battle.challenged.name) db.set_cock_status( winner.id, self.cock_battle.challenged_cock_status + donated_cock_power) else: donated_cock_power = ( (self.cock_battle.challenged_cock_status) / 2) + 1 embed_dict['fields'][1][ 'name'] = "{}:white_check_mark:".format( self.cock_battle.challenger.name) db.set_cock_status( winner.id, self.cock_battle.challenger_cock_status + donated_cock_power) results = [] for user, amount_won in self.cock_battle.wagers[winner].items(): new_user_balance = db.modify_user_balance(user.id, amount_won) results.append("{} won {:,}, new balance is {:,}".format( user, round(amount_won, 2), round(new_user_balance, 2))) embed_dict['author_name'] = "{}s c**k won the battle!".format( winner.name) embed_dict['colour'] = discord.Colour(0x0077be) embed_dict['fields'][4] = { 'name': "{} c**k was victorious in round {} and wins {} from the purse!" .format(winner.name, rounds, self.cock_battle.purse), 'value': "{}\% is added to his cocks power from his vanquished foe". format(donated_cock_power), 'inline': False } await ctx.send(embed=build_embed(embed_dict)) self.cock_battle = None await ctx.send("\n".join(results)) else: embed_dict['author_name'] = "C**k Battle Aborted!" embed_dict['colour'] = discord.Colour(0xe10531) embed_dict['fields'][4] = { 'name': "```{} did not accept, the battle is cancelled!```".format( self.cock_battle.challenged.name), 'value': 'Challenge someone awake next time!', 'inline': False } await battle_message.edit(embed=build_embed(embed_dict)) self.cock_battle = None
async def steal(self, ctx, target, amount: int): '''Try to steal worms from another user, but be careful it may backfire! The more worms you attempt to steal, the less likely it is to succeed''' try: target = ctx.message.mentions[0] except: await ctx.send("No valid user found!") await ctx.command.reset_cooldown(ctx) return target_balance = db.get_user_balance(target.id) user_balance = db.get_user_balance(ctx.author.id) if amount < 10: await ctx.send("You have to steal at least 10 worms!") await ctx.command.reset_cooldown(ctx) return if target_balance < 100: await ctx.send( "{} is too poor to steal from, find another target!".format( target.mention)) await ctx.command.reset_cooldown(ctx) return if amount > target_balance: await ctx.send( "{} only has {} worms, so I guess you're trying to steal all of them" .format(target.mention, target_balance)) amount = target_balance base_difficulty = 10 ratio = round(amount / target_balance, 2) total_difficulty = math.ceil(base_difficulty + (10 * ratio)) result = random.randint(1, 20) await ctx.send( "Attempting to steal {}% of {} worms, you'll need to roll {} or better!" .format(ratio * 100, target.mention, total_difficulty)) gif_message = await ctx.send('https://tenor.com/ba6fL.gif') await asyncio.sleep(5) if result >= total_difficulty: db.modify_user_balance(target.id, -1 * amount) db.modify_user_balance(ctx.author.id, amount) await ctx.send( "{} rolled a {} and successfully stole {} worms from {}". format(ctx.author.mention, result, amount, target.mention)) await gif_message.edit(content="https://tenor.com/bmxN5.gif") ctx.command.reset_cooldown(ctx) elif 1 < result < 6: backfire_percent = random.uniform(.1, .5) backfire_amount = round(user_balance * backfire_percent) await ctx.send( "{} rolled a {}, got caught by the police and were forced to pay {} {} worms instead" .format(ctx.author.mention, result, target.mention, backfire_amount)) db.modify_user_balance(target.id, backfire_amount) db.modify_user_balance(ctx.author.id, -1 * backfire_amount) await gif_message.edit(content="https://tenor.com/bia0L.gif") elif result == 1: await ctx.send( "{} rolled a {}, now all their worms are belong to {}".format( ctx.author.mention, result, target.mention)) db.modify_user_balance(ctx.author.id, -1 * user_balance) db.modify_user_balance(target.id, user_balance) await gif_message.edit(content="https://tenor.com/btHVc.gif") else: await ctx.send("{} rolled a {}, nothing happened!".format( ctx.author.mention, result)) await gif_message.edit(content="https://tenor.com/6ziX.gif")