-1

I am trying to make a chatbot for the web game https://skribbl.io but when my javascript script is run, it only runs once.

function send() {
    var ic = document.getElementById("inputChat");
    ic.value = "ChatBot online";
    ic.parentNode.dispatchEvent(new Event('submit', {
        bubbles: false,
        cancelable: false,
    }));
}
setInterval(send(), 1000);
Laaouatni Anas
  • 4,199
  • 2
  • 7
  • 26
L8R
  • 401
  • 5
  • 21
  • 3
    Remove () from send() in setInterval **setInterval(send, 1000);** Otherwise you are running the function on load instead of referencing the function – imvain2 Sep 08 '22 at 20:50

1 Answers1

1

setInterval(send, 1000); or setInterval(() => { send() }, 1000);

Aakash Rathee
  • 523
  • 3
  • 17