• If you need help or want to discuss things, you now can also join us on our Discord Server!
  • A first preview of the unlimited version of SinusBot can be found in the Upcoming Changes thread. A version for Windows will follow, but we don't have a release date, yet.

Help with coding

Erik444

Member
Hello uwu
i cant solucionate this :c
Code:
 Error in script (event chat): TypeError: Cannot access member 'startsWith' of undefined at Prueba Saludo.js:27:10


Code:
}, function (sinusbot, config) {
    // import modules
    var engine = require('engine');
    var event = require('event');
if (!String.prototype.startsWith) {
    String.prototype.startsWith = function(searchString, position){
      return this.substr(position || 0, searchString.length) === searchString;
  };
  }
    // listen for chat event
   event.on('chat', function (ev) {
        
        
                    var errorMensaje2 = 'Perdon, pero necesitas poner otro nick, no puedes abrazarte solo.. :v ';
                    var errorMensaje = 'Perdon, pero necesitas poner otro nick, no puedes abrazarte solo.. :v';
                    var mensaje = 'uwu';
                    var prefix = '!';
                    
                    var words = [];
                    if (ev.msg.startsWith(prefix)){
                        mensaje = ev.msg.slice(1);
                        words = mensaje.split(" ");               
                    if (words[0] == 'abrazo')
                    {
                    if (words[1])
                    {
                        if (words[2] || words[3] || words[4] || words[5] || words[6] || words[7])
                        {
                        chatChannel(errorMensaje);
                        } else if(words[1] == ' ' || words[1] == ev.clientNick)
                        {
                        chatChannel(errorMensaje2);
                        } else
                        {
                            chatChannel(ev.clientNick + ' abrazó a ' +words[1] + mensaje);
                        }
                    }
                    }
                    }
    
    });
});
this send " nick abrazo a nick uwu"
 

mxschmitt

Moderator
Staff member
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Top