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

453
Views
How do I send a TXT file in Discord.js?

How do I send a txt file in discord.js as an Attachment? Like this: enter image description here

I have tried the following code:

let content = nsOpts.Tcontent
fs.writeFileSync('./nosleep.txt', content)

let atc = new discord.MessageAttachment('nosleep.txt')

interaction.channel.send('here ya go,', { files: [atc, 'nosleep.txt', './nosleep.txt', 'attachment://nosleep.txt']})

But the bot only sends the message, not the file.

enter image description here

Thanks

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

0

Try this.

const fs = require('fs');
var atc = fs.readFileSync('./nosleep.txt', {"encoding": "utf-8"});
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!