UNPKG

serverquery

Version:

Low level TeamSpeak™ 3 ServerQuery protocol implementation

38 lines (25 loc) 1.04 kB
import { createServerQuery } from '../'; import { stringify } from '../lib/debug'; function resolve(id) { return (result) => console.log(id, "RESOLVED", stringify(result, 50)); } function reject(id) { return (reason) => console.log(id, "REJECTED", stringify(reason, 50)); } let sq = createServerQuery({ host: 'einstein.veltro.de' }); sq.on('connect', () => { }); sq.cmd('login', { clientLoginName: 'serveradmin', clientLoginPassword: process.env.PASSWORD }) .then(resolve('login'), reject('login')); sq.cmd('use', { port: 2048 }) .then(resolve('use'), reject('use')); sq.cmd('channellist', ['flags', 'voice']) .then(channels => { console.log(channels.filter(c => c.cid === 1540)) }, reject('channellist')); sq.cmd('servernotifyregister', { event: 'channel', id: 0 }) .then(resolve('servernotifyregister'), reject('servernotifyregister')); sq.on('notify', console.log); sq.on('error', console.log); sq.cmd('channelinfo', { cid: 1540 }) .then(resolve('info'), reject('info'));