I just switched to v12 and i'm trying to get the bot to play audio from a url (http://www.voicerss.org/api/)but it won't play audio and it doesn't show errors, it used to work perfectly with v11.
I've followed this page to update my code Here is the code:
async execute(message, args) {
url = `http://api.voicerss.org/?key=${process.env.VOICE_RSS_KEY}&hl=de-de&v=Jonas&c=MP3&f=16khz_16bit_stereo&src=`;
let speech = '';
for (var i = 0; i < args.length; i++) {
if (i == 0) {
speech += args[i];
} else {
speech += '%20' + args[i];
}
}
url = url.concat('', speech);
const voiceChannel = message.member.voice.channel;
if (!voiceChannel)
return message.channel.send(
'You need to be in a voice channel to use this command'
);
try {
let connection = await voiceChannel.join();
const dispatcher = connection.play(url);
//console.log(dispatcher);
console.log(url);
dispatcher.on('finish', () => {
connection.disconnect();
});
dispatcher.on('error', console.error);
} catch (err) {
console.log(err);
return message.channel.send(err);
}
}