From 95870931e77a26a8d50ff3630bf387c923e61a2d Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Mon, 28 Mar 2022 16:05:12 -0400 Subject: Fixed the leave button --- AudioBackend.js | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'AudioBackend.js') diff --git a/AudioBackend.js b/AudioBackend.js index dbc239a..070e717 100644 --- a/AudioBackend.js +++ b/AudioBackend.js @@ -19,7 +19,13 @@ * ***************************************************************************/ -import { createAudioPlayer, createAudioResource, joinVoiceChannel, VoiceConnectionStatus } from '@discordjs/voice' +import { + createAudioPlayer, + createAudioResource, + getVoiceConnection, + joinVoiceChannel, + VoiceConnectionStatus +} from '@discordjs/voice' import { MessageEmbed } from 'discord.js' import config from './config.json' assert {type: 'json'} import fs from 'fs' @@ -87,4 +93,16 @@ export function playAudio(bot) { if (!statusChannel) return console.error('The status channel does not exist! Skipping.'); statusChannel.send({embeds: [statusEmbed]}); +} + +export function destroyAudio(interaction) { + fileData = "Now Playing: Nothing"; + fs.writeFile("now-playing.txt", fileData, (err) => { + if (err) + console.log(err); + }); + audio = "Not Playing"; + player.stop(); + const connection = getVoiceConnection(interaction.guild.id); + connection.destroy(); } \ No newline at end of file -- cgit v1.2.3