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

Status
Not open for further replies.

Floflobel

Donor
is awesome!
Contributor
Hi,

I try to get the list of ServerGroups for a User.
I need to count the number in the futur.

But when try my script, the log return :
Code:
'Floflobel_Test2' is connected. Checking for the server groups...
ServerGroup : [object Object],[object Object],[object Object],[object Object].

My script :
Code:
registerPlugin({
  name: 'LimitIcone',
  version: '1.0',
  description: 'Limit icone',
  author: 'Floflobel',
  vars: {
  limit: {
  title: 'Set the limit of Server Groups',
  type: 'number',
  placeholder: "Max ?"
  },
  option: {
  title: 'Select the punition',
  type: 'select',
  options: [
  'Message',
  'Poke'
  ]
  },
  }
}, function(sinusbot, config) {
  sinusbot.on('clientMove', function(ev) {
    if(ev.oldChannel == 0) {
       sinusbot.log("'" + ev.clientNick + "' is connected. Checking for the server groups...");
       sinusbot.log("ServerGroup : " + ev.clientServerGroups + ".");
    }
  });
});

Thank's for your help.
Best regards
 
Last edited:

Patschi

Head of troll department / Xuxe dominator
Tier III
is awesome!
V.I.P.
is uber awesome!
Insider
The variable...
Code:
ev.clientServerGroups
...does contain an array of the serverGroup IDs where the client is in. You can't just print it out like that. You need to iterate through this array using a for() function from JavaScript.
 

Multivitamin

Well-Known Member
Tier III
is awesome!
V.I.P.
is uber awesome!
Contributor
Insider
Since you have this:
"ServerGroup : " + ev.clientServerGroups + "."
it tries to parse ev.clientServerGroups as string and since a Object as string is displayed like [object Object]

You simply need to remove the String at the Start and at the End like that:
sinusbot.log(ev.clientServerGroups);
 

Floflobel

Donor
is awesome!
Contributor
Code:
var srvgroups = ev.clientServerGroups
for (var k in srvgroups) {
    srvgroups(k)
}

I try to show first object with k=0. I don't know do ..
Can you give me an example ?
 
Last edited:
Status
Not open for further replies.
Top