tts not reading without undefined
client.on("messageCreate", async (msg)=>{
const prefix = "!"
const args = msg.content.slice(prefix.length).trim().split(/ +/);
let txtr = args[1]
console.log(txtr)
console.log(args)
if(msg.content == "!say")
{
const stream = discordTTS.getVoiceStream(txtr);
const audioResource=createAudioResource(stream, {inputType: StreamType.Arbitrary, inlineVolume:true});
if(!voiceConnection || voiceConnection?.status===VoiceConnectionStatus.Disconnected){
voiceConnection = joinVoiceChannel({
channelId: msg.member.voice.channelId,
guildId: msg.guildId,
adapterCreator: msg.guild.voiceAdapterCreator,
});
voiceConnection=await entersState(voiceConnection, VoiceConnectionStatus.Connecting, 5_000);
}
if(voiceConnection.status===VoiceConnectionStatus.Connected){
voiceConnection.subscribe(audioPlayer);
audioPlayer.play(audioResource);
}
}
});
client.on("messageCreate", async (msg)=>{
const prefix = "!"
const args = msg.content.slice(prefix.length).trim().split(/ +/);
let txtr = args[1]
console.log(txtr)
console.log(args)
if(msg.content == "!say")
{
const stream = discordTTS.getVoiceStream(txtr);
const audioResource=createAudioResource(stream, {inputType: StreamType.Arbitrary, inlineVolume:true});
if(!voiceConnection || voiceConnection?.status===VoiceConnectionStatus.Disconnected){
voiceConnection = joinVoiceChannel({
channelId: msg.member.voice.channelId,
guildId: msg.guildId,
adapterCreator: msg.guild.voiceAdapterCreator,
});
voiceConnection=await entersState(voiceConnection, VoiceConnectionStatus.Connecting, 5_000);
}
if(voiceConnection.status===VoiceConnectionStatus.Connected){
voiceConnection.subscribe(audioPlayer);
audioPlayer.play(audioResource);
}
}
});
!say
the voice say undefined
but when i use !say hello
nothing.
what is problem??6 Replies
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
[email protected] C:\discordbot\tts
├── @discordjs/[email protected]
├── @discordjs/[email protected]
├── @discordjs/[email protected]
├── @sapphire/[email protected]
[email protected] C:\discordbot\tts
├── @discordjs/[email protected]
├── @discordjs/[email protected]
├── @discordjs/[email protected]
├── @sapphire/[email protected]
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
It doesn't matter still have problems
Unknown User•3y ago
Message Not Public
Sign In & Join Server To View
yes but still same problem
here is my code! thx!
then howto change it? i need command to play tts.
i understand and i did it, and it's working! thx so much!!! bro!!
let voiceConnection;
let audioPlayer=new AudioPlayer();
client.on("messageCreate", async (message)=>{
const prefix = "!"
const args = message.content.slice(prefix.length).trim().split(/ +/);
var txtr = args[1]
console.log(args[1])
console.log(args)
if(message.content == "say")
{
console.log(txtr)
voiceConnection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator,
});
const stream = discordTTS.getVoiceStream(txtr);
const audioResource=createAudioResource(stream, {inputType: StreamType.Arbitrary, inlineVolume:true});
voiceConnection = await entersState(voiceConnection, VoiceConnectionStatus.Connecting, 5_000);
voiceConnection.subscribe(audioPlayer);
audioPlayer.play(audioResource)
audioPlayer.on(AudioPlayerStatus.Idle, () => {
voiceConnection.destroy();
});
}
let voiceConnection;
let audioPlayer=new AudioPlayer();
client.on("messageCreate", async (message)=>{
const prefix = "!"
const args = message.content.slice(prefix.length).trim().split(/ +/);
var txtr = args[1]
console.log(args[1])
console.log(args)
if(message.content == "say")
{
console.log(txtr)
voiceConnection = joinVoiceChannel({
channelId: message.member.voice.channelId,
guildId: message.guildId,
adapterCreator: message.guild.voiceAdapterCreator,
});
const stream = discordTTS.getVoiceStream(txtr);
const audioResource=createAudioResource(stream, {inputType: StreamType.Arbitrary, inlineVolume:true});
voiceConnection = await entersState(voiceConnection, VoiceConnectionStatus.Connecting, 5_000);
voiceConnection.subscribe(audioPlayer);
audioPlayer.play(audioResource)
audioPlayer.on(AudioPlayerStatus.Idle, () => {
voiceConnection.destroy();
});
}