A NodeJS package for voice channel interactions on Revolt. This package lets you join voice channels, play music and more!

Overview

Revoice.js - A Voice Module for Revolt

This package is still in developement and lacks many features.

You still are able to play sound to a voice channel. Other features like channel info will follow.

TODO:

  • Play/Pause for the media class (help apreciated ;))
  • Non-voice events like UserJoined and roominfo
  • Audio reception
  • Error Handling; Right now, you have to take care of things like stopping the music if you start to play another song while one is playing

Disclamer: I might have forgotten some things on the list and thus it might be extended. Feel free to open issues to suggest new features :)

Installation

Just execute npm install revoice.js to install the package, have fun! :)

Usage

TL;DR: You initiate a client, you join a voice channel and then you play media.

Please note that unlike on Discord bots, Revolt bots are able to join multiple voice channels at once. Thus a single bot is able to be in every voice channel it has access to. I have no idea about the limitations.

Media has to be created using the MediaPlayer class. You can stream both node streams and media files to revolt.

Example:

const { Revoice, MediaPlayer } = require("revoice.js");
const fs = require("fs");

const revoice = new Revoice("the-token-of-your-bot");
const connection = await revoice.join("the-voice-channel-id");
const media = new MediaPlayer();
connection.on("join", () => {
  connection.play(media); // playing audio does only work after the the bot joined the voice channel

  // IMPORTANT: If you want to hear music,
  // you have to call connection.play(media)
  // BEFORE you start playing something in the media player

  media.playFile("./assets/some-nice-song.mp3");
  // or something like the following:
  media.playStream(fs.createReadStream("./assets/some-nice-song.mp3"));

  // you don't have to store the voice connection, you can retrieve it if you have the id of the voice channel like this:
  const con = revoice.getVoiceConnection("someChannelId");

  // ... pause it
  media.pause();

  // ... resume it later
  media.resume();
});

Rejoice for Revoice!

API

Revoice Client

Properties/Methods:

  • on(event, callback): Equally to EventEmitter.on, for supported events refer to: The Events section
  • once(event, callback): Equally to EventEmitter.once, refer to on()
  • join(channelId): Connect to a voice channel; channelId typeof String
  • getVoiceConnection(channelId): Returns the voice connection to the given channel; Params: channelId typeof String

VoiceConnection

Properties/Methods:

  • play(media): Stream a MediaPlayer(Or Media) object to the current voice channel
  • leave(): Leave the voice channel and destroy the connection

Events:

  • state:
    • Data: typeof Revoice.State;
    • This event gets fired whenever the current state changes. The possible states are:
      • State.OFFLINE: The bot hasn't joined any channel yet
      • State.IDLE: The bot is in a voice channel but isn't doesn't play anything
      • State.JOINING: The bot is currently in the join process
      • State.PLAYING: The bot is in a voice channel and transmitting sound
      • State.BUFFERING: The bot is in a voice channel and there is a stream with audio buffering
      • State.PAUSED: The bot is in a voice channel and the audio has been paused
      • State.UNKNOWN: The bot is in a voice channel and might be playing something. This occurs when you choose to use the Media class as the Media class just contains some base functionality
  • join:
    • Data: empty
    • This events get fired after the bot has successfully established a connection with the voice channel
  • leave
    • Data: empty
    • This event gets fired after the bot has left a voice channel

MediaPlayer

Constructor:

new MediaPlayer(logs?, port?):

  • Creates a new Revoice-compatible media player object with basic sound controls like play/pause
  • Parameters:
    • logs: typeof Boolean; Wether or not output ffmpeg logs in the console; Optional, default: false
    • port: typeof int; The port ffmpeg should send the rtp data to; Optional but should be changed if wanting to run multiple instances, defaults to 5030

Properties/Methods:

Inherits from the Media class

  • getMediaTrack(): Get the MediaStreamTrack used for WebRTC transports
  • playFile(path): Play the file from the given filePath; Param typeof String
  • playStream(stream): Play a ReadableStream; Param typeof Readable
  • pause(): Pause the current playback if playing
  • resume(): Unpause the current playback if paused (This function is developement but working)
  • stop(): Completely stop the current playback; This can be used to stop a song to play another
  • on(event, callback): Equally to EventEmitter.on, for supported events refer to: The Events section
  • once(event, callback): Equally to EventEmitter.once, refer to on()

Events:

  • start:
    • Data: empty
    • This event gets fired when the MusicPlayer starts to process music. This includes buffering and playing
  • finish:
    • Data: empty
    • This event gets fired when a music stream finishes to stream. This feature is under developement but working

Media

This class should only be used if you want to implement your own MediaPlayer class.

Constructor:

new Media(logs?, port?):

  • Creates a new Revoice-compatible media object
  • Parameters:
    • logs: typeof Boolean; Wether or not output ffmpeg logs in the console; Optional, default: false
    • port: typeof int; The port ffmpeg should send the rtp data to; Optional, defaults to 5030

