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.
filePicture is a string. The files argument in message.channel.send requires an array of actual Buffers or such.