The options object allows you to customize the transcript generation process.
Return Type
options.returnType: Determines the format of the returned data.
'buffer': Returns the HTML data as a Buffer.'string': Returns the HTML data as a string.'attachment': Returns an AttachmentBuilder (Default).
File and Content Customization
options.filename: The name of the output file (only used if returnType is 'attachment'). Default: transcript-{channel id}.html.options.saveImages: A boolean. If true, the library downloads all image attachments and embeds them directly in the HTML. This prevents broken images if the original Discord attachments are deleted, but significantly increases file size and may hit Discord's upload limits.options.footerText: Custom text for the transcript footer. Supports placeholders:{number}: Total number of messages exported.{s}: Adds an 's' if the number is > 0 (for pluralization).
options.poweredBy: A boolean to show or hide the "Powered by discord-html-transcripts" footer (Default: true).
Custom Resolvers (Callbacks)
If your bot uses specific caching or custom fetching logic, you can provide custom callback functions via options.callbacks to resolve Discord entities mentioned in the transcript:
resolveChannel: (channelId: string) => Awaitable<Channel | null>resolveUser: (userId: string) => Awaitable<User | null>resolveRole: (roleId: string) => Awaitable<Role | null>
const attachment = await discordTranscripts.generateFromMessages(
messages,
channel,
{
returnType: 'attachment', // 'buffer' | 'string' | 'attachment'
filename: 'transcript.html',
saveImages: false,
footerText: "Exported {number} message{s}",
poweredBy: true,
callbacks: {
resolveChannel: async (channelId) => await channel.client.channels.fetch(channelId),
resolveUser: async (userId) => await channel.client.users.fetch(userId),
resolveRole: async (roleId) => await channel.guild.roles.fetch(roleId)
}
}
);