Properties/Methods:

  • getMediaTrack(): Get the MediaStreamTrack used for WebRTC transports
  • playFile(path): Play the file from the given filePath; Param typeof String
  • playStream(stream): Play a ReadableStream; Param typeof Readable

Signaling

WIP

You might also like...

Voice Controlled Discord Music Bot in discord.js v14

Voice Controlled Discord Music Bot in discord.js v14

Voice Controlled Discord Bot This repository is for the 5th Hackathon of Documatic. With that Project I am aiming to place #1 and win 50โ‚ฌ About It is

Nov 28, 2022

Music-Player - Music player application built with HTML, CSS and vanilla JavaScript

Music-Player - Music player application built with HTML, CSS and vanilla JavaScript

Music-Player Music player application built with HTML, CSS and vanilla JavaScrip

Feb 10, 2022

A decentralized Music Ownership System developed on Truffle Suite and React Bootstrap to allow Music artists to upload their content to the blockchain, that can be streamed by users

A decentralized Music Ownership System developed on Truffle Suite and React Bootstrap to allow Music artists to upload their content to the blockchain, that can be streamed by users

A decentralized Music Ownership System developed on Truffle Suite and React Bootstrap to allow Music artists to upload their content to the blockchain, that can be streamed by users.

Sep 5, 2022

๐Ÿš€ Blazing fast thread channels integration for all Discord.js versions

djs-threads ๐Ÿš€ Blazing fast thread integration for all Discord.js versions ๐Ÿ˜ƒ THIS PROJECT IS ARCHIVED this project is archived because Discord will c

Feb 28, 2022

A mobile app for playing music on Resonate, an open source music streaming co-op.

stream2own Play fair. Website | Twitter | Contributing | Developer Guide ๐ŸŽต Resonate Stream App A mobile app for playing music on Resonate, an open so

Dec 28, 2022

A quick-start template for Discord.js v14 in TypeScript that contains handling for commands, events, and interactions!

Typescript-Discord.js-v14-Template A quick-start template for Discord.js v14 in Typescript that contains handling for commands, events, and interactio

Dec 28, 2022

Manoj Bajpayee Bot offers funny interactions on your discord server.

Manoj Bajpayee Discord Bot Invite Link : https://discord.com/api/oauth2/authorize?client_id=986232247680118814&permissions=534857121088&scope=bot Inst

Jul 17, 2022

Discord-Bot - You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have published on my youtube channel.

Discord-Bot You can use the discord bot codes that are updated in every video of the codes I use in the discord bot making series that I have publishe

Jan 3, 2023

Web Application that represents a music player using the spotify API, React, JS, CSS, HTML, nodeJS, Firebase, material-ui, JSON and other technologies. Made by Yohan Hmaiti

Web Application that represents a music player using the spotify API, React, JS, CSS, HTML,  nodeJS, Firebase, material-ui, JSON and other technologies. Made by Yohan Hmaiti

Web Application that represents a music player using the spotify API, React, JS, CSS, HTML, nodeJS, Firebase, material-ui, JSON and other technologies. Made by Yohan Hmaiti

Jan 8, 2022
Comments
  • ReferenceError: MediaPlayer is not defined

    ReferenceError: MediaPlayer is not defined

    /home/runner/SeveralDullConnections/index.js:6
      const media = new MediaPlayer();
                    ^
    
    ReferenceError: MediaPlayer is not defined
        at EventEmitter.<anonymous> (/home/runner/SeveralDullConnections/index.js:6:17)
        at EventEmitter.emit (node:events:390:28)
        at EventEmitter.emit (node:domain:475:12)
        at Revoice.emit (/home/runner/SeveralDullConnections/node_modules/revoice.js/Revoice.js:68:30)
        at Revoice.initTransports (/home/runner/SeveralDullConnections/node_modules/revoice.js/Revoice.js:99:10)
        at EventEmitter.<anonymous> (/home/runner/SeveralDullConnections/node_modules/revoice.js/Revoice.js:58:12)
        at EventEmitter.emit (node:events:390:28)
        at EventEmitter.emit (node:domain:475:12)
        at Signaling.processWS (/home/runner/SeveralDullConnections/node_modules/revoice.js/Signaling.js:64:27)
    repl process died unexpectedly: exit status 1
    
    opened by NoLogicAlan 7
  • [High Priority] Bug Fixing of pause/resume and leave

    [High Priority] Bug Fixing of pause/resume and leave

    Resuming a paused song would make the ffmpeg state of the song interfere with the actual one. Fixing in progress.

    After leaving the bot would rejoin and the next time it is asked to leave it would crash

    opened by ShadowLp174 1
  • little bug fixes, readme issue update

    little bug fixes, readme issue update

      media.playStream(fs.createReadStream("./assets/warbringer.mp3"));
                       ^
    
    ReferenceError: fs is not defined
        at EventEmitter.<anonymous> (C:\Users\rzzr4\Downloads\SeveralDullConnections\index.js:9:20)
        at EventEmitter.emit (node:events:513:28)
        at Revoice.emit (C:\Users\rzzr4\Downloads\SeveralDullConnections\node_modules\revoice.js\Revoice.js:68:30)
        at Revoice.initTransports (C:\Users\rzzr4\Downloads\SeveralDullConnections\node_modules\revoice.js\Revoice.js:99:10)
        at EventEmitter.<anonymous> (C:\Users\rzzr4\Downloads\SeveralDullConnections\node_modules\revoice.js\Revoice.js:58:12)
        at EventEmitter.emit (node:events:513:28)
        at Signaling.processWS (C:\Users\rzzr4\Downloads\SeveralDullConnections\node_modules\revoice.js\Signaling.js:64:27)
        at WebSocket.<anonymous> (C:\Users\rzzr4\Downloads\SeveralDullConnections\node_modules\revoice.js\Signaling.js:58:12)
        at WebSocket.emit (node:events:513:28)
        at Receiver.receiverOnMessage (C:\Users\rzzr4\Downloads\SeveralDullConnections\node_modules\ws\lib\websocket.js:1178:20)
    
    opened by NoLogicAlan 1
  • Vortex Rewrite

    Vortex Rewrite

    Vortex (The server that powers revolt voice channels) will be rewritten soon:tm:. The development of this library will be paused until there.

    This isn't the end though. As soon as the rewrite releases, I'll rewrite this library. I hope that many bugs will disappear as vortex is moving away from mediasoup, which lacks a proper nodejs version.

    See you then :>

    in progress 
    opened by ShadowLp174 0
