From 7f73e02a60fce1c60171387beded70549fde4874 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Mon, 14 Jun 2021 20:17:37 +0545 Subject: [PATCH] ytdl options --- src/Player.ts | 4 +++- src/Structures/Queue.ts | 2 +- src/types/types.ts | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Player.ts b/src/Player.ts index cfebf98..678eb52 100644 --- a/src/Player.ts +++ b/src/Player.ts @@ -18,7 +18,8 @@ const soundcloud = new SoundCloud(); class DiscordPlayer extends EventEmitter { public readonly client: Client; public readonly options: DiscordPlayerInitOptions = { - autoRegisterExtractor: true + autoRegisterExtractor: true, + ytdlOptions: {} }; public readonly queues = new Collection(); public readonly voiceUtils = new VoiceUtils(); @@ -96,6 +97,7 @@ class DiscordPlayer extends EventEmitter { const _meta = queueInitOptions.metadata; delete queueInitOptions["metadata"]; + queueInitOptions.ytdlOptions ??= this.options.ytdlOptions const queue = new Queue(this, guild, queueInitOptions); queue.metadata = _meta; this.queues.set(guild.id, queue); diff --git a/src/Structures/Queue.ts b/src/Structures/Queue.ts index 149ab95..93fe306 100644 --- a/src/Structures/Queue.ts +++ b/src/Structures/Queue.ts @@ -35,7 +35,7 @@ class Queue { leaveOnEmptyCooldown: 1000, autoSelfDeaf: true, enableLive: false, - ytdlDownloadOptions: {}, + ytdlOptions: {}, useSafeSearch: false, disableAutoRegister: false, fetchBeforeQueued: false, diff --git a/src/types/types.ts b/src/types/types.ts index eb5248f..6a2fe35 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -1,10 +1,10 @@ import { Snowflake, User } from "discord.js"; -import { downloadOptions } from "ytdl-core"; import { Readable, Duplex } from "stream"; import { Queue } from "../Structures/Queue"; import Track from "../Structures/Track"; import { Playlist } from "../Structures/Playlist"; import { StreamDispatcher } from "../VoiceInterface/BasicStreamDispatcher"; +import { downloadOptions } from "ytdl-core"; export type FiltersName = keyof QueueFilters; @@ -80,7 +80,7 @@ export interface PlayerOptions { leaveOnEmptyCooldown?: number; autoSelfDeaf?: boolean; enableLive?: boolean; - ytdlDownloadOptions?: downloadOptions; + ytdlOptions?: downloadOptions; useSafeSearch?: boolean; disableAutoRegister?: boolean; fetchBeforeQueued?: boolean; @@ -245,4 +245,5 @@ export interface PlaylistJSON { export interface DiscordPlayerInitOptions { autoRegisterExtractor?: boolean; + ytdlOptions?: downloadOptions; }