Closed Rhyzox closed 5 years ago
There's not enough of your code to tell you exactly what's happening, but you shouldn't use "._sendMessage
" as this is an internal method used by the more appropriate ".say
" method.
Not sure why but I get the same Not connected to server issue even with the .say function here is my code
const client = new tmi.client(options);
client.connect();
client.on("chat", (chan, user, message, self) => {
client.say(chan, "pong");
});
I also have the debug on true to see and it says that it connects successfully to the server. Here is the log
[12:34] info: Connecting to irc-ws.chat.twitch.tv on port 80..
[12:34] info: Sending authentication to server..
[12:34] info: Connected to server.
[12:34] info: Joined #zelak312
[12:34] info: [#zelak312] <zelak312>: m!ping
Not connected to server. Promise { <rejected> 'Not connected to server.' }
@ZelAk312 I think you might be spamming the server and getting forcefully disconnected by Twitch. You have an unintended loop:
When the bot sends a message called via the say
& action
methods, it will emit another "chat" event.
This is where the self
boolean value passed in the event is useful.
client.on("chat", (chan, user, message, self) => {
if(self) {
return;
}
client.say(chan, "pong");
});
I found out my problem I had a typo in the "identity" property
switch(message.toLowerCase()){ case
${prefix}help: client._sendMessage(0, channel, "Help: "); break; }
I got the error:
(node:7124) UnhandledPromiseRejectionWarning: Not connected to server. (node:7124) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:7124) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.