generateFromMessages
If you want to provide your own messages for finer control of what discord-html-transcripts
will save, use this function.
Example
Parameters
messages: Message[] | Collection<string, Message>
messages: Message[] | Collection<string, Message>
These are the messages that will be used in the body of the transcript. Can either be an array of discord.js Message objects or a Collection of Messages.
channel: TextBasedChannel
channel: TextBasedChannel
Defined in discord.js as TextChannel | NewsChannel | ThreadChannel | VoiceChannel
``This is channel is used to grab information about the transcript, like guild name and icon, channel name, etc.
options: GenerateFromMessagesOptions
options: GenerateFromMessagesOptions
An object with the discord-html-transcripts configuration options.
options.returnType: 'buffer' | 'string' | 'attachment'
options.returnType: 'buffer' | 'string' | 'attachment'
It's recommended to use the ExportReturnType
enum instead of passing in a string.
This option determines what this function will return.
buffer: the HTML data as a buffer.
string: the HTML data as a string.
attachment: the HTML data as an
AttachmentBuilder
The default value is attachment
options.filename: string
options.filename: string
The name of the output file when the return type is attachment
The default value is transcript-{channel id}.html
options.saveImages: boolean
options.saveImages: boolean
Enabling this option will make Discord HTML Transcripts download all image attachments. This is useful in use cases where the channel will be deleted which will wipe all images off of Discord's CDN, which will break images that aren't downloaded.
If you are uploading the transcript to discord, enabling this option may cause issues. Your bot may hit the upload filesize limit since images take up a lot of space!
The default value is false
options.footerText: string
options.footerText: string
The text that will be used in the footer of the transcript. You can use the following placeholders:
{number}
: the total number of messages exported. Useful when you are usingcreateTranscript(...)
{s}
: Adds an s if the number is >0, otherwise it is replaced with nothing
The default value is Exported {number} message{s}
options.poweredBy: boolean
options.poweredBy: boolean
Disabling this will remove the Powered by discord-html-transcripts
in the footer.
The default value is true
options.callbacks.resolveChannel: (channelId: string) => Awaitable<Channel | null>
options.callbacks.resolveChannel: (channelId: string) => Awaitable<Channel | null>
A custom function that will be used by the module whenever it needs to resolve a channel (for example, if someone mentions a channel)
The default option uses channel.client.channels.fetch(...)
function.
options.callbacks.resolveUser: (userId: string) => Awaitable<User | null>
options.callbacks.resolveUser: (userId: string) => Awaitable<User | null>
A custom function that will be used by the module whenever it needs to resolve a user (for example, if a user is mentioned)
The default option uses channel.client.users.fetch(...)
options.callbacks.resolveRole: (roleId: string) => Awaitable<Role | null>
options.callbacks.resolveRole: (roleId: string) => Awaitable<Role | null>
A custom function that will be used by the module whenever it needs to resolve a role (for example, if a role is mentioned)
The default option uses channel.guild?.roles.fetch(...)
Last updated