I encountered an issue with a discord.js ticket transcript command. The problem arises when using the command to generate a .txt file and send it to the channel, as intended. However, the file ends up being saved locally, which is not the desired outcome.
Here is the code responsible for creating the txt file and sending it:
fs.writeFileSync(`${message.channel.name}.txt`, content.join('\n'), err => { if (err) throw err });
doneEmbed(message, lang.ticket.transcript.replace('{name}', `${message.channel.name}.txt`));
return message.channel.send(new MessageAttachment(`${message.channel.name}.txt`, `${message.channel.name}.txt`));
The doneEmbed
function is used for embedding purposes, here is a brief overview:
//Emoji file
const e = require('../../data/config/emojis.json');
//Embed
module.exports.doneEmbed = function doneEmbed(message, desc) {
let embed = new MessageEmbed()
.setDescription(e.done + desc)
.setColor(c.done)
message.channel.send(embed);
}
Below is the file structure where the transcripts are incorrectly saved (🎫 | exstare.txt & 🎫 | test.txt):
https://i.sstatic.net/YeQJh.png
Any assistance would be greatly appreciated!