• Jobs
  • About Us
  • professionals
    • Home
    • Jobs
    • Courses and challenges
  • business
    • Home
    • Post vacancy
    • Our process
    • Pricing
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Salary Calculator

0

394
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 3 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 3 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 Our process Sales
Legal
Terms and conditions Privacy policy
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recommend me some offers
I have an error