idk what can i do
This commit is contained in:
parent
9a4c84b506
commit
346874ce31
2 changed files with 11 additions and 8 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -10,3 +10,4 @@ json/blacklist.json
|
|||
json/customresponse.json
|
||||
tag/*
|
||||
tts.mp3
|
||||
ttsvc.mp3
|
||||
|
|
|
@ -44,13 +44,13 @@ module.exports = class ttsvcCommand extends Command {
|
|||
}
|
||||
|
||||
// Write the binary audio content to a local file
|
||||
fs.writeFile('tts.mp3', response.audioContent, 'binary', err => {
|
||||
fs.writeFile('ttsvc.mp3', response.audioContent, 'binary', err => {
|
||||
if (err) {
|
||||
console.error('ERROR:', err);
|
||||
message.say('An error has occured, the message is probably too long')
|
||||
return;
|
||||
}
|
||||
console.log('Audio content written to file: tts.mp3');
|
||||
console.log('Audio content written to file: ttsvc.mp3');
|
||||
const { voiceChannel } = message.member;
|
||||
|
||||
// If not in voice channel ask user to join
|
||||
|
@ -63,11 +63,13 @@ module.exports = class ttsvcCommand extends Command {
|
|||
voiceChannel.leave()
|
||||
message.say('I leaved the channel');
|
||||
} else
|
||||
const dispatcher = voiceChannel.join()
|
||||
.then(connection => dispatcher = connection.play('./tts.mp3'))
|
||||
dispatcher.on('finish', () => {
|
||||
voiceChannel.leave()
|
||||
voiceChannel.join().then(connection => {
|
||||
const dispatcher = connection.playStream('./ttsvc.mp3');
|
||||
// End at then end of the audio stream
|
||||
dispatcher.on('end', () => setTimeout(function(){
|
||||
voiceChannel.leave();
|
||||
}, 2000));
|
||||
});
|
||||
|
||||
});
|
||||
})}}
|
||||
});
|
||||
}}
|
Loading…
Reference in a new issue