Discord.jsDiscord.pyLavalink 4WavelinkKazagurumaTutorial
How to Connect Lavalink 4 to Discord.js v14 & Discord.py (Complete 2026 Tutorial)
Altivora DevOps Team
11 min read
Connecting your Discord bot to an external Lavalink 4 audio node separates CPU-heavy audio transcoding from your bot's core gateway event loop.
1. Connecting with Discord.js (v14) using Kazaguruma:
import { Client, GatewayIntentBits } from "discord.js";
import { Kazaguruma, Plugins } from "kazaguruma";
const client = new Client({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
});
const Nodes = [
{
name: "Altivora-Node-India",
url: "node-in.altivorahosting.com:2333",
auth: "your_lavalink_password",
secure: false,
},
];
export const manager = new Kazaguruma(
{
plugins: [new Plugins.PlayerMoved(client)],
source: ["youtube", "soundcloud", "spotify"],
},
Nodes,
{
send: (guildId, payload) => {
const guild = client.guilds.cache.get(guildId);
if (guild) guild.shard.send(payload);
},
}
);
client.on("ready", () => {
console.log(`Bot is ready as ${client.user.tag}`);
});
client.login(process.env.DISCORD_TOKEN);
2. Connecting with Python (discord.py) using Wavelink:
import discord
from discord.ext import commands
import wavelink
class MusicBot(commands.Bot):
def __init__(self):
intents = discord.Intents.default()
intents.message_content = True
super().__init__(command_prefix="!", intents=intents)
async def setup_hook(self):
node: wavelink.Node = wavelink.Node(
uri="http://node-in.altivorahosting.com:2333",
password="your_lavalink_password"
)
await wavelink.Pool.connect(client=self, nodes=[node])
bot = MusicBot()
@bot.event
async def on_wavelink_node_ready(payload: wavelink.NodeReadyEventPayload):
print(f"Lavalink Node connected: {payload.node.identifier}")
bot.run("YOUR_DISCORD_BOT_TOKEN")
High-Performance Infrastructure
Deploy with Altivora Hosting
Gen4 NVMe Soft RAID storage, AMD EPYC & Intel Xeon compute cores, unmetered bandwidth, and automated DDoS mitigation.
Related Technical Guides
JMusicBot
How to Host JMusicBot & Lavalink 4 for Crystal Clear Discord Audio
Complete setup guide for self-hosting JMusicBot and connecting it to a dedicated Lavalink 4 audio server with high player capacity.
Read guide→
Telegram Bot
How to Build and Deploy a 24/7 Telegram Bot with Python and Systemd
Step-by-step guide to writing a high-throughput Telegram bot using Aiogram / python-telegram-bot and managing it as a background service on Linux.
Read guide→
Ready to upgrade your infrastructure?
Experience the Altivora difference with 99.99% uptime SLA and 60-second setup.
