@necord/lavalink v1.1.4-dev.1747097630.c7f3c48
About
Transform your bot into a professional DJ with the power of the Lavalink ecosystem. This package uses lavalink-client behind the scenes, providing a high-performance and efficient solution for managing audio streams on Discord. By leveraging Lavalink, your bot gains the ability to manage audio playback, queues, and real-time controls with minimal latency, transforming it into a fully capable and professional music system.
Installation
Node.js 18.0.0 or newer is required.
$ npm i @necord/lavalink necord discord.js
$ yarn add @necord/lavalink necord discord.js
$ pnpm add @necord/lavalink necord discord.jsUsage
Once the installation process is complete, we can import the NecordLavalinkModule into the root AppModule:
import { NecordLavalinkModule } from '@necord/lavalink';
import { Module } from '@nestjs/common';
import { Client } from 'discord.js';
import { AppUpdate } from './app.update';
@Module({
imports: [
NecordLavalinkModule.forRoot({
nodes: [
{
authorization: 'youshallnotpass',
host: 'localhost',
port: 2333,
id: 'main_node'
}
]
})
],
providers: [AppUpdate]
})
export class AppModule {
}Then create app.update.ts file and add OnLavalinkManager/OnceLavalinkManager decorators for handling LavalinkManager events and
OnNodeManager/OnceNodeManager decorators for handling NodeManager events:
import { Injectable, Logger } from '@nestjs/common';
import { Context } from 'necord';
import { OnLavalinkManager, OnNodeManager, LavalinkManagerContextOf, NodeManagerContextOf } from '@necord/lavalink';
@Injectable()
export class AppUpdate {
private readonly logger = new Logger(AppUpdate.name);
@OnNodeManager('connect')
public onReady(@Context() [node]: NodeManagerContextOf<'connect'>) {
this.logger.log(`Node: ${node.options.id} Connected`);
}
@OnLavalinkManager('playerCreate')
public onPlayerCreate(@Context() [player]: LavalinkManagerContextOf<'playerCreate'>) {
this.logger.log(`Player created at ${player.guildId}`);
}
}Whenever you need to handle any event data, use the Context decorator.
If you want to fully dive into Necord, check out these resources:
- Necord Wiki - Official documentation of Necord.
- Nest JS - A progressive framework for creating well-architectured applications.
- Discord JS - The most powerful library for creating bots.
- Discord API - Official documentation of Discord API.
- Lavalink - Official Lavalink documentation.
- lavalink-client - Easy, flexible and feature-rich lavalink@v4 Client.
Backers
Stay in touch
- Author - Alexey Filippov
- Twitter - @SocketSomeone
License
10 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
9 months ago
1 year ago
9 months ago
1 year ago
9 months ago
10 months ago
9 months ago
10 months ago
10 months ago
10 months ago
11 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
9 months ago
10 months ago
11 months ago
10 months ago
10 months ago
11 months ago
10 months ago
9 months ago
10 months ago
10 months ago
9 months ago
11 months ago
1 year ago
1 year ago
1 year ago
1 year ago