Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@discordjs/voice

Package Overview
Dependencies
Maintainers
3
Versions
1229
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@discordjs/voice - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

dist/audio/AudioPlayerError.d.ts

2

dist/audio/AudioPlayer.d.ts

@@ -148,3 +148,3 @@ /// <reference types="node" />

*/
play(resource: AudioResource): void;
play<T>(resource: AudioResource<T>): void;
/**

@@ -151,0 +151,0 @@ * Pauses playback of the current resource, if any.

@@ -8,2 +8,3 @@ "use strict";

const VoiceConnection_1 = require("../VoiceConnection");
const AudioPlayerError_1 = require("./AudioPlayerError");
const PlayerSubscription_1 = require("./PlayerSubscription");

@@ -203,5 +204,4 @@ // The Opus "silent" frame

play(resource) {
var _a, _b;
if (resource.playStream.readableEnded || resource.playStream.destroyed) {
throw new Error(`Cannot play a resource (${(_a = resource.name) !== null && _a !== void 0 ? _a : 'unnamed'}) that has already ended.`);
throw new Error('Cannot play a resource that has already ended.');
}

@@ -212,3 +212,3 @@ if (resource.audioPlayer) {

}
throw new Error(`Resource (${(_b = resource.name) !== null && _b !== void 0 ? _b : 'unnamed'}) is already being played by another audio player.`);
throw new Error('Resource is already being played by another audio player.');
}

@@ -224,5 +224,5 @@ resource.audioPlayer = this;

* @event AudioPlayer#error
* @type {Error}
* @type {AudioPlayerError}
*/
this.emit('error', error);
this.emit('error', new AudioPlayerError_1.AudioPlayerError(error, this.state.resource));
}

@@ -229,0 +229,0 @@ if (this.state.status !== AudioPlayerStatus.Idle && this.state.resource === resource) {

@@ -9,3 +9,3 @@ /// <reference types="node" />

*/
interface CreateAudioResourceOptions {
interface CreateAudioResourceOptions<T> {
/**

@@ -16,6 +16,7 @@ * The type of the input stream. Defaults to `StreamType.Arbitrary`.

/**
* An optional name that can be attached to the resource. This could be a track title, song name etc.
* Optional metadata that can be attached to the resource (e.g. track title, random ID).
* This is useful for identification purposes when the resource is passed around in events.
* See {@link AudioResource.metadata}
*/
name?: string;
metadata?: T;
/**

@@ -30,3 +31,3 @@ * Whether or not inline volume should be enabled. If enabled, you will be able to change the volume

*/
export declare class AudioResource {
export declare class AudioResource<T = unknown> {
/**

@@ -43,5 +44,5 @@ * An object-mode Readable stream that emits Opus packets. This is what is played by audio players.

/**
* An optional name that can be used to identify the resource.
* Optional metadata that can be used to identify the resource.
*/
name?: string;
metadata?: T;
/**

@@ -56,3 +57,3 @@ * If the resource was created with inline volume transformation enabled, then this will be a

audioPlayer?: AudioPlayer;
constructor(pipeline: Edge[], playStream: Readable, name?: string, volume?: VolumeTransformer);
constructor(pipeline: Edge[], playStream: Readable, metadata?: T, volume?: VolumeTransformer);
}

@@ -72,4 +73,4 @@ /**

*/
export declare function createAudioResource(input: string | Readable, options?: CreateAudioResourceOptions): AudioResource;
export declare function createAudioResource<T>(input: string | Readable, options?: CreateAudioResourceOptions<T>): AudioResource<T>;
export {};
//# sourceMappingURL=AudioResource.d.ts.map

@@ -12,6 +12,6 @@ "use strict";

class AudioResource {
constructor(pipeline, playStream, name, volume) {
constructor(pipeline, playStream, metadata, volume) {
this.pipeline = pipeline;
this.playStream = playStream;
this.name = name;
this.metadata = metadata;
this.volume = volume;

@@ -52,6 +52,3 @@ }

// No adjustments required
return {
playStream: input,
pipeline: [],
};
return new AudioResource([], input, options.metadata);
}

@@ -65,10 +62,5 @@ const streams = transformerPipeline.map((pipe) => pipe.transformer(input));

const volume = streams.find((stream) => stream instanceof prism_media_1.VolumeTransformer);
return {
playStream: playStream,
pipeline: transformerPipeline,
name: options.name,
volume,
};
return new AudioResource(transformerPipeline, playStream, options.metadata, volume);
}
exports.createAudioResource = createAudioResource;
//# sourceMappingURL=AudioResource.js.map

@@ -50,2 +50,4 @@ "use strict";

function audioCycleStep() {
if (nextTime === -1)
return;
nextTime += FRAME_LENGTH;

@@ -52,0 +54,0 @@ const available = audioPlayers.filter((player) => player.checkPlayable());

{
"name": "@discordjs/voice",
"version": "0.1.0",
"version": "0.1.1",
"description": "audio streaming capability for discord.js",

@@ -13,3 +13,4 @@ "main": "dist/index.js",

"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test": "jest",
"test:ci": "jest --verbose --ci --no-stack-trace",
"lint": "eslint src --ext .ts",

@@ -44,4 +45,8 @@ "lint:fix": "eslint src --ext .ts --fix",

"devDependencies": {
"@babel/core": "^7.13.8",
"@babel/preset-env": "^7.13.9",
"@babel/preset-typescript": "^7.13.0",
"@commitlint/cli": "^11.0.0",
"@commitlint/config-angular": "^11.0.0",
"@types/jest": "^26.0.20",
"@types/node": "^14.14.25",

@@ -51,2 +56,3 @@ "@types/ws": "^7.4.0",

"@typescript-eslint/parser": "^4.14.2",
"babel-jest": "^26.6.3",
"discord-api-types": "^0.12.1",

@@ -58,2 +64,3 @@ "eslint": "^7.20.0",

"husky": "^4.3.8",
"jest": "^26.6.3",
"lint-staged": "^10.5.4",

@@ -60,0 +67,0 @@ "prettier": "^2.2.1",

@@ -7,3 +7,4 @@ # @discordjs/voice

<a href="https://www.npmjs.com/package/@discordjs/voice"><img src="https://img.shields.io/npm/dt/@discordjs/voice.svg?maxAge=3600" alt="NPM downloads" /></a>
<a href="https://github.com/discordjs/voice/actions"><img src="https://github.com/discordjs/voice/workflows/Testing/badge.svg" alt="Build status" /></a>
<a href="https://github.com/discordjs/voice/actions"><img src="https://github.com/discordjs/voice/actions/workflows/test.yml/badge.svg" alt="Build status" /></a>
<a href="https://codecov.io/gh/discordjs/voice"><img src="https://codecov.io/gh/discordjs/voice/branch/main/graph/badge.svg?token=u7oQ23UoxX" alt="Test coverage"/></a>
<a href="https://www.patreon.com/discordjs"><img src="https://img.shields.io/badge/donate-patreon-F96854.svg" alt="Patreon" /></a>

@@ -10,0 +11,0 @@ </p>

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc