merge-requests/3/head
Supositware 6 years ago
parent 066be8915e
commit 2bd536aa85

@ -25,7 +25,6 @@ class TtsvcCommand extends Command {
}
async exec(message, args) {
try {
let text = args.text;
// Construct the request
@ -54,21 +53,20 @@ class TtsvcCommand extends Command {
}
console.log('Audio content written to file: ttsvc.mp3');
if (message.member.voice.channel) {
const connection = await message.member.voice.channel.join();
const dispatcher = connection.playFile('../../ttsvc.mp3');
dispatcher.on('finish', () => {
dispatcher.destroy();
});
} else {
message.reply('You need to join a voice channel first!');
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('../../ttsvc.mp3');
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!`);
}
});
});
} catch (err) {
console.error(err);
}
}
}
module.exports = TtsvcCommand;
Loading…
Cancel
Save