A fully typesafe and easy-to-use Node.js client for interacting with Teamspeak servers via ServerQuery.
💡 Inspired by Discord.js, bringing a similar event-driven and easy-to-use interface to Teamspeak.
✨ More features are coming soon! Feel free to contribute and help improve the project.
🔗 Website
🔗 Documentation
🔗 Exmples
🔗 View on npm
// General example
import { Query } from 'teamspeak.js';
const query = new Query({
host: '127.0.0.1',
port: 10011,
});
query.on('Ready', async () => {
console.log('Connected to TeamSpeak server!');
await query.login('serveradmin', 'p4ssw0rd'); // Login with query credentials
await query.virtualServers.use(1); // Select VirtualServer with ID 1
await query.notifications.subscribeAll(); // Subscribe to ALL notifications (channelcreated, clientmoved, ...)
// You're free to go!
// Fetch all clients
const clients = await query.clients.fetch();
console.log('There are currently', clients.size, 'clients');
// Create a new permanent channel
const createdChannel = await query.channels.create({ name: 'New Channel', type: 'permanent' });
console.log('Created channel:', createdChannel);
// Edit the channel
await createdChannel.edit({ name: 'Changed Name', topic: 'Just chilling' });
// Delete the channel
await createdChannel.delete();
});
query.on('ChannelCreate', (channel) => {
console.log('Some channel got created:', channel);
});
query.on('ChannelUpdate', (before, after) => {
if (before.name !== after.name) {
console.log(`Channel name of ${before.id} changed from "${before.name}" to "${after.name}"`);
}
});
query.on('TextMessage', (message) => {
console.log(
`Received a ${message.mode}-message from ${message.invoker.nickname || message.invoker.id || 'Unknown Client'}: ${message.content}`,
);
});
query.connect();
// TeamSpeak 6 Server example
import { Query } from 'teamspeak.js';
const query = new Query({
host: '127.0.0.1',
protocol: 'ssh',
ssh: {
username: 'serveradmin',
password: 'H3lloW0rld',
},
});
query.on('Ready', async () => {
console.log('Connected to TeamSpeak 6 server!');
// No need for query.login anymore
});
query.connect();
View more examples on our Website!