All Projects → MrJacz → Discord.js Lavalink

MrJacz / Discord.js Lavalink

Licence: mit
A discord.js lavalink client

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Discord.js Lavalink

Progress Bot
High-tech weaponized moe progress delivery bot for IRC, Discord, and web
Stars: ✭ 38 (-38.71%)
Mutual labels:  discord-bot, discord
Bottyclient
A slim Discord client with many cool features including less network traffic which supports bot tokens, but user tokens theoretically work too. Tags: Discord Bot Client Token for Bot Botting Download English
Stars: ✭ 58 (-6.45%)
Mutual labels:  discord-bot, discord
Promcord
📊 Analyze your entire discord guild in grafana using prometheus. Message, User, Game and Voice statistics...
Stars: ✭ 39 (-37.1%)
Mutual labels:  discord-bot, discord
Crucian
⚡ Discord bot with economy, gambling, music, fun, moderation features based on discord.js v12
Stars: ✭ 55 (-11.29%)
Mutual labels:  discord-bot, discord
Dagbot
The official Repository for dagbot, the self proclaimmed n1 meme bot.
Stars: ✭ 40 (-35.48%)
Mutual labels:  discord-bot, discord
Whatsapptodiscord
WhatsAppToDiscord is a Discord bot uses WhatsApp Web for messaging in Discord built on top of go-whatsapp and discordgo
Stars: ✭ 35 (-43.55%)
Mutual labels:  discord-bot, discord
Zira
Zira is a Discord Bot that allows you to react to an emoji on a message and manage a users roles.
Stars: ✭ 55 (-11.29%)
Mutual labels:  discord-bot, discord
Ninjabotcore
C# Discord Bot Created Using .Net Core
Stars: ✭ 34 (-45.16%)
Mutual labels:  discord-bot, discord
Automod Bot
Fun moderation economy bot discord.js
Stars: ✭ 41 (-33.87%)
Mutual labels:  discord-bot, discord
Juniperbot
Fluffy Discord Bot (Music, Ranking, Reminder, Vk Community bridge,WikiFur) created using JDA
Stars: ✭ 43 (-30.65%)
Mutual labels:  discord-bot, discord
Smorebot
SmoreBot is a fun, lightweight, multipurpose bot packed with features.
Stars: ✭ 51 (-17.74%)
Mutual labels:  discord-bot, discord
Kyoko
Moved to GitLab: https://gitlab.com/KyokoBot
Stars: ✭ 50 (-19.35%)
Mutual labels:  discord-bot, discord
Discord4j
Discord4J is a fast, powerful, unopinionated, reactive library to enable quick and easy development of Discord bots for Java, Kotlin, and other JVM languages using the official Discord Bot API.
Stars: ✭ 973 (+1469.35%)
Mutual labels:  discord-bot, discord
Clara
A general purpose Node.JS bot for Discord.
Stars: ✭ 37 (-40.32%)
Mutual labels:  discord-bot, discord
Cj
CJ is a Discord bot that hangs around in the open.mp/burgershot.gg community discord.
Stars: ✭ 34 (-45.16%)
Mutual labels:  discord-bot, discord
Jeelangamusic
Discord bot with music functional. Play, skip, save music and etc!
Stars: ✭ 40 (-35.48%)
Mutual labels:  discord-bot, discord
Discord Bot
🤖 Our BIG help in things about moderation and many more useful stuff on our Discord server.
Stars: ✭ 30 (-51.61%)
Mutual labels:  discord-bot, discord
Modmail
A feature rich discord Modmail bot
Stars: ✭ 957 (+1443.55%)
Mutual labels:  discord-bot, discord
Calebj Cogs
⚙ Cogs for Red-Discordbot
Stars: ✭ 42 (-32.26%)
Mutual labels:  discord-bot, discord
Community Bot
The bot used on the TypeScript Community discord server
Stars: ✭ 46 (-25.81%)
Mutual labels:  discord-bot, discord

Discord npm npm downloads NPM version Build Status Codacy Badge Open Source Love dependencies Status devDependencies Status NPM

discord.js-lavalink

A lavalink client for Discord.js

Documentation

mrjacz.github.io/discord.js-lavalink

Installation

For stable

# Using yarn
yarn add discord.js-lavalink

# Using npm
npm install discord.js-lavalink

For Development

# Using yarn
yarn add MrJacz/discord.js-lavalink

# Using npm
npm install MrJacz/discord.js-lavalink

LavaLink configuration

Download from the CI server

Put an application.yml file in your working directory. Example

Run with java -jar Lavalink.jar

The issue tracker is for issues only

If you're having a problem with the module contact us in the Discord Server

Implementation

Start by creating a new PlayerManager passing an array of nodes and an object with user the client's user id and shards The total number of shards your bot is operating on.

const { PlayerManager } = require("discord.js-lavalink");

const nodes = [{ host: "localhost", port: 2333, password: "youshallnotpass" }];

const manager = new PlayerManager(client, nodes, {
    user: client.user.id, // Client id
    shards: shardCount // Total number of shards your bot is operating on
});

manager.on("error", (node, error) => {
    node; // is the node which the error is from
    error; // is the error;
});

Resolving tracks using LavaLink REST API

const fetch = require("node-fetch");
const { URLSearchParams } = require("url");

async function getSongs(search) {
    const node = client.player.nodes.first();

    const params = new URLSearchParams();
    params.append("identifier", search);

    return fetch(`http://${node.host}:${node.port}/loadtracks?${params}`, { headers: { Authorization: node.password } })
        .then(res => res.json())
        .then(data => data.tracks)
        .catch(err => {
            console.error(err);
            return null;
        });
}

getSongs("ytsearch:30 second song").then(songs => {
    // handle loading of the tracks somehow ¯\_(ツ)_/¯
});

Joining and Leaving channels

// Join
const player = await manager.join({
    guild: guildId, // Guild id
    channel: channelId, // Channel id
    host: "localhost" // lavalink host, based on array of nodes
});

await player.play(track); // Track is a base64 string we get from Lavalink REST API

player.once("error", error => console.error(error));
player.once("end", data => {
    if (data.reason === "REPLACED") return; // Ignore REPLACED reason to prevent skip loops
    // Play next song
});

// Leave voice channel and destory Player
await manager.leave(guildId); // Player ID aka guild id

For a proper example look at example/app.js

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].