diff --git a/docs/api-reference/createtranscript.md b/docs/api-reference/createtranscript.md index b26fe8a..0d09ba2 100644 --- a/docs/api-reference/createtranscript.md +++ b/docs/api-reference/createtranscript.md @@ -90,3 +90,11 @@ Defined in [discord.js](https://discord.js.org/#/docs/discord.js/main/typedef/Gu ### `options: CreateTranscriptOptions` The same options as [generatefrommessages.md](generatefrommessages.md 'mention') but adds the `limit` option which lets you limit set the number of messages to fetch. + +### `options.limit: number` + +The number of messages to fetch. + +### `options.filter: (message: Message) => boolean` + +A function that will be called for each message to determine if it should be included in the transcript. If false, the message will not be included. diff --git a/src/generator/renderers/reply.tsx b/src/generator/renderers/reply.tsx index 8517f7c..0d2016b 100644 --- a/src/generator/renderers/reply.tsx +++ b/src/generator/renderers/reply.tsx @@ -27,7 +27,7 @@ export default async function MessageReply({ message, context }: { message: Mess roleColor={referencedMessage.member?.displayHexColor ?? undefined} bot={!isCrosspost && referencedMessage.author.bot} verified={referencedMessage.author.flags?.has(UserFlags.VerifiedBot)} - op={message.channel.isThread() && referencedMessage.author.id === message.channel.ownerId} + op={message?.channel?.isThread?.() && referencedMessage.author.id === message?.channel?.ownerId} server={isCrosspost ?? undefined} command={isCommand} > diff --git a/src/index.ts b/src/index.ts index 4ae1412..0591c18 100644 --- a/src/index.ts +++ b/src/index.ts @@ -111,7 +111,7 @@ export async function createTranscript = Partial< * The max amount of messages to fetch. Use `-1` to recursively fetch. */ limit: number; + + /** + * Filter messages of the channel + * @default (() => true) + */ + filter: (message: Message) => boolean; } >; diff --git a/tests/generate.ts b/tests/generate.ts index 744f757..a79d4ca 100644 --- a/tests/generate.ts +++ b/tests/generate.ts @@ -4,8 +4,10 @@ import { TranscriptImageDownloader, createTranscript } from '../src'; import { config } from 'dotenv'; config(); +const { GuildMessages, Guilds, MessageContent } = discord.GatewayIntentBits; + const client = new discord.Client({ - intents: [discord.IntentsBitField.Flags.GuildMessages, discord.IntentsBitField.Flags.Guilds], + intents: [GuildMessages, Guilds, MessageContent], }); client.on('ready', async () => { @@ -18,15 +20,11 @@ client.on('ready', async () => { } console.time('transcript'); + const attachment = await createTranscript(channel, { - // saveImages: true, - callbacks: { - resolveImageSrc: new TranscriptImageDownloader() - .withMaxSize(5120) // 5MB in KB - .withCompression(40, true) // 40% quality, convert to webp - .build(), - }, + // options go here }); + console.timeEnd('transcript'); await channel.send({