Why does this even work

This commit is contained in:
Daniel Odendahl Jr
2018-06-10 01:26:20 +00:00
parent c8d78901c7
commit 2dd81a23ea
9 changed files with 22 additions and 19 deletions
+11 -5
View File
@@ -35,11 +35,17 @@ module.exports = class DECTalkCommand extends Command {
if (this.client.voiceConnections.has(channel.guild.id)) return msg.say('I am already playing a sound.');
try {
const connection = await channel.join();
const { headers } = await request
.get('http://tts.cyzon.us/tts')
.query({ text })
.redirects(0);
const dispatcher = connection.play(`http://tts.cyzon.us${headers.location}`);
let url = 'http://tts.cyzon.us';
try {
await request
.get('http://tts.cyzon.us/tts')
.query({ text })
.redirects(0);
} catch (err) {
if (err.headers.location) url += err.headers.location;
else throw err;
}
const dispatcher = connection.play(url);
dispatcher.once('finish', () => channel.leave());
dispatcher.once('error', () => channel.leave());
return null;