Skip to main content
Version: 2.0.0

Usage

Basic Usage

const { Client, GatewayIntentBits, ActivityType } = require('discord.js');
const { Ruvyrias, RuvyriasEvent, LibrariesType, PlatformsType } = require('ruvyrias');

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

client.ruvyrias = new Ruvyrias(client,
[{
name: 'main',
host: 'localhost',
port: 2333,
auth: 'youshallnotpass',
secure: false,
}],
,{
library: LibrariesType.DiscordJS,
defaultPlatform: PlatformsType.YtSearch,
resume: true,
autoResume: true,
reconnectTries: Infinity,
reconnectTimeout: 1000 * 10,
});

client.on('ready', (client) => {
console.log(`[+] Logged in as: ${client.user?.tag}`);
client.ruvyrias.init(client);

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

client.on('messageCreate', async (message) => {
if (!message.content.toLowerCase().startsWith('!') || message.author.bot) return;

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

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

const player = client.ruvyrias.createPlayer({
guildId: message.guildId,
voiceChannelId: message.member.voice.channel.id,
textChannelId: message.channelId,
selfDeaf: true,
selfMute: false
});

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

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

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

if (!player.isPlaying && !player.isPaused) return player.play();
return message.reply(`🎶 [${playlistInfo?.name}](${query}) with \`${tracks.length}\` tracks added.`);
}
else if (loadType === 'search' || loadType === 'track') {
const track = tracks[0];
player.queue.add(track);

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

client.ruvyrias.on(RuvyriasEvent.NodeConnect, node => {
console.log(`[+] Node ${node.options.name} connected.`)
});

client.ruvyrias.on(RuvyriasEvent.TrackStart, track => {
const channel = client.channels.cache.get(player.textChannel);

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

client.ruvyrias.on(RuvyriasEvent.QueueEnd, player => {
player.stop();

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

client.login('token');

Implementation Repositories

Note: Send PR to add your repository here.

RepositoryCreatorAdditional Information
Ruvyrias ExampleDarkslayerHaosOfficial Ruvyrias Exampe Bot, easy setup and usage.