• If you need help or want to discuss things, you now can also join us on our Discord Server!

EN [SOLVED] Group assigner by joining a channel and remove by leaving the Channel

Vxrious

Donor
is awesome!
#1
Hello,

I looking for a script like that
User x joins Channel Y (User X gets group A) User X leaves Channel Y (Bot remove group A from User x again)

Hope i explained it right :D

-Vxrious
 

DrWarpMan

Member
Contributor
#2
Should work..

JavaScript:
registerPlugin({
    name: 'Group On Channel Join',
    version: '0.1',
    backends: ['ts3'],
    description: 'Adds specified group to a user, when he joins specified channel, and removes, when he leaves the channel',
    author: 'DrWarpMan',
    vars: [
        {
            name: 'channelId',
            title: 'The channel ID, that if user joins, user will be added to specified group:',
            type: 'channel'
        },
        {
            name: 'groupId',
            title: 'The group ID, that will be given, to the user, after joining specified channel:',
            type: 'string',
            placeholder: '69'
        }
    ]
}, function (sinusbot, config) {

    var engine = require('engine');
    var backend = require('backend');
    var event = require('event');

    if(config.channelId == undefined || config.groupId == undefined)
        return;

    var channelId = config.channelId;
    var groupId = config.groupId;

    event.on('clientMove', function (ev) {
        if(ev.toChannel != null)
        {  
            if(channelId === ev.toChannel.id())
            {
                ev.client.addToServerGroup(backend.getServerGroupByID(groupId));
            } else ev.client.removeFromServerGroup(backend.getServerGroupByID(groupId));
        }
    });
});
 

Attachments

Similar threads