roughnecks Posted April 27, 2019 Report Posted April 27, 2019 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: 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 Quote
Dr. McKay Posted April 27, 2019 Report Posted April 27, 2019 Without seeing exactly how parseMessage is called, all I can suggest is that maybe you want that if to be if (!message || !message.startsWith('!')) Quote
roughnecks Posted April 27, 2019 Author Report Posted April 27, 2019 Did like you suggested and it looks like it's working fine now! Thanks Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.