• 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 get clientId from clientUid

Status
Not open for further replies.

jowieweb

New Member
Hi,
I'm playing around with the scripting API, but I got stuck...
I need the clientid, but I only have the clientUid or the nickname. Is there a way to look it up? Or a way to list ALL connected users and then search the right id?

I guess i could log all users with the onMove method and than search by myself?
But thats a quite ugly way...

thx for the help,
jowieweb
 

Multivitamin

Well-Known Member
Tier III
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Code:
    function getClientByUid(uid) {
        return getClientByParam('uid', uid);
    }
  
    function getClientById(id) {
        return getClientByParam('id', id);
    }

    function getClientByParam(search_key, search_value) {
        var channels = getChannels();
        for (var i = 0; i < channels.length; i++) {
            if (channels[i]['clients'].length > 0) {
                for (var key in channels[i]['clients']) {
                    if (channels[i]['clients'][key][search_key] == search_value) {
                        var client = channels[i]['clients'][key];
                        client.cid = channels[i].id;
                        return client;
                    }
                }
            }
        }
        return false;
    }

Here you are able to get the client as object with the function

var client = getClientByUid('someuidhere=');
 
Last edited:
Status
Not open for further replies.
Top