Skip to main content
Version: 2.0.0

Ruvyrias v1 → v2 Migration Guide


Overview

Ruvyrias v2 introduces major changes compared to v1. Many methods and properties have been renamed, redesigned, or replaced, so updating your code requires careful attention. This guide highlights key updates, with visual diff-style examples (+ added, - removed) for clarity.


1. Joining Voice Channels

In v2, not only were the method names changed, but several properties were renamed and restructured. This section shows a side-by-side comparison.

v1 Example:

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

v2 Example:

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

Key Changes:

  • createConnectioncreatePlayer
  • voiceChannelvoiceChannelId
  • textChanneltextChannelId
  • deafselfDeaf
  • muteselfMute

⚠️ Important: These changes are breaking, so any v1 code will need to be updated to use the new properties and method names.


2. Searching for Tracks

In v2, the method for searching tracks has changed from client.ruvyrias.resolve to client.ruvyrias.search. Here's the comparison.

v1 Example:

- const resolve = await client.ruvyrias.resolve({
- query: 'lorna shore prison of flesh',
- requester: message.author
- });

v2 Example:

+ const resolve = await client.ruvyrias.search({
+ query: 'lorna shore prison of flesh',
+ requester: message.author
+ });

Key Changes:

  • client.ruvyrias.resolveclient.ruvyrias.search

3. Ruvyrias Client Initialization

v2 changes the structure of the client initialization and moves some properties, including resume. Some values now use enums, which must be imported.

v1 Example:

- client.ruvyrias = new Ruvyrias(client, [
- {
- name: 'main',
- host: 'localhost',
- port: 2333,
- password: 'youshallnotpass',
- secure: false,
- resume: true,
- }
- ],{
- library: 'discord.js',
- defaultPlatform: 'ytsearch',
- autoResume: true,
- reconnectTries: Infinity,
- reconnectTimeout: 1000 * 10,
- });

v2 Example:

+ import { LibrariesType, PlatformsType } from 'ruvyrias';
+
+ 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,
+ });

Key Changes:

  • passwordauth
  • resume moved from the node object to the client options object
  • library and defaultPlatform now use enums (LibrariesType and PlatformsType)
  • Enums must be imported from Ruvyrias

4. Event Handling Changes

In v2, events are now represented as enums (RuvyriasEvent). Previously, all events were plain strings, but now you must use the enum keys.

v1 Example:

- client.ruvyrias.on('nodeConnect', node => { ... });
- client.ruvyrias.on('trackStart', (player, track) => { ... });
- client.ruvyrias.on('queueEnd', player => { ... });

v2 Example:

+ import { RuvyriasEvent } from 'ruvyrias';
+
+ client.ruvyrias.on(RuvyriasEvent.NodeConnect, node => { ... });
+ client.ruvyrias.on(RuvyriasEvent.TrackStart, track => { ... });
+ client.ruvyrias.on(RuvyriasEvent.QueueEnd, player => { ... });

Key Changes:

  • All event keys are now enum values: RuvyriasEvent.Debug, RuvyriasEvent.Raw, RuvyriasEvent.NodeConnect, etc.
  • Must import RuvyriasEvent from the library
  • Additional events now include NodeDisconnect, NodeCreate, NodeDestroy, NodeReconnect, NodeError, SocketClose, TrackEnd, TrackError, QueueAdd, QueueRemove, PlayerUpdate, PlayerCreate, PlayerDestroy
  • Update all existing event listeners to reference these enums instead of strings

5. Player Methods Updates

Player Pause / Unpause

In Ruvyrias v1, pausing and resuming a player was controlled with a single method and a boolean parameter. In v2, this has been split into two separate methods for clarity.

v1 Example:

// Pause the player
player.pause(true);

// Resume the player
player.pause(false);

v2 Example:

// Pause the player
player.pause();

// Resume the player
player.resume();

Key Changes

  • player.pause(true)player.pause()
  • player.pause(false)player.resume()
  • This change makes the API more explicit and easier to read.
  • No boolean parameter is needed anymore; pause and unpause are separate actions.

⚠️ Important: Update all instances where player.pause(true/false) is used to the new method calls to avoid runtime errors.

Loop Mode Using Enum

The setLoop method still exists but now uses a LoopType enum instead of string literals.

v1 Example:

- player.setLoop('TRACK');

v2 Example:

+ import { LoopType } from 'ruvyrias';
+ player.setLoop(LoopType.Track);

Key Changes:

  • Strings 'NONE', 'TRACK', 'QUEUE' are replaced with LoopType.Off, LoopType.Track, LoopType.Queue
  • Method signature: setLoop(mode: LoopType)
  • Must import LoopType from Ruvyrias
  • Update all calls to use the enum instead of raw strings

Seek Method Renamed

The previous seekTo method was renamed to seek in v2. It allows seeking to a specific position in the current track.

v2 Example:

+ await player.seek(120000); // Seeks to 2 minutes in the current track

Key Changes:

  • Method renamed: seekTo(position: number)seek(position: number)
  • Returns a Promise<Player>

Queue Enhancements

The Queue class now includes two new methods:

removeDuplicates

+ const removed = queue.removeDuplicates();
+ // Removes duplicate tracks based on their URI

jump

+ const success = queue.jump(5);
+ // Skips to the 5th track in the queue, removing all previous tracks

Key Changes:

  • removeDuplicates() removes tracks with duplicate URIs
  • jump(position) allows skipping to a specific track in the queue
  • Both methods emit the proper events when tracks are removed

6. Using Built-in Plugins

v2 changes how built-in plugins (Spotify, Deezer, AppleMusic) are instantiated. They are now accessed through the Plugin namespace, and some option keys may have changed.

v1 Example:

- const { Client } = require('discord.js');
- const { Spotify } = require('ruvyrias');
-
- const spotify = new Spotify({
- clientID: 'client-id-here',
- clientSecret: 'client-secret-here',
- });
-
- const RuvyriasOptions = {
- library: 'discord.js',
- defaultPlatform: 'spsearch',
- plugins: [spotify],
- };

v2 Example:

+ import { LibrariesType, PlatformsType, Plugin } from 'ruvyrias';
+ const { Client } = require('discord.js');
+
+ const spotify = new Plugin.Spotify({
+ clientId: 'client-id-here',
+ clientSecret: 'client-secret-here',
+ });
+
+ const RuvyriasOptions = {
+ library: LibrariesType.DiscordJS,
+ defaultPlatform: PlatformsType.YtSearch,
+ plugins: [spotify],
+ };

Key Changes:

  • Built-in plugins are accessed through Plugin namespace: Plugin.Spotify, Plugin.Deezer, Plugin.AppleMusic
  • Option keys may have changed (clientIDclientId) depending on the plugin
  • library and defaultPlatform now use enums
  • Import necessary enums and the Plugin object from Ruvyrias

7. Next Steps

  • Update all plugin instantiations to use Plugin namespace.
  • Adjust any option key changes according to v2.
  • Ensure proper enum imports for library, defaultPlatform, and RuvyriasEvent.
  • Refactor calls to setLoop to use the new seek method.
  • Explore new Queue methods removeDuplicates() and jump(position) for advanced queue management.

Note: This document is a draft and supports live editing for incremental updates and collaboration.