tmijs / tmi.js

💬 Javascript library for the Twitch Messaging Interface. (Twitch.tv)
https://tmijs.com
MIT License
1.55k stars 214 forks source link

After "Connected to server.", receiving chat works, but sending gives "Not connected to server." #202

Closed chamberlainpi closed 7 years ago

chamberlainpi commented 7 years ago

Actual behaviour: When registering a 'chat' event, chat messages are received correctly. But using any client commands like client.say throws an error (the Promise's catch spits out "Not connected to server.")

I did use an oauth password with my bot account, username is all lowercase (I have setup two accounts, one for myself, one for this bot - both using the same email address... could that be a problem?).

Screenshot of TMI.js error

Expected behaviour: The bot should be able to send the message to the chat.

Server configuration

AlcaDesign commented 7 years ago

You haven't filled out any information in the issue message, so I'll assume you're attempting to use of the example set ups?

Make sure your code follows this minimal setup:

Node

var tmi = require('tmi.js');
var client = new tmi.client({
        connection: {
            reconnect: true,
            secure: true
        },
        options: {
            debug: true
        },
        identity: {
            username: '',
            password: ''
        },
        channels: [ 'somechannel' ]
    });
client.connect();

Browser

var client = new tmi.client({
        connection: {
            reconnect: true,
            secure: true
        },
        options: {
            debug: true
        },
        identity: {
            username: '',
            password: ''
        },
        channels: [ 'somechannel' ]
    });
client.connect();

If you see in the console that it logs its connection, then it's not the library. You need to make sure that the client is connected and has joined a channel before you attempt to use .say() on a channel.

chamberlainpi commented 7 years ago

@AlcaDesign yeah sorry about the accidental submission before I had everything filled out.

With the minimal example you're suggesting, I see there's no credentials used. Won't that mean node won't be able to interact with the chat still?

chamberlainpi commented 7 years ago

I tested the minimal example and I'm getting 3 output lines from [info]:

[03:56] info: Connecting to irc-ws.chat.twitch.tv on port 443.. [03:56] info: Sending authentication to server.. [03:56] info: Connected to server.

But since the example didn't tie it to any channels, now it won't respond even if I enter something in the chat with my personal account.

celluj34 commented 7 years ago

That's because you need to join them first...

chamberlainpi commented 7 years ago

I was joining it before when I was using the options.channels field, but I was just pointing out the example didn't have it.

chamberlainpi commented 7 years ago

I think I just found it.... oh god I feel so dumb....

Seriously.... idendity, what was I thinking

4am, I probably should go to bed. :zzz:

Apologies for bringing up this false alarm!

AlcaDesign commented 7 years ago

Well I said it was "minimal" .. Not necessarily the minimal for a chat bot. I just wanted to see if you were able to connect to the servers in the first place. I've updated it to include the identity and the channels object.

chamberlainpi commented 7 years ago

Thanks for your help.

Yeah I couldn't understand why I could make the connection, but not the authentication. Using idendity over identity would certainly break something.