#How would I save an attachment provided by a command?
26 messages · Page 1 of 1 (latest)
• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.
Download the file using the link you get from the attachment object
How would I do that exactly?
That's what I do atleast.
wget exists in linux
I was ideally hoping to download it with code and save it automatically
You can achieve that by using the child_process package of node.
the exec package to be exact.
That can be used to execute a download command for the attachment link after navigating to your folder within the working directory
But double check what you're downloading always.
do you have documentation for it?
What OS are you using ?
for testing, windows, for hosting, my VPS with ubuntu using pm2
Then the commands and how you handle the chaining differs
what I was looking for is a way to just use fs to write the file ideally
to save time and just make my code more efficient
would I be able to use a write stream for this or?
I think I have found a way from this code sample
let request = require(`request`);
let fs = require(`fs`);
function download(url){
request.get(url)
.on('error', console.error)
.pipe(fs.createWriteStream('meme.png'));
}
Then I have to apologize because idk much about the fs ecosystem. 
For me personally I created a single download function that I can use anywhere within the code when I want.
Oh yeah that also works. atleast the logic is right
yeah Ill test this and hope that it doesnt corrupt
even if it does ill just trial and error it