From c678e7f8d0f8306b3ff7b7143f16ce535371a110 Mon Sep 17 00:00:00 2001 From: Charlie Hess Date: Wed, 30 Sep 2015 21:11:06 -0700 Subject: [PATCH] If at first you don't succeed, try, try again? --- src/texas-holdem.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/texas-holdem.js b/src/texas-holdem.js index db92198..6bfbdab 100644 --- a/src/texas-holdem.js +++ b/src/texas-holdem.js @@ -3,6 +3,7 @@ const _ = require('underscore-plus'); const Deck = require('./deck'); const PotManager = require('./pot-manager'); +const SlackApiRx = require('./slack-api-rx'); const PlayerOrder = require('./player-order'); const PlayerStatus = require('./player-status'); const ImageHelpers = require('./image-helpers'); @@ -486,7 +487,14 @@ class TexasHoldem { if (!player.isBot) { let dm = this.playerDms[player.id]; - dm.send(`Your hand is: ${this.playerHands[player.id]}`); + if (!dm) { + SlackApiRx.getOrOpenDm.subscribe(({dm}) => { + this.playerDms[player.id] = dm; + dm.send(`Your hand is: ${this.playerHands[player.id]}`); + }); + } else { + dm.send(`Your hand is: ${this.playerHands[player.id]}`); + } } else { player.holeCards = this.playerHands[player.id]; }