• We would like to invite you to check out the latest 1.0 alpha versions. You can read more about what's new here. Please note, that this is still an early release and will contain new bugs ¯\_(ツ)_/¯
  • If you need help or want to discuss things, you now can also join us on our Discord Server!

EN function send msg

Status
Not open for further replies.
Hello !

I have small problem with function send msg

the code:
Code:
    function send_msg(msg, ev) {
        var mode = (typeof ev !== 'undefined') ? ev.mode : 2;
        switch (mode) {
            case 1:
                sinusbot.chatPrivate(ev.clientId, msg);
                break;
            case 2:
                sinusbot.chatChannel(msg);
                break;
            default:
                sinusbot.chatServer(msg);
                break;
        }
for ev.mode 2 - works fine, send message on chatChannel but I'd like to set it to 1 for sending message for client, log:

Code:
Cannot access member 'clientId' of undefined at send_msg
I know that this script is for old type of sinusbot, but I hope someone will help me to solve that case :)
 

VerHext

Donor
is awesome!
Contributor
Insider
Code:
var engine = require('engine');
var backend = require('backend');

         
function send_msg(msg, clientId, mode)
          {
            switch(mode)
            {
              case 1:
                  backend.getClientByID(clientId).chat(msg);
                  break;
              case 2:
                  backend.getClientByID(clientId).getChannels()[0].chat(msg);
                  break;
              case 3:
                  backend.chat(msg);
                  break;

            }
          }
This is an example
 
Status
Not open for further replies.

Similar threads

Top