Bot wont talk & no error, how do i debug? (.wav sound file)

how do i debug this? since it says nothing in logs and doesnt even light up green code (voiceConnectionAudioPlayer.player.play(...) is actually ran):
function sayAsUser(text, userId)
{
const voice = voicesJSON();
const name = getRandomInt(1000).toString() + ".wav";
const filePath = `D:/js projects/schizophrenia discord bot/sounds/${name}`;
// say.speak(text, voice.userVoices.voice[voice.userVoices.userId.indexOf(userId)]);
say.export(text, voice.userVoices.voice[voice.userVoices.userId.indexOf(userId)], 1, filePath, (e) => {
console.log(e);
});

console.log("trying to play audio...");
const watcher = fs.watch("D:/js projects/schizophrenia discord bot/sounds", (eventType, file) => {
if(eventType == "rename" && file == name)
{
console.log("actually playing audio...");
voiceConnectionAudioPlayer.player.play(createAudioResource(fs.createReadStream(filePath)));
watcher.close();
}
console.log(file);
});

}
function sayAsUser(text, userId)
{
const voice = voicesJSON();
const name = getRandomInt(1000).toString() + ".wav";
const filePath = `D:/js projects/schizophrenia discord bot/sounds/${name}`;
// say.speak(text, voice.userVoices.voice[voice.userVoices.userId.indexOf(userId)]);
say.export(text, voice.userVoices.voice[voice.userVoices.userId.indexOf(userId)], 1, filePath, (e) => {
console.log(e);
});

console.log("trying to play audio...");
const watcher = fs.watch("D:/js projects/schizophrenia discord bot/sounds", (eventType, file) => {
if(eventType == "rename" && file == name)
{
console.log("actually playing audio...");
voiceConnectionAudioPlayer.player.play(createAudioResource(fs.createReadStream(filePath)));
watcher.close();
}
console.log(file);
});

}
2 Replies
d.js toolkit
d.js toolkit4mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
skg
skgOP4mo ago
[email protected] @discordjs/[email protected] and node: v21.5.0 and this is how i get the voice connection:
client.on("interactionCreate", (interaction) => // on command
{
if(!interaction.isChatInputCommand()) return;

if(interaction.commandName == "join")
{
try
{
const voiceChannelId = interaction.member.voice.channel.id;


voiceConnection = joinVoiceChannel({
channelId: voiceChannelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator
});
interaction.reply("Joined voice chat succesfully!");
console.log(`Joining vc ${interaction.member.voice.channel.name} (ID: ${voiceChannelId})`);

voiceConnectionAudioPlayer = voiceConnection.subscribe(createAudioPlayer());

} catch (error) {
console.log(error);
}
}
});
client.on("interactionCreate", (interaction) => // on command
{
if(!interaction.isChatInputCommand()) return;

if(interaction.commandName == "join")
{
try
{
const voiceChannelId = interaction.member.voice.channel.id;


voiceConnection = joinVoiceChannel({
channelId: voiceChannelId,
guildId: interaction.guildId,
adapterCreator: interaction.guild.voiceAdapterCreator
});
interaction.reply("Joined voice chat succesfully!");
console.log(`Joining vc ${interaction.member.voice.channel.name} (ID: ${voiceChannelId})`);

voiceConnectionAudioPlayer = voiceConnection.subscribe(createAudioPlayer());

} catch (error) {
console.log(error);
}
}
});
ping me if you have any response here are my intents:
const client = new Client({
intents: [IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildVoiceStates]
});
const client = new Client({
intents: [IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
IntentsBitField.Flags.GuildVoiceStates]
});
Want results from more Discord servers?
Add your server