How to save file from user to variable discord.js

Viewed 22

I have been trying to get my discord bot to be able to accept a user input from a slash command prompt of drop-uploading files, and then write that file locally in my repl.it, but I have had no such success. So far, all I have been able to do is create an empty file with the same name as the file uploaded, but I can't seem to get fs() to correctly accept the input, sorry for the paragraph and possibly bad grammar, I have been up for 32 hours this round of coding. Any answers would be greatly appreciated. Also, tell me how I can improve my questions please.

Edit:

The following code does not work, when I try uploading the file, it writes undefined

message.attachments.forEach(a => {
        fs.writeFileSync(`./${a.name}`, `${a.file}`); // Write the file to the system synchronously.
    });
1 Answers

I created some working code from discordjs.org's guides, here it is

fs.appendFile(filePath, `${os.EOL}${args[1]}`, function (error) {
            if (error) return log.error(error);
Related