• We would like to invite you to check out the latest 1.0 alpha versions. You can read more about what's new here. Please note, that this is still an early release and will contain new bugs ¯\_(ツ)_/¯
  • If you need help or want to discuss things, you now can also join us on our Discord Server!
TeamSpeak ServerQuery

TeamSpeak ServerQuery 1.0.0

No permission to download
This Library allows you to connect to a TeamSpeak 3 Server Query
Notice: This is a Library which may be required by other Scripts! This is not a standalone Script!


To be able to use the Script the User needs to alter the config.ini and add this 2 lines:
  ServerQuery = ["net"]

For Developers:

After loading the ServerQuery with var ServerQuery = require("ServerQuery.js")
You need to instance it first with var ts3 = new ServerQuery({host: "", port: 10011})

The constructor of ServerQuery expects one object as an argument
host -> the teamspeak server host ip, default value if empty is ""
port -> the teamspeak query telnet port, default value if empty is 10011
net -> fully optional to load the net module from a different script

you can subscribe to events with ts3.on(event_name, function(ev) { ... })

Events you can subscribe to are
connect -> gets fired when the connection to the TCP Socket was successfull
close -> gets fired when the connection to the TeamSpeak gets closed
error -> when something bad happens
notify -> gets called when you receive a TeamSpeak Event

to send a query command you can call the execute function
it takes multiple arguments in a non specific order:
string -> the command which should be sent
object -> object with keys which will get escaped { msg: "Hello World!" } will be sent like msg=Hello\sWorld!
array -> flags for example within the clientlist command ["-uid", "-away", "-country"]
function -> the callback function

  name: "Example Plugin for ServerQuery.js",
  version: "1.0.0",
  description: "Example Script to interact with a TeamSpeak Server Query",
  author: "Multivitamin <[email protected]>",
  vars: []
}, function() {

  var engine = require("engine")
  var event = require("event")

  //wait for all scripts to finnish loading
  event.on("load", function() {
    //load the external library
    var ServerQuery = require("ServerQuery.js")
    //check if the Library has been loaded
    if (typeof ServerQuery !== "function") return engine.log("This Script requires to have ServerQuery.js installed!")

    //create a new instance of it
    var ts3 = new ServerQuery({ host: "", port: 10011 })

    //event connect gets fired when the Query has successfully connected with the TeamSpeak Server
    ts3.on("connect", function() {
      engine.log("TS3 CONNECTED!")
      //authenticate with the TeamSpeak Server
      ts3.send("login", ["serveradmin", "qGH9i3rs"], function(err) {
        if (err) return engine.log("Query Error: "+JSON.stringify(err))
        //select a virtualserver
        ts3.send("use", {port: 9987}, function(err) {
          if (err) return engine.log("Query Error: "+JSON.stringify(err))
          //send a whoami to get info about the own client
          ts3.send("whoami", function(err, res) {
            if (err) return engine.log("Query Error: "+JSON.stringify(err))
            engine.log("TeamSpeak Logged in and selected Port 9987 and got a WhoAmI Response")


First release
Last update
0.00 star(s) 0 ratings

More resources from Multivitamin