Closed Sophan-Developer closed 3 years ago
Bot joined voice and not playstream
const tts = require("google-tts-api");
let tts1 = message.content.split(" ").slice(1).join(" ");
const voiceChannel = message.member.voiceChannel;
if (!voiceChannel) return message.channel.send('**Please be in a voice channel first!**');
if (!client.voiceConnections.get(message.channel.guild.id)) {
voiceChannel.join()
.then(connnection => {
tts.getAudioBase64(tts1, {
lang: 'en-US',
slow: false,
host: 'https://translate.google.com',
timeout: 10000,
})
.then((url) => {
const dispatcher = connnection.playStream(url);
})
.catch((err) => {
message.channel.send(':no_entry_sign: Something wen\'t wrong.\n' + err);
voiceChannel.leave();
});
});
} else {
}
Hi @KimYou-Developer,
getAudioBase64
is return a base64 encoded string but not the URL. (from new Google API)
You can try to use tts.getAudioUrl
in this way.
const tts = require('google-tts-api');
const voiceChannel = message.member.voiceChannel;
if (!voiceChannel) return message.channel.send('**Please be in a voice channel first!**');
if (!client.voiceConnections.get(message.channel.guild.id)) {
voiceChannel
.join()
.then((connnection) => {
const url = tts.getAudioUrl(tts1);
const dispatcher = connnection.playStream(url);
})
.catch((err) => {
message.channel.send(":no_entry_sign: Something wen't wrong.\n" + err);
voiceChannel.leave();
});
}
@zlargon thanks for helping 😍😍
I use it with discord.js v11.6.1 How to fix this with New version 2.0.0? Why you don't have discord server?