work pls
This commit is contained in:
parent
066be8915e
commit
2bd536aa85
1 changed files with 36 additions and 38 deletions
|
@ -25,7 +25,6 @@ class TtsvcCommand extends Command {
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
try {
|
|
||||||
let text = args.text;
|
let text = args.text;
|
||||||
|
|
||||||
// Construct the request
|
// Construct the request
|
||||||
|
@ -54,21 +53,20 @@ class TtsvcCommand extends Command {
|
||||||
}
|
}
|
||||||
console.log('Audio content written to file: ttsvc.mp3');
|
console.log('Audio content written to file: ttsvc.mp3');
|
||||||
|
|
||||||
|
const voiceChannel = message.member.voice.channel;
|
||||||
if (message.member.voice.channel) {
|
if (!voiceChannel) return message.say('Please enter a voice channel first.');
|
||||||
const connection = await message.member.voice.channel.join();
|
try {
|
||||||
const dispatcher = connection.playFile('../../ttsvc.mp3');
|
const connection = await voiceChannel.join();
|
||||||
dispatcher.on('finish', () => {
|
const dispatcher = connection.play('../../ttsvc.mp3');
|
||||||
dispatcher.destroy();
|
dispatcher.once('finish', () => voiceChannel.leave());
|
||||||
});
|
dispatcher.once('error', () => voiceChannel.leave());
|
||||||
} else {
|
return null;
|
||||||
message.reply('You need to join a voice channel first!');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error(err);
|
voiceChannel.leave();
|
||||||
|
return message.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
module.exports = TtsvcCommand;
|
module.exports = TtsvcCommand;
|
Loading…
Reference in a new issue