Advertisement
Guest User

Untitled

a guest
Aug 23rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (defmethod handle-event "!create-bet"
  2.   [event-type {:keys [channel-id content]}]
  3.   (let [split-content (str/split content #" ")
  4.         pw (get split-content 1)
  5.         game-id (get split-content 2)
  6.         team1 (get split-content 3)
  7.         team2 (get split-content 4)]
  8.     (when (and (= 5 (count split-content))
  9.                (= (hash pw) (:password @state)))
  10.       (swap! state assoc
  11.              :open? true
  12.              :game-id game-id
  13.              :team1 team1
  14.              :team2 team2)
  15.       (m/create-message! (:messaging @state) (:default-announcement-channel @state)
  16.                          :content (str "Bets are now open for game " game-id
  17.                                        "\n" team1 " vs " team2 "!"
  18.                                        "\ntype ```!bet 1 <amount>``` to bet on " team1
  19.                                        "\nand ```!bet 2 <amount>``` to bet on " team2
  20.                                        "\nYou have " (/ (:betting-time @state) 1000) " seconds to make your bet!"))
  21.       (Thread/sleep (:betting-time @state)) ;;want to sleep here without disrupting other commands
  22.       (swap! state assoc :open? false)
  23.       (m/create-message! (:messaging @state) (:default-announcement-channel @state)
  24.                          :content "Bets are now closed! Good luck!"))))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement