• 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 [SOLVED] Group assigner by joining a channel and remove by leaving the Channel

Vxrious

Helping Hand
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

Well-Known Member
Contributor
Insider
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

  • groupOnChannelJoin.js
    1.3 KB · Views: 40

DrWarpMan

Well-Known Member
Contributor
Insider
Depends, what do you need? If you are interested in something private, hit me up in the DM.
 
Top