Releases(v0.1.734-old-vortex)
  • v0.1.734-old-vortex(Oct 19, 2022)

    This is the revoice version, working for the current (19. October 2022) vortex servers. As the rewrite is nearly finished, this version has been closed to develop a new one for the new system.

    The new revoice.js will be available soon:tm:

    Source code(tar.gz)
    Source code(zip)
Owner
ShadowLp174
Hobby JS, Java and PHP programmer.
ShadowLp174
This DJS ticket system with transcripts is fully configurable, you can change the transcripts channel, tickets channel, and more

This DJS ticket system with transcripts is fully configurable, you can change the transcripts channel, tickets channel, and more! This command uses embeds, and buttons.

LunarCodes 6 Oct 18, 2022
Iโ€™m a very useful music bot that can make you play a music with a simple command! I have a lot of good commands that you can have a better experience playing your favorites songs!

Iโ€™m a very useful music bot that can make you play a music with a simple command! I have a lot of good commands that you can have a better experience playing your favorites songs!

Hugo Kishi 2 Aug 16, 2022
An simple package to create an Activity in Discord Voice Channel using Discord.js

discordjs-activity An simple package to create an Activity in Discord Voice Channel using Discord.js ?? | Installation npm install discordjs-activity

Sudhan 55 Nov 15, 2022
๐Ÿ”Š first auto join discord selfbot - just with one command join it to your server ๐Ÿ”ฅ

?? Messi (Discord Self Bot) first auto join discord selfbot - just with one command join it to your server discord.js-selfbot ?? Requirements Discord

Parsa 25 Dec 12, 2022
Advanced Music Bot It is an advance type of discord music bot which plays high quality of music with spotify

Advanced Music Bot It is an advance type of discord music bot which plays high quality of music with spotify, apple music support . You can save your songs and play it. It also has DJ mode system.

Diwas Atreya 65 Dec 25, 2022
It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with buttons. It can play youtube songs, playlists. This bot code was made by Supreme#2401. It uses djs V12

Lofi-Radio-Music-Bot It is a discord bot bot which can play lofi song in different language 24/7. It has premium system and cool embed looks with butt

Diwas Atreya 89 Jan 2, 2023
Revoltchat-bot - Revolt.chat bot template

revoltchat-bot Revolt.chat bot template made with Typescript Setup Guide Clone this repository git clone https://github.com/debert-jamie/revoltchat-bo

Debert Jamie 3 Jan 2, 2023
Zoltan is a polyphonic music synthesizer that you can play in your browser.

Zoltan Zoltan is a polyphonic browser-based synthesizer written in TypeScript using React. The project is currently in the early alpha stages, so expe

Mark-James McDougall 7 Dec 17, 2022
A web app for seeing your recent Twitch chat mentions and/or other tracked words amongst channels you follow.

Mentions A web app for seeing your recent Twitch chat mentions and/or other tracked words amongst channels you follow. Requirements NodeJS. Client ID

Ravenbtw 3 Dec 22, 2022
Discord bot made in javascript to play youtube music.

DJS O DJS รฉ um bot para Discord com a capacidade da criar playlists personalizadas, tendo como fonte a biblioteca de mรบsicas do Youtube. Frameworks e

Matheus Luiz 2 Aug 21, 2022