2025-12-16 16:02:07 +01:00
2025-04-06 16:42:31 +02:00
2025-07-07 12:18:29 +02:00
2025-12-16 12:02:18 +01:00
2025-12-16 16:02:07 +01:00
2025-12-16 16:02:07 +01:00

Discord Audio Stream

npm GitHub package.json version GitHub Repo stars

This module is designed to work with discord.js/voice v0.19. This package doesn't support older versions!

Designed for 24/7 audio playing on discord.
Discord has many unwanted rate limits, especially in the audio area. This package does all the work and ensures that your music never stops playing due to ffmpeg or Discord, with as little effort as possible.

Recommended best Practise:
Create a global Map<GuildId, AudioManager> (Map<KEY, OBJ>) list. When the feature is used on a guild, add a new instance of AudioManager to the Map. When starting the connection or audio, overwrite the respective configuration with the override methods provided. To finally start, use the respective method. For each call and each change, retrieve the AudioManager object from the list and perform your actions. When the feature get stopped, first execute StopConnection and then Dispose to save as much power as possible. Garbage collection does the rest.
For large systems: For large systems, it is recommended to queue each start with the packet p-queue, to give ffmpeg enough time..

👋 Support

Please create an issue on github or write fraujulian on discord!

📝 Usage

Installation

Node.js 22.12.0 or newer is required.

npm install discord-audio-stream
yarn add discord-audio-stream
pnpm add discord-audio-stream
bun add discord-audio-stream

Required Dependencies

  • You only need to install libsodium-wrappers if your system does not support aes-256-gcm (verify by running require('node:crypto').getCiphers().includes('aes-256-gcm')).

  • @snazzah/davey
  • opusscript
  • prism-media
  • FFmpeg (one of those)
    • FFmpeg (installed and added to environment)
    • ffmpeg-static

AudioManager Instance

Options

Declaration:

AudioManager(ffmpegMode: string, renewInMs, number, connectionData: VoiceConnectionDataModel, audioData: VoiceAudioDataModel): IDisposable, IAudioManager
  • ffmpegMode: 'Native' or 'Standalone'
    • Native: FFmpeg installed on your system
    • Standalone: FFmpeg-static as NodeJs library
  • renewInMs: renewal time > default is 1,5h (5400000ms)
  • connectionData: Options for voice connection. (type of VoiceConnectionDataModel)
  • audioData: Options for audio player. (type of VoiceAudioDataModel)

Example

let audioManager = new AudioManager(
    'Native',
    5400000,
    {
        VoiceChannelId: 0, //voice channel id where to play music
        GuildId: 0, //guild id
        VoiceAdapter: 0, //guild VoiceAdapter
    },
    {
        ResourceType: '', //resource type like link or file
        Resource: '', //auto play link or file name
    },
);

Fields and Methods of AudioManager

Fields

Name Type Security Description
Active bool protected To check if the connection is active.
Playing bool protected To check if it is playing audio.

Methods

Name Parameters Return type Description
OverrideVoiceConnectionData connectionData (type of VoiceConnectionDataModel) void To override intern connectionData field.
OverrideVoiceAudioDataModel audioData (type of VoiceAudioDataModel) void To override intern audioData field.
CreateAndPlay Promise Join channel and start playing audio.
CreateConnection void Let it connect to voice channel.
PlayAudio Promise To start playing audio.
PauseAudio void Pause the audio, if it is playing
ResumeAudio void Resume the audio, if it is paused.
SetVolume volume (type of number, 0 - 100 percent) void To set the audio volume.
StopConnection Promise Method to disconnect the voice channel.
Dispose void Dispose all data in object.

📝 Types

📋 Contributors:

~ FrauJulian - Julian Lechner - CODEOWNER

🤝 Enjoy the package?

Give it a star on github!

S
Description
🖼️ NodeJs library for discord to make 24/7 audio streaming easier.
https://www.npmjs.com/package/discord-audio-stream Readme AGPL-3.0
5.3 MiB
Languages
TypeScript 86.9%
JavaScript 13%