Chat API Issue (Chat-Voting System)

Hello forum! My name Arthur and I am programmer (beginner) from Ukraine. I really need help of professionals and I hope I will get it. So, closely to the issue. I have been endeavouring to do this for almost 2 days.
You know such thing as Twitch Mode in such game as The Binding of Isaac. The conception is following: when it’s time to vote for such in-game bonus, viewers in chat should write the number they vote, for example “#2”. So, i got an idea to make a such service to provide online-voting on stream with this fuction (pleaseee. don’t send me versions of such services are already done, i want to achieve and to create it by myself). I found and used ChartJS (framework of js to create diagrams) to create diagram as a “pie”. The last thing i need it’s to realize the chat-voting system using API. I just can’t do this. I use JavaScript, exactly WebSocket to connect to IRC Chat Server. After i’ve connected successfully I just don’t know what to do in order to get chat messages are sent by other people. I’ll attach screenshot of my code. Help me to do this. Thank you!
screenshot describing diagram conception →

Your JOIN is missing # from before the channel name. You should also end each message with \r\n per IRC protocol, even though it’s not strictly required when using websockets instead of a raw connection.

I would personally use socket.onopen instead of checking readystate in send, too.

From a code maintainability point of view using socket on a line before you’ve defined it is bad practice, but doesn’t change anything functionally (vars are scoped to the entire function, even code that lies before it)

1 Like

Oh… My… God… Thank you! It’s so hilarious error! I don’t even know how to express my gratefulness!
Also thank you for your advice. Fortunately, it’s only amateur project, you know, so personally for me now the most important thing is that everything is working.

Keep at it and enjoy! :slight_smile:

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.