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);
}
}
});
when use command just !say the voice say undefined but when i use !say hello nothing. what is problem??
6 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
변상훈
변상훈OP3y ago
[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]
and is it possible change langues?
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
변상훈
변상훈OP3y ago
It doesn't matter still have problems
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
변상훈
변상훈OP3y ago
yes but still same problem
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();
});

}
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!!

Did you find this page helpful?