• 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.

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.
Top