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

390
Views
Comppresing folder to zip in node.js

I'm creating a discord bot in discord.js that saves messages on the server. I would like to make it send a .zip compressed file from the saved messages folder. I know how to send attechment but I don't know how to add files from directory to this zip

I tried this:

But files aren't appending in zip.
Could someone please send fixed code?
Thank you in advance for your help.

var fs = require("fs");
var JSZip = require("jszip");
var zip = new JSZip();

zip
   .folder("data");
   .generateNodeStream({ type: 'nodebuffer', streamFiles: true })

  .pipe(fs.createWriteStream("logs.zip"))
   .on('finish', function () {
       console.log("out.zip written.");
   });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

At the Discord.js Documentation in stable version, TextChannel reference has a method send that allow send remote and local files.

Sample code of documentation for send a local file:

// Send a local file
channel.send({
  files: [{
    attachment: 'entire/path/to/file.jpg',
    name: 'file.jpg'
    description: 'A description of the file'
  }]
})
  .then(console.log)
  .catch(console.log);

You can build a absolute path file with the path module and give as attachment value.

const path = require('path');
const ABSOLUTE_PATH_FILE = path.resolve(__dirname, "./../files/filename.zip");
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!