Tyzen
A stable and updated wrapper around Lavalink
Tyzen
Features
✅ Stable
✅ Documented
✅ Updated
✅ Extendable
✅ ESM & CommonJS supported
✅ Very cute (Very Important)
Supported Libraries
Refer to /src/connectors for list of supported libraries + how to support other libraries
Installation
- Stable (3.x.x) | Needs Lavalink Versions:
"3.5.x" < "3.9.x" >
npm install tyzen
- Dev (4.0.0-dev) | Needs Lavalink Versions:
"4.x.x <"
npm install https://github.com/itachi9797/tyzen.git
Lavalink v4 support is currently deployed on main branch, do npm install https://github.com/itachi9797/tyzen.git
Dev versions are not guaranteed to stay the same api wise, and even with last known stable, I won't say it's 100% stable
Small code snippet examples
Initializing the library (Using Connector Discord.JS)
const { Client } = require('discord.js');
const { Tyzen, Connectors } = require('tyzen');
const Nodes = [{
name: 'sikku',
url: 'sikku:890',
auth: 'sikku202838'
}];
const client = new Client();
const tyzen = new Tyzen(new Connectors.DiscordJS(client), Nodes);
tyzen.on('error', (_, error) => console.error(error));
client.login('token');
client.tyzen = tyzen;
Never initialize Tyzen like this, or else she will never initialize, start tyzen before you call client.login()
client.on('ready', () => {
client.tyzen = new Tyzen(new Connectors.DiscordJS(client), Nodes);
});
Join a voice channel, search for a track, play the track, then disconnect after 30 seconds
const player = await tyzen.joinVoiceChannel({
guildId: 'your_guild_id',
channelId: 'your_channel_id',
shardId: 0
});
const result = await player.node.rest.resolve('scsearch:snowhalation');
if (!result?.tracks.length) return;
const metadata = result.tracks.shift();
await player.playTrack({ track: metadata.encoded });
setTimeout(() => tyzen.leaveVoiceChannel(player.guildId), 30000).unref();
Playing a track and changing a playback option (in this example, volume)
await player.playTrack({ track: metadata.encoded });
await player.setGlobalVolume(50);
Updating the whole player if you don't want to use my helper functions
await player.update({ ...playerOptions });
Setting a custom get node ideal function
const player = await tyzen.joinVoiceChannel({
guildId: 'your_guild_id',
channelId: 'your_channel_id',
shardId: 0,
getNode: (nodes, connection) => {
nodes = [ ...nodes.values() ];
return nodes.find(node => node.group === connection.region);
}
});
Updating from V3 -> V4 (notable changes)
The way of joining and leaving voice channels is now different
const { Client } = require('discord.js');
const { Tyzen, Connectors } = require('tyzen');
const Nodes = [{
name: 'sikku',
url: 'sikku:890',
auth: 'sikku202838'
}];
const client = new Client();
const tyzen = new Tyzen(new Connectors.DiscordJS(client), Nodes);
tyzen.on('error', (_, error) => console.error(error));
client.login('token');
client.once('ready', async () => {
const node = tyzen.getIdealNode();
const result = await node.rest.resolve('scsearch:snowhalation');
if (!result?.tracks.length) return;
const metadata = result.tracks.shift();
const player = await tyzen.joinVoiceChannel({
guildId: 'your_guild_id',
channelId: 'your_channel_id',
shardId: 0
});
const result_2 = await player.node.rest.resolve('scsearch:snowhalation');
console.log(result_2.tracks.shift());
await player.playTrack({ track: metadata.encoded });
setTimeout(async () => {
await tyzen.leaveVoiceChannel(player.guildId);
}, 30000);
})
Usual player methods now return promises
await player.playTrack(...data);
await player.stopTrack();
There are 2 kinds of volumes you can set, global and filter
await player.setGlobalVolume(100);
console.log(player.volume);
await player.setFilterVolume(1.0);
console.log(player.filters.volume)
There are other internal changes like
console.log(tyzen.connections);
const player = await tyzen.joinVoiceChannel({
guildId: 'your_guild_id',
channelId: 'your_channel_id',
shardId: 0,
getNode: (nodes, connection) => {
nodes = [ ...nodes.values() ];
return nodes.find(node => node.group === connection.region);
}
});
console.log(tyzen.getIdealNode());
Support Server HERE