#Bot wont talk & no error, how do i debug?

40 messages · Page 1 of 1 (latest)

dreamy siren
#

(selected opus tag bc i had to, to post idk what it is)

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);
    });
    
}
dense irisBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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
dreamy siren
#
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);
        }        
    }
});
#

here are my intents:

#
const client = new Client({
    intents: [IntentsBitField.Flags.Guilds,
              IntentsBitField.Flags.GuildMembers,
              IntentsBitField.Flags.GuildMessages,
              IntentsBitField.Flags.MessageContent,
              IntentsBitField.Flags.GuildVoiceStates]
});
#

ping me if you have a response

#

.wav file btw

undone hamlet
#

& the types here may have a hint

frozen valveBOT
undone hamlet
#

notably, that readstream isn't explicitly mentioned

dreamy siren
undone hamlet
#

start by breaking down this line into separate calls voiceConnectionAudioPlayer.player.play(createAudioResource(fs.createReadStream(filePath)));

undone hamlet
#

iirc you can just pass the path into createAudioResource

dreamy siren
#

ill try it again tho

undone hamlet
#

ah u are right

#

you can add a listener to the error event on audioplayer

dreamy siren
#

wtf

#

this works

#

i swear i tried this before 😭

#

i hate coding ong

#

well ty

#

so much

#

❤️

undone hamlet
#

yw

dreamy siren
#

do you know if i can delete the mp4 file right after i give the command to play it?

undone hamlet
#

i think so

#

should be read entirely into memory

dreamy siren
#

oh gotcha

#

how do you delete files in nodejs

#

btw lol

undone hamlet
#

idk google it

dreamy siren
#

oh its fs.rm

#

why is it an abreviation

undone hamlet
#

cause rm is a native command in every system