Skip to content

Multivit4min/teamspeak-commander

Repository files navigation

TeamSpeak Command Interface for TS3-NodeJS-Library

Build Status Coverage Status npm Discord

This is still work in progress API may change without notice

Introduction

This library allows you to easily create commands for your teamspeak server using ts3-nodejs-library

Install

npm install --save teamspeak-commander

Documentation

You can find all necessary documentation here or a lot of examples in the docs folder of this project!

Usage:

const { TeamSpeak } = require("ts3-nodejs-library")
const { Commander } = require("teamspeak-commander")

const commander = new Commander({ prefix: "!" })

//command !ping
commander.createCommand("ping")
  .setHelp("sends pong as response")
  .run(event => {
    event.reply("Pong!")
  })

//command !roll 10 -> rolls a number between 1 and 10
//command !roll -> rolls a number between 1 and 6
commander.createCommand("roll")
  .help("rolls a number")
  .addArgument(arg => arg.number.name("max").optional(6))
  .run(event => {
    const random = Math.floor(Math.random() * event.arguments.max) + 1
    event.reply(`Rolled a ${random} (from 1-${event.arguments.max})`)
  })

TeamSpeak.connect({
  host: "....",
}).then(teamspeak => {
  commander.addInstance(teamspeak)
})