# nsyslava

> Lavalink client with lots of extra functionality, easy to use and well optimized.

Latest version **2.0.7** (published 2022-08-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install nsyslava
pnpm add nsyslava
yarn add nsyslava
bun add nsyslava
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.7 |
| Published | 2022-08-15 |
| First published | 2022-03-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 7 |
| Unpacked size | 46.3 KB |
| Known vulnerabilities | 0 (+23 in 1 direct dependencies) |
| Install scripts | no |
| Author | nicenathapong |
| Maintainers | nicenathapong |
| Keywords | lavalink, discord, nSys, nicenathapong |

## Links

- npm: https://www.npmjs.com/package/nsyslava
- npm.io page: https://npm.io/package/nsyslava

## Dependencies (7)

- [ws](https://npm.io/package/ws.md) ^8.5.0
- [axios](https://npm.io/package/axios.md) ^0.26.1
- [@types/ws](https://npm.io/package/@types/ws.md) ^8.5.2
- [@types/events](https://npm.io/package/@types/events.md) ^3.0.0
- [@lavalink/encoding](https://npm.io/package/@lavalink/encoding.md) ^0.1.2
- [tiny-typed-emitter](https://npm.io/package/tiny-typed-emitter.md) ^2.1.0
- [@discordjs/collection](https://npm.io/package/@discordjs/collection.md) ^0.5.0

## Recent versions

- 2.0.7 (latest) — 2022-08-15
- 2.0.62 — 2022-06-04
- 2.0.61 — 2022-06-04
- 2.0.6 — 2022-05-12
- 2.0.53 — 2022-05-12
- 2.0.52 — 2022-05-12
- 2.0.51 — 2022-04-16
- 2.0.5 — 2022-04-16
- 2.0.4 — 2022-04-16
- 2.0.35 — 2022-04-16
- 2.0.34 — 2022-04-16
- 2.0.33 — 2022-04-16
- 2.0.32 — 2022-04-16
- 2.0.31 — 2022-04-16
- 2.0.3 — 2022-04-16
- … 20 more at https://npm.io/package/nsyslava/versions

## README

# **📘 nSysLava**
> Lavalink client with lots of extra functionality, easy to use and well optimized!

**พัฒนาโดยคนไทย 😳**
- **Many utility functions** - มีฟังก์ชันอรรถประโยชน์มากมาย
- **Lightweight and high efficiency** - เบาและมีประสิทธิภาพสูง

## **❤️ Interesting function / ฟังก์ชันที่น่าสนใจ**

- **Best Reconnecting handles**
- **Load Balance**
- **Queue System**
- **Autoplay**

## **📌 Links**
- [**Github**](https://github.com/nicenathapong/nSysLava)
- [**npm**](https://www.npmjs.com/package/nsyslava)

## **📖 Installation / วิธีการติดตั้ง**
required [**Node.js**](https://nodejs.org/en/) v16+
```shell
npm i nsyslava
```
## **📘 Usage / การใช้งาน**

### **Setup**
```ts
import { Client } from 'discord.js';
import { nSysManager } from 'nsyslava';

const client = new Client({ intents: [...] });

const manager = new nSysManager([
    {
        name: 'nLavalink',
        host: 'localhost',
        port: 2333,
        secure: false,
        authorization: 'loveu3000',
        clientName: 'nSysLava',
        reconnect: {
            retryAmout: 999,
            delay: 3000,
        },
        search: true,
        play: true,
    }
])

manager.on('sendGatewayPayload', (id, payload) => {
    const guild = client.guilds.cache.get(id);
    if (guild) guild.shard.send(payload);
})

client.ws.on('VOICE_SERVER_UPDATE', upd => manager.handleVoiceUpdate(upd))
client.ws.on('VOICE_STATE_UPDATE', upd => manager.handleVoiceUpdate(upd))

client.once('ready', () => {
    console.log(`[Client] is Ready! | Login as ${client.user.tag}`)
    manager.connect(client.user.id)
})

client.login(...)
```

### **Playing music**
```ts
const result = await manager.loadTracks('https://youtu.be/G0iN4jhaKqw');

if (result.loadType === 'LOAD_FAILED' || result.loadType === 'NO_MATCHES') return;

const player = manager.createPlayer(guildId);
player.connect(channelId);

player.queue.add(result.tracks);
player.queue.start();
```

### **Functions**
```ts
// skip
player.queue.skip();

// previous
player.queue.toPrevious();

// remove
player.queue.remove(4);

// shuffle
player.queue.shuffle();

// loop
// 0 = none
// 1 = queue
// 2 = track
player.queue.setLoop(2);

// Autoplay
player.queue.setAutoplay(true);

// pause
player.setPause(true);

// volume
player.setVolume(100);

// seek
player.seek(37000);

// Destroy player
manager.destroy(guildId)

// Node stats
const node = manager.getNode('nLavalink');
console.log(node.stats)

// Add node
manager.addNode({ ...nodeConfig })
```

---
_Source: https://npm.io/package/nsyslava · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
