async def openbets(ctx): '''DEALER ONLY. Opens the table for betting, allows users to place bets with $bet <amount>''' global betsOpen if ctx.message.channel.id in global_constants.validChannels: # Only execute if the message author is a dealer. if isDealer(ctx.author): # Delete all messages in chat messages = [] async for message in ctx.channel.history(limit=int(100)): messages.append(message) await message.channel.delete_messages(messages) # If there are bets existing... if bool(currentBets) == True: await ctx.send(embed=dialogBox( 'warning', 'The dealer is yet to pay out some bets.', 'Check the open bets with `$unpaidbets`.')) # If bets are already open... elif betsOpen: await ctx.send( embed=dialogBox('warning', 'Bets are already open', 'Close them with `$closebets`.')) # If bets aren't open and there aren't any existing bets, then open bets. else: betsOpen = True await ctx.send(embed=dialogBox( 'tick', 'Bets are now open!', 'Place your bets with `$bet <number>` (e.g. `$bet 50`)')) else: await ctx.send(embed=dialogBox( 'error', 'Only the dealer has access to this command.'))
async def pay(ctx, userMentionString, payoutRatio): '''DEALER ONLY. Pays the @'ed user out. For example, `$pay @Jess 2x` will give Jess back $100 on a bet of $50. Ensure that the username after the @ is an actual mention (i.e. it pings the user).''' if ctx.message.channel.id in global_constants.validChannels: if isDealer(ctx.author): if global_constants.deleteDealerMessages == True: await ctx.message.delete() dbUser = userInDatabase(int(convertMentionToID(userMentionString))) if int(convertMentionToID(userMentionString)) not in currentBets: await ctx.send( dialogBox( 'warning', 'No bets currently standing for this user.', 'They may have not placed a bet, or the dealer may have already paid them out.' )) else: payoutResponse = payUserOut(ctx, userMentionString, payoutRatio, 'win') finaldialog = dialogBox( 'winner', '{user} wins!'.format(user=dbUser.real_name), 'The house has paid <@!{userID}> a total of **{amount}**, and their wallet balance is now **{balance}**.' .format(userID=dbUser.dc_uniqueid, amount=asMoney(payoutResponse), balance=asMoney(dbUser.wallet))) finaldialog.set_thumbnail( url=getAvatarURL(ctx, dbUser.dc_uniqueid)) await ctx.send(embed=finaldialog) else: await ctx.send(embed=dialogBox( 'error', 'Only the dealer has access to this command.'))
async def push(ctx, userMentionString): '''DEALER ONLY. Refunds a user's bet in the event of a push. An alias of $pay <user> 1x.''' if ctx.message.channel.id in global_constants.validChannels: if isDealer(ctx.author): if global_constants.deleteDealerMessages == True: await ctx.message.delete() dbUser = userInDatabase(int(convertMentionToID(userMentionString))) if int(convertMentionToID(userMentionString)) not in currentBets: await ctx.send( dialogBox( 'warning', 'No bets currently standing for this user.', 'They may have not placed a bet, or the dealer may have already paid them out.' )) else: payoutResponse = payUserOut(ctx, userMentionString, 1, 'win') finaldialog = dialogBox( 'push', '{user} pushes!'.format( user=payoutResponse['userWhoGotPaid'].real_name), 'The house has refunded <@!{userID}>\'s bet of **{amount}**, and their wallet balance is now back at **{balance}**.' .format(userID=dbUser.dc_uniqueid, amount=asMoney(payoutResponse), balance=asMoney(dbUser.wallet))) finaldialog.set_thumbnail( url=getAvatarURL(ctx, dbUser.dc_uniqueid)) await ctx.send(embed=finaldialog) else: await ctx.send(embed=dialogBox( 'error', 'Only the dealer has access to this command.'))
async def closebets(ctx): '''DEALER ONLY. Closes the table for betting, barring players from placing bets with the $bet command''' global betsOpen if ctx.message.channel.id in global_constants.validChannels: if global_constants.deleteDealerMessages == True: await ctx.message.delete() # Only execute if the message author is a dealer. if isDealer(ctx.author): # If bets are closed... if not betsOpen: await ctx.send( embed=dialogBox('warning', 'Bets aren\'t open yet', 'Open them with `$openbets`.')) else: # Delete all messages in chat # messages = [] # async for message in message.channel.history(limit=int(100)): # messages.append(message) # await message.channel.delete_messages(messages) betsOpen = False betString = '' if bool(currentBets) == True: for userID, betValue in currentBets.items(): betString += ' — **<@!{user}>** has bet **{amount}**.\n'.format( user=userID, amount=asMoney(betValue)) else: betString = 'No bets have been placed...?' await ctx.send(embed=dialogBox( 'raisedhand', 'Bets are now closed!', betString)) else: await ctx.send(embed=dialogBox( 'error', 'Only the dealer has access to this command.'))
async def buyin(ctx, userMentionString): '''DEALER ONLY. Adds $100 to a user's wallet.''' if ctx.message.channel.id in global_constants.validChannels: if isDealer(ctx.author): if global_constants.deleteDealerMessages == True: await ctx.message.delete() dbUser = userInDatabase(convertMentionToID(userMentionString)) dbUser.update(wallet=dbUser.wallet + float(100)) dbUser.update(total_buyins=dbUser.total_buyins + 1) await ctx.send(embed=dialogBox( 'handshake', '{} has bought in!'.format(dbUser.real_name), 'The dealer has topped up {name}\'s wallet with an extra **$100**, bringing their funds up to **{amt}**.' .format(name=dbUser.real_name, amt=asMoney(dbUser.wallet)))) else: await ctx.send(embed=dialogBox( 'error', 'Only the dealer has access to this command.'))