1

I'm trying to connect to the twitch chat-irc websockets, but when I run my code to test, it returns .temp:7: attempt to call nil. I've heard that it has to do something with functions, but my code has no functions, only strings, and has only 2 other lines that connect to line 7. Anyone have an idea of how to fix this?

local Channel = *my channel*
local Name = *Bot account name*
local Pass = *oauth code*

local cum = "wss://irc-ws.chat.twitch.tv:443"

local ws = http.websocket(cum)
if ws then
        print("Connection Established")

websocket.send("PASS " ..Pass .."\r\n")
websocket.send("NICK " ..Name .."\r\n")
websocket.send("Join " ..Channel .."\r\n")
Egor Skriptunoff
  • 23,359
  • 2
  • 34
  • 64
Spiring
  • 11
  • 1

1 Answers1

0

You created a variable called ws, then proceeded to use a variable named websocket which doesn't exist. Replace the 3 last lines with this:

ws.send("PASS " ..Pass .."\r\n")
ws.send("NICK " ..Name .."\r\n")
ws.send("Join " ..Channel .."\r\n")

It has something to do with functions because send() is a function. You tried to call send() on a variable that doesn't exist, resulting in that error.

Reimar
  • 11
  • 1
  • 1