Comparing version 1.0.0 to 1.0.1
@@ -41,3 +41,3 @@ "use strict"; | ||
else { | ||
const connection = yield VoiceConnection_1.default.createConnection(vc); | ||
const connection = yield VoiceConnection_1.default.createConnection(vc, this); | ||
this.connections.set(vc.guildId, connection); | ||
@@ -44,0 +44,0 @@ return connection; |
@@ -35,2 +35,3 @@ "use strict"; | ||
catch (_b) { | ||
this.connection.manager.connections.delete(this.connection.channel.guildId); | ||
this.connection.emit("disconnect"); | ||
@@ -45,2 +46,3 @@ this.connection.voice.destroy(); | ||
else { | ||
this.connection.manager.connections.delete(this.connection.channel.guildId); | ||
this.connection.emit("disconnect"); | ||
@@ -61,2 +63,3 @@ this.connection.voice.destroy(); | ||
this.connection.voice.destroy(); | ||
this.connection.manager.connections.delete(this.connection.channel.guildId); | ||
this.connection.emit("disconnect"); | ||
@@ -80,6 +83,7 @@ } | ||
} | ||
playStream(stream) { | ||
playStream(stream, options) { | ||
var _a; | ||
this.audioResource = voice_1.createAudioResource(stream, { | ||
inputType: voice_1.StreamType.Arbitrary, | ||
inlineVolume: true | ||
inputType: (options === null || options === void 0 ? void 0 : options.type) || voice_1.StreamType.Arbitrary, | ||
inlineVolume: (_a = options === null || options === void 0 ? void 0 : options.inlineVolume) !== null && _a !== void 0 ? _a : true | ||
}); | ||
@@ -86,0 +90,0 @@ this.audioPlayer.play(this.audioResource); |
@@ -28,2 +28,3 @@ "use strict"; | ||
this.dispatcher = null; | ||
this.manager = this.options.manager; | ||
this.voice.on("debug", (m) => void this.emit("debug", m)); | ||
@@ -33,5 +34,6 @@ this.voice.on("error", (err) => void this.emit("error", err)); | ||
disconnect() { | ||
this.manager.connections.delete(this.channel.guildId); | ||
this.voice.destroy(); | ||
} | ||
static createConnection(channel) { | ||
static createConnection(channel, manager) { | ||
// eslint-disable-next-line no-async-promise-executor | ||
@@ -43,3 +45,4 @@ return new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () { | ||
const vc = new VoiceConnection(connection, { | ||
channel | ||
channel, | ||
manager | ||
}); | ||
@@ -65,3 +68,3 @@ resolve(vc); | ||
} | ||
play(stream) { | ||
play(stream, options) { | ||
if (!this.dispatcher) { | ||
@@ -71,3 +74,3 @@ const dispatcher = new StreamDispatcher_1.default(this); | ||
} | ||
this.dispatcher.playStream(stream); | ||
this.dispatcher.playStream(stream, options); | ||
return this.dispatcher; | ||
@@ -74,0 +77,0 @@ } |
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import * as _discordjs_voice from '@discordjs/voice'; | ||
import { AudioResource, VoiceConnection as VoiceConnection$1, VoiceConnectionStatus } from '@discordjs/voice'; | ||
import { StreamType, AudioResource, VoiceConnection as VoiceConnection$1, VoiceConnectionStatus } from '@discordjs/voice'; | ||
import { TypedEmitter } from 'tiny-typed-emitter'; | ||
@@ -25,3 +25,8 @@ import { Readable } from 'stream'; | ||
channel: VoiceChannels; | ||
manager: DartVoiceManager; | ||
} | ||
interface PlayOptions { | ||
type?: `${StreamType}`; | ||
inlineVolume?: boolean; | ||
} | ||
@@ -35,3 +40,3 @@ declare class StreamDispatcher extends TypedEmitter<DispatcherEvents> { | ||
private attachEvents; | ||
playStream(stream: Readable | string): void; | ||
playStream(stream: Readable | string, options?: PlayOptions): void; | ||
setVolume(amount: number): boolean; | ||
@@ -57,7 +62,8 @@ setVolumeLogarithmic(amount: number): boolean; | ||
dispatcher: StreamDispatcher; | ||
readonly manager: DartVoiceManager; | ||
constructor(voice: VoiceConnection$1, options: VoiceConnectionData); | ||
disconnect(): void; | ||
static createConnection(channel: VoiceChannels): Promise<VoiceConnection>; | ||
static createConnection(channel: VoiceChannels, manager: DartVoiceManager): Promise<VoiceConnection>; | ||
static joinChannel(channel: VoiceChannels): Promise<VoiceConnection$1>; | ||
play(stream: Readable | string): StreamDispatcher; | ||
play(stream: Readable | string, options?: PlayOptions): StreamDispatcher; | ||
get status(): VoiceConnectionStatus; | ||
@@ -78,2 +84,2 @@ } | ||
export { DartVoiceManager, DispatcherEvents, StreamDispatcher, VoiceChannels, VoiceConnection, VoiceConnectionData, VoiceEvents, catchError, noop, wait }; | ||
export { DartVoiceManager, DispatcherEvents, PlayOptions, StreamDispatcher, VoiceChannels, VoiceConnection, VoiceConnectionData, VoiceEvents, catchError, noop, wait }; |
@@ -0,0 +0,0 @@ "use strict"; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
@@ -0,0 +0,0 @@ "use strict"; |
{ | ||
"name": "dartjs", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Very simple framework that provides discord.js v12 voice interface", | ||
@@ -55,3 +55,4 @@ "main": "dist/index.js", | ||
"tweetnacl": "^1.0.3", | ||
"typescript": "^4.3.5" | ||
"typescript": "^4.3.5", | ||
"ytdl-core": "^4.9.1" | ||
}, | ||
@@ -58,0 +59,0 @@ "dependencies": { |
@@ -0,0 +0,0 @@ # DartJS |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
23748
410
15