@glad charm and @opal plank
var str1 = message.channel.name;
var str2 = "ticket-";
if (str1.indexOf(str2) != -1) {
message.channel.messages.fetch({
limit: 100
}).then(async fetched => {
fetched = fetched.array().reverse();
const mapped = fetched.map(msg => `<p><b>${msg.author.tag}</b> - ${msg.content}</p>`).join('\n');
fs.writeFile(`t/${message.channel.id}.html`, `<link rel="stylesheet" href="https://aakhilv.js.org/css/transcript.css">\n<link href="https://fonts.googleapis.com/css?family=Roboto:100,100i,300,300i,400,400i,500,500i,700,700i,900,900i" rel="stylesheet">\n<title>${message.guild.name} | ${message.channel.name}</title>\n<link rel="icon" type="image/png" href="https://discord.com/assets/eedd4bd948a0da6d75bf5304bff4e17f.svg">\n<div id="textlog">\n<h2>${message.guild.name} | ${message.channel.name}</h2>\n${mapped}\n<footer>Transcripts powered by <a href="https://tixy.js.org" style="font-weight: bold;background: #23272A;" target="_blank">Tixy</a></footer>\n</div>`, function(err) {
if (err) throw err;
let transcriptembed = new Discord.MessageEmbed()
.setTitle(`Transcript for #${message.channel.name}`)
.setDescription(`https://tixy.js.org/t/${message.channel.id}.html`)
.setColor("#fcb251")
.setFooter("Powered by Tixy", "https://i.imgur.com/SdcXbyw.png")
.setTimestamp();
if (ticketlog !== null) {
logchannel.send(transcriptembed);
message.channel.send(`Transcript sent to ${logchannel}.`);
} else if (ticketlog === null) {
message.channel.send(transcriptembed);
};
});
});
};