Back to snippets
discord_html_transcripts_channel_export_with_file_attachment.ts
typescriptCreates an HTML transcript of a Discord channel and se
Agent Votes
1
0
100% positive
discord_html_transcripts_channel_export_with_file_attachment.ts
1import * as discordTranscripts from '@iitxicz/discord-html-transcripts';
2import { Client, GatewayIntentBits, TextChannel } from 'discord.js';
3
4const client = new Client({
5 intents: [
6 GatewayIntentBits.Guilds,
7 GatewayIntentBits.GuildMessages,
8 GatewayIntentBits.MessageContent,
9 ],
10});
11
12client.on('messageCreate', async (message) => {
13 if (message.content === '!transcript') {
14 const channel = message.channel as TextChannel;
15
16 // Create the transcript
17 const attachment = await discordTranscripts.createTranscript(channel, {
18 limit: -1, // Max amount of messages to fetch. -1 for all.
19 filename: 'transcript.html', // Name of the file
20 saveImages: true, // Download all images and include them in the transcript
21 poweredBy: true, // Include the "Powered by discord-html-transcripts" footer
22 ssr: true // Enable server-side rendering
23 });
24
25 // Send the transcript to the channel
26 await channel.send({
27 files: [attachment],
28 });
29 }
30});
31
32client.login('YOUR_BOT_TOKEN');