discord-player
Advanced tools
Comparing version 5.0.0-dev.6db3cdb7b2bc9b69a807e7ca37b90e6c259bae3f to 5.0.0-dev.8ce04b3.1625486509
@@ -7,8 +7,7 @@ export { AudioFilters } from "./utils/AudioFilters"; | ||
export { Queue } from "./Structures/Queue"; | ||
export { StreamUtils } from "./utils/StreamUtils"; | ||
export { Track } from "./Structures/Track"; | ||
export { Util } from "./utils/Util"; | ||
export { VoiceUtils } from "./VoiceInterface/VoiceUtils"; | ||
export { VoiceEvents, StreamDispatcher } from "./VoiceInterface/BasicStreamDispatcher"; | ||
export { VoiceEvents, StreamDispatcher } from "./VoiceInterface/StreamDispatcher"; | ||
export { VoiceAdapterCreator } from "./VoiceInterface/AdapterCreator"; | ||
export * from "./types/types"; |
@@ -13,3 +13,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.VoiceAdapterCreator = exports.StreamDispatcher = exports.VoiceUtils = exports.Util = exports.Track = exports.StreamUtils = exports.Queue = exports.QueryResolver = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0; | ||
exports.VoiceAdapterCreator = exports.StreamDispatcher = exports.VoiceUtils = exports.Util = exports.Track = exports.Queue = exports.QueryResolver = exports.Player = exports.Playlist = exports.ExtractorModel = exports.AudioFilters = void 0; | ||
var AudioFilters_1 = require("./utils/AudioFilters"); | ||
@@ -27,4 +27,2 @@ Object.defineProperty(exports, "AudioFilters", { enumerable: true, get: function () { return AudioFilters_1.AudioFilters; } }); | ||
Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return Queue_1.Queue; } }); | ||
var StreamUtils_1 = require("./utils/StreamUtils"); | ||
Object.defineProperty(exports, "StreamUtils", { enumerable: true, get: function () { return StreamUtils_1.StreamUtils; } }); | ||
var Track_1 = require("./Structures/Track"); | ||
@@ -36,6 +34,6 @@ Object.defineProperty(exports, "Track", { enumerable: true, get: function () { return Track_1.Track; } }); | ||
Object.defineProperty(exports, "VoiceUtils", { enumerable: true, get: function () { return VoiceUtils_1.VoiceUtils; } }); | ||
var BasicStreamDispatcher_1 = require("./VoiceInterface/BasicStreamDispatcher"); | ||
Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return BasicStreamDispatcher_1.StreamDispatcher; } }); | ||
var StreamDispatcher_1 = require("./VoiceInterface/StreamDispatcher"); | ||
Object.defineProperty(exports, "StreamDispatcher", { enumerable: true, get: function () { return StreamDispatcher_1.StreamDispatcher; } }); | ||
var AdapterCreator_1 = require("./VoiceInterface/AdapterCreator"); | ||
Object.defineProperty(exports, "VoiceAdapterCreator", { enumerable: true, get: function () { return AdapterCreator_1.VoiceAdapterCreator; } }); | ||
__exportStar(require("./types/types"), exports); |
@@ -5,3 +5,3 @@ import { Client, Collection, GuildResolvable } from "discord.js"; | ||
import { VoiceUtils } from "./VoiceInterface/VoiceUtils"; | ||
import { PlayerEvents, PlayerOptions, SearchOptions, DiscordPlayerInitOptions } from "./types/types"; | ||
import { PlayerEvents, PlayerOptions, SearchOptions, PlayerInitOptions } from "./types/types"; | ||
import Track from "./Structures/Track"; | ||
@@ -12,3 +12,3 @@ import { Playlist } from "./Structures/Playlist"; | ||
readonly client: Client; | ||
readonly options: DiscordPlayerInitOptions; | ||
readonly options: PlayerInitOptions; | ||
readonly queues: Collection<`${bigint}`, Queue<unknown>>; | ||
@@ -20,5 +20,5 @@ readonly voiceUtils: VoiceUtils; | ||
* @param {Client} client The Discord Client | ||
* @param {DiscordPlayerInitOptions} [options={}] The player init options | ||
* @param {PlayerInitOptions} [options={}] The player init options | ||
*/ | ||
constructor(client: Client, options?: DiscordPlayerInitOptions); | ||
constructor(client: Client, options?: PlayerInitOptions); | ||
/** | ||
@@ -87,4 +87,10 @@ * Handles voice state update | ||
scanDeps(): string; | ||
/** | ||
* Resolves qeuue | ||
* @param {GuildResolvable|Queue} queueLike Queue like object | ||
* @returns {Queue} | ||
*/ | ||
resolveQueue<T>(queueLike: GuildResolvable | Queue): Queue<T>; | ||
[Symbol.iterator](): Generator<Queue<unknown>, void, undefined>; | ||
} | ||
export { Player }; |
@@ -37,3 +37,3 @@ "use strict"; | ||
* @param {Client} client The Discord Client | ||
* @param {DiscordPlayerInitOptions} [options={}] The player init options | ||
* @param {PlayerInitOptions} [options={}] The player init options | ||
*/ | ||
@@ -79,7 +79,6 @@ constructor(client, options = {}) { | ||
return; | ||
// update channel | ||
if (oldState.channelID && newState.channelID && oldState.channelID !== newState.channelID) { | ||
if (oldState.channelId && newState.channelId && oldState.channelId !== newState.channelId) { | ||
queue.connection.channel = newState.channel; | ||
} | ||
if (!oldState.channelID && newState.channelID && newState.member.id === newState.guild.me.id) { | ||
if (!oldState.channelId && newState.channelId && newState.member.id === newState.guild.me.id) { | ||
if (newState.serverMute || !newState.serverMute) { | ||
@@ -94,3 +93,3 @@ queue.setPaused(newState.serverMute); | ||
} | ||
if (oldState.channelID === newState.channelID && oldState.member.id === newState.guild.me.id) { | ||
if (oldState.channelId === newState.channelId && oldState.member.id === newState.guild.me.id) { | ||
if (oldState.serverMute !== newState.serverMute) { | ||
@@ -105,3 +104,3 @@ queue.setPaused(newState.serverMute); | ||
} | ||
if (oldState.member.id === this.client.user.id && !newState.channelID) { | ||
if (oldState.member.id === this.client.user.id && !newState.channelId) { | ||
queue.destroy(); | ||
@@ -112,3 +111,3 @@ return void this.emit("botDisconnect", queue); | ||
return; | ||
if (!oldState.channelID || newState.channelID) { | ||
if (!oldState.channelId || newState.channelId) { | ||
const emptyTimeout = queue._cooldownsTimeout.get(`empty_${oldState.guild.id}`); | ||
@@ -399,3 +398,2 @@ const channelEmpty = Util_1.Util.isVoiceEmpty(queue.connection.channel); | ||
return { playlist: null, tracks: [] }; | ||
// @todo: better way of handling large playlists | ||
yield ytpl.fetch().catch(Util_1.Util.noop); | ||
@@ -484,2 +482,10 @@ const playlist = new Playlist_1.Playlist(this, { | ||
} | ||
/** | ||
* Resolves qeuue | ||
* @param {GuildResolvable|Queue} queueLike Queue like object | ||
* @returns {Queue} | ||
*/ | ||
resolveQueue(queueLike) { | ||
return this.getQueue(queueLike instanceof Queue_1.Queue ? queueLike.guild : queueLike); | ||
} | ||
*[Symbol.iterator]() { | ||
@@ -486,0 +492,0 @@ yield* Array.from(this.queues.values()); |
/// <reference types="node" /> | ||
import { Collection, Guild, StageChannel, VoiceChannel } from "discord.js"; | ||
import { Collection, Guild, Snowflake, GuildChannelResolvable } from "discord.js"; | ||
import { Player } from "../Player"; | ||
import { StreamDispatcher } from "../VoiceInterface/BasicStreamDispatcher"; | ||
import { StreamDispatcher } from "../VoiceInterface/StreamDispatcher"; | ||
import Track from "./Track"; | ||
@@ -18,2 +18,3 @@ import { PlayerOptions, PlayerProgressbarOptions, PlayOptions, QueueFilters, QueueRepeatMode } from "../types/types"; | ||
repeatMode: QueueRepeatMode; | ||
readonly id: Snowflake; | ||
private _streamTime; | ||
@@ -47,6 +48,6 @@ _cooldownsTimeout: Collection<string, NodeJS.Timeout>; | ||
* Connects to a voice channel | ||
* @param {StageChannel|VoiceChannel} channel The voice/stage channel | ||
* @param {GuildChannelResolvable} channel The voice/stage channel | ||
* @returns {Promise<Queue>} | ||
*/ | ||
connect(channel: StageChannel | VoiceChannel): Promise<this>; | ||
connect(channel: GuildChannelResolvable): Promise<this>; | ||
/** | ||
@@ -105,2 +106,12 @@ * Destroys this queue | ||
/** | ||
* Mutes the playback | ||
* @returns {void} | ||
*/ | ||
mute(): void; | ||
/** | ||
* Unmutes the playback. If the last volume was set to 0, unmute will produce no effect. | ||
* @returns {void} | ||
*/ | ||
unmute(): void; | ||
/** | ||
* The stream time of this queue | ||
@@ -154,6 +165,6 @@ * @type {number} | ||
* Removes a track from the queue | ||
* @param {Track|number} track The track to remove | ||
* @param {Track|Snowflake|number} track The track to remove | ||
* @returns {Track} | ||
*/ | ||
remove(track: Track | number): Track; | ||
remove(track: Track | Snowflake | number): Track; | ||
/** | ||
@@ -166,2 +177,8 @@ * Jumps to particular track | ||
/** | ||
* Inserts the given track to specified index | ||
* @param {Track} track The track to insert | ||
* @param {number} [index=0] The index where this track should be | ||
*/ | ||
insert(track: Track, index?: number): void; | ||
/** | ||
* @typedef {object} PlayerTimestamp | ||
@@ -174,6 +191,5 @@ * @property {string} current The current progress | ||
* Returns player stream timestamp | ||
* @param {boolean} [queue=false] If it should generate timestamp for the queue | ||
* @returns {PlayerTimestamp} | ||
*/ | ||
getPlayerTimestamp(queue?: boolean): { | ||
getPlayerTimestamp(): { | ||
current: string; | ||
@@ -205,2 +221,3 @@ end: string; | ||
* @returns {Promise<void>} | ||
* @private | ||
*/ | ||
@@ -214,2 +231,3 @@ private _handleAutoplay; | ||
toJSON(): { | ||
id: `${bigint}`; | ||
guild: `${bigint}`; | ||
@@ -216,0 +234,0 @@ voiceChannel: `${bigint}`; |
@@ -25,3 +25,3 @@ "use strict"; | ||
}; | ||
var _Queue_instances, _Queue_destroyed, _Queue_watchDestroyed; | ||
var _Queue_instances, _Queue_lastVolume, _Queue_destroyed, _Queue_watchDestroyed; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -51,2 +51,3 @@ exports.Queue = void 0; | ||
this.repeatMode = 0; | ||
this.id = discord_js_1.SnowflakeUtil.generate(); | ||
this._streamTime = 0; | ||
@@ -56,2 +57,3 @@ this._cooldownsTimeout = new discord_js_1.Collection(); | ||
this._filtersUpdate = false; | ||
_Queue_lastVolume.set(this, 0); | ||
_Queue_destroyed.set(this, false); | ||
@@ -100,2 +102,7 @@ /** | ||
*/ | ||
/** | ||
* The ID of this queue | ||
* @type {Snowflake} | ||
* @name Queue#id | ||
*/ | ||
Object.assign(this.options, { | ||
@@ -137,3 +144,3 @@ leaveOnEnd: true, | ||
* Connects to a voice channel | ||
* @param {StageChannel|VoiceChannel} channel The voice/stage channel | ||
* @param {GuildChannelResolvable} channel The voice/stage channel | ||
* @returns {Promise<Queue>} | ||
@@ -144,11 +151,12 @@ */ | ||
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this); | ||
if (!["stage", "voice"].includes(channel === null || channel === void 0 ? void 0 : channel.type)) | ||
throw new TypeError(`Channel type must be voice or stage, got ${channel === null || channel === void 0 ? void 0 : channel.type}!`); | ||
const connection = yield this.player.voiceUtils.connect(channel, { | ||
const _channel = this.guild.channels.resolve(channel); | ||
if (!["stage", "voice"].includes(_channel === null || _channel === void 0 ? void 0 : _channel.type)) | ||
throw new TypeError(`Channel type must be voice or stage, got ${_channel === null || _channel === void 0 ? void 0 : _channel.type}!`); | ||
const connection = yield this.player.voiceUtils.connect(_channel, { | ||
deaf: this.options.autoSelfDeaf | ||
}); | ||
this.connection = connection; | ||
if (channel.type === "stage") { | ||
yield channel.guild.me.voice.setSuppressed(false).catch(() => __awaiter(this, void 0, void 0, function* () { | ||
return yield channel.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop); | ||
if (_channel.type === "stage") { | ||
yield _channel.guild.me.voice.setSuppressed(false).catch(() => __awaiter(this, void 0, void 0, function* () { | ||
return yield _channel.guild.me.voice.setRequestToSpeak(true).catch(Util_1.Util.noop); | ||
})); | ||
@@ -202,6 +210,8 @@ } | ||
destroy(disconnect = this.options.leaveOnStop) { | ||
var _a; | ||
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this); | ||
this.connection.end(); | ||
if (this.connection) | ||
this.connection.end(); | ||
if (disconnect) | ||
this.connection.disconnect(); | ||
(_a = this.connection) === null || _a === void 0 ? void 0 : _a.disconnect(); | ||
this.player.queues.delete(this.guild.id); | ||
@@ -280,2 +290,3 @@ this.player.voiceUtils.cache.delete(this.guild.id); | ||
return false; | ||
__classPrivateFieldSet(this, _Queue_lastVolume, amount, "f"); | ||
this.options.initialVolume = amount; | ||
@@ -312,2 +323,18 @@ return this.connection.setVolume(amount); | ||
/** | ||
* Mutes the playback | ||
* @returns {void} | ||
*/ | ||
mute() { | ||
const lv = __classPrivateFieldGet(this, _Queue_lastVolume, "f"); | ||
this.volume = 0; | ||
__classPrivateFieldSet(this, _Queue_lastVolume, lv, "f"); | ||
} | ||
/** | ||
* Unmutes the playback. If the last volume was set to 0, unmute will produce no effect. | ||
* @returns {void} | ||
*/ | ||
unmute() { | ||
this.volume = __classPrivateFieldGet(this, _Queue_lastVolume, "f"); | ||
} | ||
/** | ||
* The stream time of this queue | ||
@@ -453,3 +480,3 @@ * @type {number} | ||
* Removes a track from the queue | ||
* @param {Track|number} track The track to remove | ||
* @param {Track|Snowflake|number} track The track to remove | ||
* @returns {Track} | ||
@@ -463,9 +490,9 @@ */ | ||
if (trackFound) { | ||
this.tracks = this.tracks.filter((t) => t._trackID !== trackFound._trackID); | ||
this.tracks = this.tracks.filter((t) => t.id !== trackFound.id); | ||
} | ||
} | ||
else { | ||
trackFound = this.tracks.find((s) => s._trackID === track._trackID); | ||
trackFound = this.tracks.find((s) => s.id === (track instanceof Track_1.default ? track.id : track)); | ||
if (trackFound) { | ||
this.tracks = this.tracks.filter((s) => s._trackID !== trackFound._trackID); | ||
this.tracks = this.tracks.filter((s) => s.id !== trackFound.id); | ||
} | ||
@@ -489,2 +516,15 @@ } | ||
/** | ||
* Inserts the given track to specified index | ||
* @param {Track} track The track to insert | ||
* @param {number} [index=0] The index where this track should be | ||
*/ | ||
insert(track, index = 0) { | ||
if (!track || !(track instanceof Track_1.default)) | ||
throw new TypeError("track must be the instance of Track"); | ||
if (typeof index !== "number" || index < 0 || !Number.isFinite(index)) | ||
throw new Error(`Invalid index "${index}"`); | ||
this.tracks.splice(index, 0, track); | ||
this.player.emit("trackAdd", this, track); | ||
} | ||
/** | ||
* @typedef {object} PlayerTimestamp | ||
@@ -497,11 +537,8 @@ * @property {string} current The current progress | ||
* Returns player stream timestamp | ||
* @param {boolean} [queue=false] If it should generate timestamp for the queue | ||
* @returns {PlayerTimestamp} | ||
*/ | ||
getPlayerTimestamp(queue = false) { | ||
getPlayerTimestamp() { | ||
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this); | ||
const previousTracksTime = this.previousTracks.length > 0 ? this.previousTracks.reduce((p, c) => p + c.durationMS, 0) : 0; | ||
const currentStreamTime = queue ? previousTracksTime + this.streamTime : this.streamTime; | ||
const totalTracksTime = this.totalTime; | ||
const totalTime = queue ? previousTracksTime + totalTracksTime : this.current.durationMS; | ||
const currentStreamTime = this.streamTime; | ||
const totalTime = this.current.durationMS; | ||
const currentTimecode = Util_1.Util.buildTimeCode(Util_1.Util.parseMS(currentStreamTime)); | ||
@@ -520,10 +557,6 @@ const endTimecode = Util_1.Util.buildTimeCode(Util_1.Util.parseMS(totalTime)); | ||
*/ | ||
createProgressBar(options = { timecodes: true, queue: false }) { | ||
createProgressBar(options = { timecodes: true }) { | ||
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this); | ||
const previousTracksTime = this.previousTracks.length > 0 ? this.previousTracks.reduce((p, c) => p + c.durationMS, 0) : 0; | ||
const currentStreamTime = options.queue ? previousTracksTime + this.streamTime : this.streamTime; | ||
const totalTracksTime = this.totalTime; | ||
const totalTime = options.queue ? previousTracksTime + totalTracksTime : this.current.durationMS; | ||
const length = typeof options.length === "number" ? (options.length <= 0 || options.length === Infinity ? 15 : options.length) : 15; | ||
const index = Math.round((currentStreamTime / totalTime) * length); | ||
const index = Math.round((this.streamTime / this.current.durationMS) * length); | ||
const indicator = typeof options.indicator === "string" && options.indicator.length > 0 ? options.indicator : "🔘"; | ||
@@ -535,3 +568,3 @@ const line = typeof options.line === "string" && options.line.length > 0 ? options.line : "▬"; | ||
if (options.timecodes) { | ||
const timestamp = this.getPlayerTimestamp(options.queue); | ||
const timestamp = this.getPlayerTimestamp(); | ||
return `${timestamp.current} ┃ ${bar.join("")} ┃ ${timestamp.end}`; | ||
@@ -545,3 +578,3 @@ } | ||
if (options.timecodes) { | ||
const timestamp = this.getPlayerTimestamp(options.queue); | ||
const timestamp = this.getPlayerTimestamp(); | ||
return `${timestamp.current} ┃ ${indicator}${line.repeat(length - 1)} ┃ ${timestamp.end}`; | ||
@@ -571,3 +604,4 @@ } | ||
return __awaiter(this, void 0, void 0, function* () { | ||
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this); | ||
if (!this.destroyed) | ||
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this); | ||
if (!this.connection || !this.connection.voiceConnection) | ||
@@ -580,4 +614,5 @@ throw new Error("Voice connection is not available, use <Queue>.connect()!"); | ||
return; | ||
this.player.emit("debug", this, "Received play request"); | ||
if (!options.filtersUpdate) { | ||
this.previousTracks = this.previousTracks.filter((x) => x._trackID !== track._trackID); | ||
this.previousTracks = this.previousTracks.filter((x) => x.id !== track.id); | ||
this.previousTracks.push(track); | ||
@@ -621,3 +656,3 @@ } | ||
this.connection.playStream(resource).then(() => { | ||
this.connection.setVolume(this.options.initialVolume); | ||
this.setVolume(this.options.initialVolume); | ||
}); | ||
@@ -630,2 +665,3 @@ }); | ||
* @returns {Promise<void>} | ||
* @private | ||
*/ | ||
@@ -663,3 +699,3 @@ _handleAutoplay(track) { | ||
} | ||
*[(_Queue_destroyed = new WeakMap(), _Queue_instances = new WeakSet(), Symbol.iterator)]() { | ||
*[(_Queue_lastVolume = new WeakMap(), _Queue_destroyed = new WeakMap(), _Queue_instances = new WeakSet(), Symbol.iterator)]() { | ||
__classPrivateFieldGet(this, _Queue_instances, "m", _Queue_watchDestroyed).call(this); | ||
@@ -676,2 +712,3 @@ yield* this.tracks; | ||
return { | ||
id: this.id, | ||
guild: this.guild.id, | ||
@@ -678,0 +715,0 @@ voiceChannel: (_b = (_a = this.connection) === null || _a === void 0 ? void 0 : _a.channel) === null || _b === void 0 ? void 0 : _b.id, |
@@ -1,2 +0,2 @@ | ||
import { User } from "discord.js"; | ||
import { User, Snowflake } from "discord.js"; | ||
import { Player } from "../Player"; | ||
@@ -18,3 +18,3 @@ import { RawTrackData, TrackJSON } from "../types/types"; | ||
readonly raw: RawTrackData; | ||
readonly _trackID: number; | ||
readonly id: Snowflake; | ||
/** | ||
@@ -21,0 +21,0 @@ * Track constructor |
@@ -13,3 +13,3 @@ "use strict"; | ||
this.raw = {}; | ||
this._trackID = Date.now(); | ||
this.id = discord_js_1.SnowflakeUtil.generate(); | ||
/** | ||
@@ -74,4 +74,4 @@ * The player that instantiated this Track | ||
* The track id | ||
* @name Track#_trackID | ||
* @type {number} | ||
* @name Track#id | ||
* @type {Snowflake} | ||
* @readonly | ||
@@ -140,2 +140,3 @@ */ | ||
return { | ||
id: this.id, | ||
title: this.title, | ||
@@ -142,0 +143,0 @@ description: this.description, |
@@ -7,3 +7,3 @@ /// <reference types="node" /> | ||
import { Playlist } from "../Structures/Playlist"; | ||
import { StreamDispatcher } from "../VoiceInterface/BasicStreamDispatcher"; | ||
import { StreamDispatcher } from "../VoiceInterface/StreamDispatcher"; | ||
import { downloadOptions } from "ytdl-core"; | ||
@@ -112,3 +112,2 @@ export declare type FiltersName = keyof QueueFilters; | ||
timecodes?: boolean; | ||
queue?: boolean; | ||
length?: number; | ||
@@ -383,2 +382,3 @@ line?: string; | ||
export interface TrackJSON { | ||
id: Snowflake; | ||
title: string; | ||
@@ -424,9 +424,9 @@ description: string; | ||
/** | ||
* @typedef {object} DiscordPlayerInitOptions | ||
* @typedef {object} PlayerInitOptions | ||
* @property {boolean} [autoRegisterExtractor=true] If it should automatically register `@discord-player/extractor` | ||
* @property {YTDLDownloadOptions} [ytdlOptions={}] The options passed to `ytdl-core` | ||
*/ | ||
export interface DiscordPlayerInitOptions { | ||
export interface PlayerInitOptions { | ||
autoRegisterExtractor?: boolean; | ||
ytdlOptions?: downloadOptions; | ||
} |
@@ -88,3 +88,3 @@ "use strict"; | ||
static wait(time) { | ||
return new Promise((r) => setTimeout(r, time).unref()); | ||
return new Promise((r) => setTimeout(r, time)); | ||
} | ||
@@ -91,0 +91,0 @@ static get noop() { |
import { VoiceChannel, StageChannel, Collection, Snowflake } from "discord.js"; | ||
import { DiscordGatewayAdapterCreator, VoiceConnection } from "@discordjs/voice"; | ||
import { StreamDispatcher } from "./BasicStreamDispatcher"; | ||
import { StreamDispatcher } from "./StreamDispatcher"; | ||
declare class VoiceUtils { | ||
@@ -5,0 +5,0 @@ cache: Collection<Snowflake, StreamDispatcher>; |
@@ -15,3 +15,4 @@ "use strict"; | ||
const voice_1 = require("@discordjs/voice"); | ||
const BasicStreamDispatcher_1 = require("./BasicStreamDispatcher"); | ||
const StreamDispatcher_1 = require("./StreamDispatcher"); | ||
const AdapterCreator_1 = require("./AdapterCreator"); | ||
class VoiceUtils { | ||
@@ -38,3 +39,3 @@ /** | ||
const conn = yield this.join(channel, options); | ||
const sub = new BasicStreamDispatcher_1.StreamDispatcher(conn, channel); | ||
const sub = new StreamDispatcher_1.StreamDispatcher(conn, channel); | ||
this.cache.set(channel.guild.id, sub); | ||
@@ -51,3 +52,3 @@ return sub; | ||
join(channel, options) { | ||
var _a, _b; | ||
var _a, _b, _c; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -57,7 +58,7 @@ let conn = voice_1.joinVoiceChannel({ | ||
channelId: channel.id, | ||
adapterCreator: (_a = options.adapter) !== null && _a !== void 0 ? _a : channel.guild.voiceAdapterCreator, | ||
adapterCreator: (_b = (_a = options.adapter) !== null && _a !== void 0 ? _a : channel.guild.voiceAdapterCreator) !== null && _b !== void 0 ? _b : AdapterCreator_1.VoiceAdapterCreator(channel), | ||
selfDeaf: Boolean(options.deaf) | ||
}); | ||
try { | ||
conn = yield voice_1.entersState(conn, voice_1.VoiceConnectionStatus.Ready, (_b = options === null || options === void 0 ? void 0 : options.maxTime) !== null && _b !== void 0 ? _b : 20000); | ||
conn = yield voice_1.entersState(conn, voice_1.VoiceConnectionStatus.Ready, (_c = options === null || options === void 0 ? void 0 : options.maxTime) !== null && _c !== void 0 ? _c : 20000); | ||
return conn; | ||
@@ -77,3 +78,3 @@ } | ||
disconnect(connection) { | ||
if (connection instanceof BasicStreamDispatcher_1.StreamDispatcher) | ||
if (connection instanceof StreamDispatcher_1.StreamDispatcher) | ||
return connection.voiceConnection.destroy(); | ||
@@ -80,0 +81,0 @@ return connection.destroy(); |
{ | ||
"name": "discord-player", | ||
"version": "5.0.0-dev.6db3cdb7b2bc9b69a807e7ca37b90e6c259bae3f", | ||
"version": "5.0.0-dev.8ce04b3.1625486509", | ||
"description": "Complete framework to facilitate music commands using discord.js", | ||
@@ -55,3 +55,3 @@ "main": "lib/index.js", | ||
"dependencies": { | ||
"@discordjs/voice": "^0.5.0", | ||
"@discordjs/voice": "^0.5.3", | ||
"discord-ytdl-core": "^5.0.4", | ||
@@ -62,26 +62,26 @@ "libsodium-wrappers": "^0.7.9", | ||
"tiny-typed-emitter": "^2.0.3", | ||
"youtube-sr": "^4.1.4", | ||
"ytdl-core": "^4.8.2" | ||
"youtube-sr": "^4.1.7", | ||
"ytdl-core": "^4.8.3" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "^7.14.5", | ||
"@babel/core": "^7.14.5", | ||
"@babel/preset-env": "^7.14.5", | ||
"@babel/core": "^7.14.6", | ||
"@babel/preset-env": "^7.14.7", | ||
"@babel/preset-typescript": "^7.14.5", | ||
"@devsnowflake/docgen": "devsnowflake/docgen#ts-patch", | ||
"@discord-player/extractor": "^3.0.2", | ||
"@discordjs/opus": "^0.5.3", | ||
"@types/node": "^15.12.2", | ||
"@types/ws": "^7.4.4", | ||
"@typescript-eslint/eslint-plugin": "^4.28.0", | ||
"@typescript-eslint/parser": "^4.28.0", | ||
"@types/node": "^16.0.0", | ||
"@types/ws": "^7.4.6", | ||
"@typescript-eslint/eslint-plugin": "^4.28.1", | ||
"@typescript-eslint/parser": "^4.28.1", | ||
"discord-api-types": "^0.18.1", | ||
"discord.js": "^13.0.0-dev.6d3d00b44577a70e840f0187d6894043677c5329", | ||
"discord.js-docgen": "discordjs/docgen#ts-patch", | ||
"eslint": "^7.29.0", | ||
"discord.js": "^13.0.0-dev.fe5d56c.1625443439", | ||
"eslint": "^7.30.0", | ||
"jsdoc-babel": "^0.5.0", | ||
"prettier": "^2.3.1", | ||
"prettier": "^2.3.2", | ||
"rimraf": "^3.0.2", | ||
"ts-node": "^10.0.0", | ||
"typescript": "^4.3.4" | ||
"typescript": "^4.3.5" | ||
} | ||
} |
@@ -8,5 +8,4 @@ # Discord Player | ||
[](https://wakatime.com/badge/github/Androz2091/discord-player) | ||
[](https://www.codefactor.io/repository/github/androz2091/discord-player/overview/v5) | ||
> V5 WIP | ||
## Installation | ||
@@ -13,0 +12,0 @@ |
142575
3440
29
162
Updated@discordjs/voice@^0.5.3
Updatedyoutube-sr@^4.1.7
Updatedytdl-core@^4.8.3