sinusbot/scripts/followme.js

28 lines
859 B
JavaScript

registerPlugin({
name: 'Follow Me',
version: '3.0.0',
backends: ['ts3', 'discord'],
description: 'The bot will follow the movements of any of the clients given',
author: 'SinusBot Team', // Michael Friese, Max Schmitt, Jonas Bögle
vars: [{
name: 'clientUids',
title: 'Comma-separated list of client-UIDs that the bot should follow',
type: 'string'
}]
}, (_, {clientUids}) => {
const engine = require('engine')
const backend = require('backend')
const event = require('event')
if (!clientUids) {
engine.log('No client-UIDs set.')
return
}
const uids = clientUids.trim().split(',')
event.on('clientMove', ({ client, toChannel }) => {
if (toChannel && uids.includes(client.uid())) {
backend.getBotClient().moveTo(toChannel)
}
})
})