npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

ruvyrias

v1.3.7

Published

A stable and powerful Lavalink client for NodeJS.

Downloads

331

Readme

Note: This version supports only Lavalink V4 or above.

Table of contents

Installation

# Using npm
npm install ruvyrias

# Using yarn
yarn add ruvyrias

About

To use, you need a configured Lavalink instance.

Ruvyrias is a robust Discord music bot client tailored for Lavalink V4 and above. Key features include:

  • Stability: A reliable and smooth client experience.
  • TypeScript Support: Enhanced development with TypeScript.
  • Lavalink Compatibility: 100% compatible with Lavalink version 4 and above.
  • Object-Oriented: Organized and maintainable code.
  • Customizable: Adapt the client to your bot preferences.
  • Easy Setup: Quick and hassle-free installation.
  • Queue System: Efficiently manage music playback.
  • Platform Support: Built-in compatibility with Youtube, Soundcloud, Spotify, Apple Music, and Deezer.

Implementation Repositories

Note: Send PR to add your repository here.

| Repository | Creator | Additional Information | | ---------------------------------------------------------------------- | ----------------------------------------------------| ----------------------------------------------------| | Ruvyrias Example | DarkslayerHaos | Official Ruvyrias Exampe Bot, easy setup and usage. | | Lunox | adh319 | Check out the repository for futher information. |

Basic Usage

// Import necessary modules.
const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
const { Ruvyrias } = require('ruvyrias');

// Define Lavalink nodes configuration.
const nodes = [
    {
        name: 'main',
        host: 'localhost',
        port: 2333,
        password: 'youshallnotpass',
        secure: false,
        resume: true,
    },
];

// Define options for Ruvyrias client.
const RuvyriasOptions = {
    library: 'discord.js',
    defaultPlatform: 'ytsearch',
    autoResume: true,
    reconnectTries: Infinity,
    reconnectTimeout: 1000 * 10,
};

// Initialize Discord client with necessary intents.
const client = new Client({
    intents: [
        GatewayIntentBits.Guilds,
        GatewayIntentBits.GuildMessages,
        GatewayIntentBits.GuildVoiceStates,
        GatewayIntentBits.MessageContent,
    ],
});

// Create Ruvyrias instance and bind it to the client.
client.ruvyrias = new Ruvyrias(client, nodes, RuvyriasOptions);

// Event handler for when the bot is ready.
client.on('ready', (client) => {
    console.log(`[+] Logged in as: ${client.user?.tag}`);
    client.ruvyrias.init(client);

    client.user.setActivity({ name: '!play', type: ActivityType.Listening })
});

// Event handler for message creation.
client.on('messageCreate', async (message) => {
    // Ignore messages that don't start with '!' or are from bots.
    if (!message.content.toLowerCase().startsWith('!') || message.author.bot) return;

    // Extract command and arguments from the message
    const args = message.content.slice(1).trim().split(/ +/g);
    const command = args.shift()?.toLowerCase()

    if (command === 'play') {
        const query = args.join(' ');

        // Creating the Player.
        const player = client.ruvyrias.createConnection({
            guildId: message.guildId,
            voiceChannel: message.member.voice.channel.id,
            textChannel: message.channelId,
            deaf: true,
            mute: false
        });

        const resolve = await client.ruvyrias.resolve({ query, requester: message.author });
        const { loadType, tracks, playlistInfo } = resolve;

        // Handle errors or empty responses.
        if (loadType === 'error' || loadType === 'empty') {
            return message.reply({ embeds: [{ description: `❌ An error occurred, please try again!`, color: Colors.Red }] });
        }

        // Handle playlist loading.
        if (loadType === 'playlist') {
            for (const track of tracks) {
                player.queue.add(track);
            }

            if (!player.playing && !player.paused) return player.play();
            return message.reply(`🎶 [${playlistInfo?.name}](${query}) with \`${tracks.length}\` tracks added.`);
        } 
        // Handle single track or search results loading.
        else if (loadType === 'search' || loadType === 'track') {
            const track = tracks[0];
            player.queue.add(track);

            if (!player.playing && !player.paused) return player.play();
            return message.channel.send(`🎶 \`${track.info.title}\` added to queue.`);
        }
    }
});

// Runs when a Lavalink Node is successfully connected.
client.ruvyrias.on('nodeConnect', node => {
    console.log(`[+] Node ${node.options.name} connected.`)
});

// Runs when a new track starts playing in the music player.
client.ruvyrias.on('trackStart', (player, track) => {
    const channel = client.channels.cache.get(player.textChannel);

    channel.send(`🎶 Now playing: \`${track.info.title}\` by \`${track.info.author}\`.`);
});

// Runs when the music playlist reaches the end and the music player leaves the voice channel.
client.ruvyrias.on('queueEnd', player => {
    player.stop();

    const channel = client.channels.cache.get(player.textChannel);
    channel.send('⛔ The player queue has ended, i\'m leaving voice channal!');
});

// Log in the bot using the provided token.
client.login('token');

Credits

The Ruvyrias client, customized by DarkslayerHaos, is a fork originally derived from the code of Poru developed by Parasop.