From fc4f96908a84498af2e3cd09badc3c74e62fb84f Mon Sep 17 00:00:00 2001
From: loicbersier <loic.bersier1@gmail.com>
Date: Mon, 20 May 2019 00:17:30 +0200
Subject: [PATCH] fixed

---
 commands/fun/tts/samvc.js | 30 +++++++++++++++---------------
 1 file changed, 15 insertions(+), 15 deletions(-)

diff --git a/commands/fun/tts/samvc.js b/commands/fun/tts/samvc.js
index 12e049ac..99816634 100644
--- a/commands/fun/tts/samvc.js
+++ b/commands/fun/tts/samvc.js
@@ -73,22 +73,22 @@ class samvcCommand extends Command {
 			},
 		}).then(async (result) => {
 			const outputFilename = './samvc.mp3';
-			fs.writeFileSync(outputFilename, result.data);
-
-			const voiceChannel = message.member.voice.channel;
-			if (!voiceChannel) return message.say('Please enter a voice channel first.');
-			try {
-				const connection = await voiceChannel.join();
-				const dispatcher = connection.play('./samvc.wav');
-				dispatcher.once('finish', () => voiceChannel.leave());
-				dispatcher.once('error', () => voiceChannel.leave());
-				return null;
-			} catch (err) {
-				voiceChannel.leave();
-				return message.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
-			}
+			fs.writeFile(outputFilename, result.data, async function(err) {
+				if (err) console.error(err);
+				const voiceChannel = message.member.voice.channel;
+				if (!voiceChannel) return message.say('Please enter a voice channel first.');
+				try {
+					const connection = await voiceChannel.join();
+					const dispatcher = connection.play('./dectalkvc.wav');
+					dispatcher.once('finish', () => voiceChannel.leave());
+					dispatcher.once('error', () => voiceChannel.leave());
+					return null;
+				} catch (err) {
+					voiceChannel.leave();
+					return message.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
+				}
+			});
 		});
-
 	}
 }