Jump to content


Photo
Question

People joining chat room

node.js node-steam-user

Best Answer Dr. McKay , 27 April 2019 - 12:19 PM

Without seeing exactly how parseMessage is called, all I can suggest is that maybe you want that if to be if (!message || !message.startsWith('!'))

Go to the full post


  • Please log in to reply
2 replies to this topic

#1 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 58 posts

Posted 27 April 2019 - 11:46 AM

Hello

 

My BoT is in a couple group chat rooms and is catching all messages starting with "!" in order to execute commands.

I have an issue every time someone joins the chat room and Steam displays this:

 

jfcVz7k.png

 

BoT returns:

UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'startsWith' of null

I thought that "messages" and server_messages were 2 different items, so why the error when my code is:

function parseMessage(groupID, chatID, message, senderID, senderAccountID, sender) {
    if (message && !message.startsWith('!')) {
        return;
    }

Isn't the "joined" stuff a server message? How do I get rid of the error?

 

Thanks as always  :P



#2 Dr. McKay

Dr. McKay

    Developer

  • Administrator
  • 2,140 posts

Posted 27 April 2019 - 12:19 PM   Best Answer

Without seeing exactly how parseMessage is called, all I can suggest is that maybe you want that if to be if (!message || !message.startsWith('!'))



#3 roughnecks

roughnecks

    Advanced Member

  • Member
  • PipPipPip
  • 58 posts

Posted 27 April 2019 - 05:00 PM

Did like you suggested and it looks like it's working fine now! Thanks







Also tagged with one or more of these keywords: Question, node.js, node-steam-user

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users