All Projects → lavacord → Lavacord

lavacord / Lavacord

Licence: Apache-2.0 license
A easy to use Lavalink client that can be used with any discord api wrapper

Programming Languages

typescript
32286 projects

Projects that are alternatives of or similar to Lavacord

Shoukaku
A featureful stable wrapper for Lavalink
Stars: ✭ 140 (+125.81%)
Mutual labels:  discordjs, eris, discord-js, lavalink, lavalink-client, lavalink-wrapper, lavalink-music
NanoSpace
Erela.js & Discord.js@v14 (Prefix Commands!)
Stars: ✭ 59 (-4.84%)
Mutual labels:  discordjs, discord-js, lavalink, lavalink-music
lavalink-list
A list of free and available public lavalink. Feel free to make a pull request!
Stars: ✭ 43 (-30.65%)
Mutual labels:  lavalink, lavalink-client, lavalink-music
zuly
🤖 | Hi, I'm zuly, a brazilian bot! Focused on animes!
Stars: ✭ 45 (-27.42%)
Mutual labels:  discordjs, eris, discord-js
lavamusic
lavalink music bot base in erela.js and discord.js v13
Stars: ✭ 210 (+238.71%)
Mutual labels:  discord-js, lavalink, lavalink-music
Discord-Tools
VSCode extension allowing the integration of a Discord chat, bot templates, snippets, themes and more!
Stars: ✭ 91 (+46.77%)
Mutual labels:  discordjs, eris, discord-js
Nova-Bot
This bot was created using discord.js v12. This bot offers you many powerful commands ranging from moderation to economy.
Stars: ✭ 37 (-40.32%)
Mutual labels:  discordjs, discord-js
KannaKamuiBot
A multipurpose bot for fun, emotes, anime, utility, music, nsfw, valorant, moderation, and welcome/leave messages.
Stars: ✭ 64 (+3.23%)
Mutual labels:  discordjs, discord-js
command-handler
Discord Bot (w/ Command Handler)
Stars: ✭ 25 (-59.68%)
Mutual labels:  discordjs, discord-js
ApocaBot
ApocaBot: A Discord Bot for PbtA Games
Stars: ✭ 30 (-51.61%)
Mutual labels:  discordjs, discord-js
multiple-purpose-discord-bot-like-carlbot
A MultiPurpose Discord bot Named Dumb Bot which does Almost Everything You will need in one bot and with 230+ Commands and does almost everything which is in carl-bot or dyno
Stars: ✭ 70 (+12.9%)
Mutual labels:  discordjs, discord-js
Discord.JS-Coding-Tutorials
🙂 A full Discord.JS v12 Guide for making Discord Bots by DashCruft on YouTube
Stars: ✭ 58 (-6.45%)
Mutual labels:  discordjs, discord-js
Discord-BOT-Dashboard-V2
Discord BOT Dashboard V2 is made to make Discord BOT Development easy, designed to help create applications without writing a single line of code while using a user friendly Web-Dashboard!
Stars: ✭ 120 (+93.55%)
Mutual labels:  discordjs, discord-js
discord-guide-fa
اینجا یاد میگیرید چطور از صفر یک دیسکورد بات بسازید 🐱‍🏍
Stars: ✭ 69 (+11.29%)
Mutual labels:  discordjs, discord-js
discord-altyapi-bot
Discord Bot Altyapısı - Discord.js v14 Altyapı
Stars: ✭ 172 (+177.42%)
Mutual labels:  discordjs, discord-js
Hurricano
An amazing open-source Discord bot using MongoDB with many features such as a customizable prefix, a reaction menu, music, role requirement giveaways and much more!
Stars: ✭ 97 (+56.45%)
Mutual labels:  discordjs, discord-js
Discord-Template-V13
An easy-to-use discord bot including database, slash commands and context menus !
Stars: ✭ 103 (+66.13%)
Mutual labels:  discordjs, discord-js
discord-clock
A simple clock script for your bot to show what time it is in your server | Discord.js v13 ready!
Stars: ✭ 29 (-53.23%)
Mutual labels:  discordjs, discord-js
slshx
⚔️ Strongly-typed Discord commands on Cloudflare Workers
Stars: ✭ 163 (+162.9%)
Mutual labels:  discordjs, discord-js
mikaela
Mikaela is a discord music bot that gives users the ability to store their favorite songs, and create playlists on discord.
Stars: ✭ 19 (-69.35%)
Mutual labels:  discordjs, discord-js

Discord npm (scoped) npm downloads GitHub Depfu Codacy Badge

LavaCord

A simple and easy to use lavalink wrapper.

Documentation

lavacord.github.io/lavacord

Installation

For stable

# Using yarn
yarn add lavacord

# Using npm
npm install lavacord

For Development

# Using yarn
yarn add lavacord/lavacord

# Using npm
npm install lavacord/lavacord

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 Manager 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.

// import the Manager class from lavacord
const { Manager } = require("lavacord");

// Define the nodes array as an example
const nodes = [
    { id: "1", host: "localhost", port: 2333, password: "youshallnotpass" }
];

// Initilize the Manager with all the data it needs
const manager = new Manager(nodes, {
    user: client.user.id, // Client id
    shards: shardCount, // Total number of shards your bot is operating on
    send: (packet) => {
        // this needs to send the provided packet to discord using the method from your library. use the @lavacord package for the discord library you use if you don't understand this
    }
});

// Connects all the LavalinkNode WebSockets
await manager.connect();

// The error event, which you should handle otherwise your application will crash when an error is emitted
manager.on("error", (error, node) => {
    error, // is the error
    node // is the node which the error is from
});

Resolving tracks using LavaLink REST API

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

async function getSongs(search) {
    // This gets the best node available, what I mean by that is the idealNodes getter will filter all the connected nodes and then sort them from best to least beast.
    const node = manager.idealNodes[0];

    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
    node: "1" // lavalink node id, 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
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].