ga-dc / js1

General Assembly's first JavaScript Development Course
11 stars 22 forks source link

Loren's Slackbot #38

Closed lorenries closed 8 years ago

lorenries commented 8 years ago

The javascript: https://github.com/lorenries/GAslackbot/blob/master/scripts/bot.js

The bot is supposed to do 4 things, 2 of which it does successfully.

  1. It tells you whether or not we have class
  2. It sends you a random crossword puzzle

It does not, unfortunately, send John a random crossword if you ask it to, nor does it add a crossword to the array of random crosswords. :( still trying to figure those out.

jsm13 commented 8 years ago

Nice work! The issue on the sending me a crossword is that the messageRoom method is actually on the bot object rather than the message object. You would want line 25 to be return bot.messageRoom( 'johnmaster' , message.random(crosswords)) ; With adding the crossword, you are right now accessing the brain storage on the bot (some object with special methods for setting and getting) and asking what value it has associated with the key 'newCrossword'. It will return undefined because nothing has been set to that key. You then push the undefined value to the array. What you'll want to do is access msg.match to get the input and then push that value to the array (or to the brain with set)