From dc68644b08c87b52996bc7fe88368a87557e6f79 Mon Sep 17 00:00:00 2001 From: Androz2091 Date: Sat, 26 Dec 2020 23:55:45 +0100 Subject: [PATCH] :sparkles: Add autoSelfDeaf option Closes #64 --- src/Player.js | 6 +++++- typings/index.d.ts | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Player.js b/src/Player.js index 675a87c..6094a79 100644 --- a/src/Player.js +++ b/src/Player.js @@ -59,6 +59,7 @@ const filters = { * @property {boolean} [leaveOnStop=true] Whether the bot should leave the current voice channel when the stop() function is used. * @property {boolean} [leaveOnEmpty=true] Whether the bot should leave the voice channel if there is no more member in it. * @property {number} [leaveOnEmptyCooldown=0] Used when leaveOnEmpty is enabled, to let the time to users to come back in the voice channel. + * @property {boolean} [autoSelfDeaf=true] Whether the bot should automatically turn off its headphones when joining a voice channel. */ /** @@ -69,7 +70,9 @@ const filters = { const defaultPlayerOptions = { leaveOnEnd: true, leaveOnStop: true, - leaveOnEmpty: true + leaveOnEmpty: true, + leaveOnEmptyCooldown: 0, + autoSelfDeaf: true } class Player extends EventEmitter { @@ -287,6 +290,7 @@ class Player extends EventEmitter { this.queues.set(message.guild.id, queue) channel.join().then((connection) => { queue.voiceConnection = connection + if (this.options.autoSelfDeaf) connection.voice.setSelfDeaf(true) queue.tracks.push(track) this.emit('queueCreate', message, queue) resolve(queue) diff --git a/typings/index.d.ts b/typings/index.d.ts index 65269b0..398dc9b 100644 --- a/typings/index.d.ts +++ b/typings/index.d.ts @@ -48,6 +48,7 @@ declare module 'discord-player' { leaveOnStop: boolean; leaveOnEmpty: boolean; leaveOnEmptyCooldown?: number; + autoSelfDeaf: boolean; } type Filters = 'bassboost' | '8D' | 'vaporwave' | 'nightcore'| 'phaser' | 'tremolo' | 'vibrato' | 'reverse' | 'treble' | 'normalizer' | 'surrounding' | 'pulsator' | 'subboost' | 'karaoke' | 'flanger' | 'gate' | 'haas' | 'mcompand'; type FiltersStatuses = {