Skip to content

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

License

Notifications You must be signed in to change notification settings

ShadowLp174/revoice.js

Repository files navigation

Revoice.js - A Voice Module for Stoat (Revolt)

A Node.js package allowing bots (or selfbots) to connect to voice channels on the Discord-alternative Stoat, formerly Revolt.

Features:

  • Audio Playback
  • Pausing/Resuming Playback
  • Adjusting volume
  • User Events (joining/leaving)

This package is still in development. If you need a certain feature currently not implemented, please open an issue and let me know about it. I will see what I can do :)

Livekit Update

Stoat, formerly Revolt, has updated to a new voice system called Livekit. Revoice.js has been updated to support this and is a lot more stable now.
The rewrite was made with backwards-compatibility in mind so any programs using Revoice written before the switch should still work after updating to the newest Revoice version. However, minor issues may arise (such as media.playbackPaused being removed in favour of media.paused).
To connect to Stoat instances still using Vortex, the old Revoice and MediaPlayer are still accessible by importing them through require("revoice.js").legacy.

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, Stoat 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:

If you want to see a working music bot using revoice, check out Remix!

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();
});

TODO:

  • Play/Pause for the media class
  • Non-voice events like UserJoined and roominfo
  • Audio Level Normalisation
  • 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 :)

Connect to self-hosted instances

You can pass the configuration data for revolt-api and thus connect it to a self-hosted instance. For the data you can pass, see oapi

Documentation

For the documentation, please have a look at the pages deployment: https://shadowlp174.github.io/revoice.js/docs

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •