Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

161
Views
node js 'FILE_NOT_FOUND'

so I am learning node JS and trying to make a discord bot with it and I am having troubles.

module.exports = {
    name: "gabe",
    description: "gabe",
    execute(message, args) {
        var fs = require("fs");
        var files = fs.readdirSync("./gabe/");
        let chosenFile = files[Math.floor(Math.random() * files.length)];
        const fileDirectory = "./gabe/";
        const filePicture = fileDirectory.concat(chosenFile);
        message.channel.send({ files: filePicture });
    },
};

I am trying to select a random picture from a folder (./gabe/), but I am getting 'FILE_NOT_FOUND'

In my code I am randomly selecting a .png from the ./gabe/ folder and trying to concat it to make it './gabe/name.png' so that the discord bot can dipsplay it.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

filePicture is a string. The files argument in message.channel.send requires an array of actual Buffers or such.

enter image description here

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!