From 3378d5cfd7da26611efefbeb429df80f17dcd789 Mon Sep 17 00:00:00 2001 From: Snowflake107 Date: Fri, 11 Jun 2021 15:13:21 +0545 Subject: [PATCH] feat: @discordjs/voice --- src/VoiceInterface/VoiceSubscription.ts | 7 +++++++ src/VoiceInterface/VoiceUtils.ts | 5 +++-- src/index.ts | 3 ++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/VoiceInterface/VoiceSubscription.ts b/src/VoiceInterface/VoiceSubscription.ts index 5e5ff23..e41edc2 100644 --- a/src/VoiceInterface/VoiceSubscription.ts +++ b/src/VoiceInterface/VoiceSubscription.ts @@ -93,6 +93,13 @@ class VoiceSubscription extends EventEmitter { return this.audioPlayer.state.status; } + /** + * Disconnects from voice + */ + disconnect() { + this.voiceConnection.destroy(); + } + /** * Stops the player */ diff --git a/src/VoiceInterface/VoiceUtils.ts b/src/VoiceInterface/VoiceUtils.ts index f69d87c..3992152 100644 --- a/src/VoiceInterface/VoiceUtils.ts +++ b/src/VoiceInterface/VoiceUtils.ts @@ -40,8 +40,9 @@ class VoiceUtils { * Disconnects voice connection * @param {VoiceConnection} connection The voice connection */ - public static disconnect(connection: VoiceConnection) { - connection.destroy(); + public static disconnect(connection: VoiceConnection | VoiceSubscription) { + if (connection instanceof VoiceSubscription) return connection.voiceConnection.destroy(); + else connection.destroy(); } } diff --git a/src/index.ts b/src/index.ts index cb0ff5c..f4043fb 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1 +1,2 @@ -export {}; +export { VoiceUtils } from "./VoiceInterface/VoiceUtils"; +export { VoiceEvents, VoiceSubscription } from "./VoiceInterface/VoiceSubscription";