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tB,KACR,CAIA,OAHI,EAAgB,EAAY,SAC5B,EAAc,EAAY,MAAM,EAAG,IAEhC,qBAAqB,EAAY,UAAW,EAAS,EAChE,CAtFsB,OAAlB,eAA4C,OAAlB,gBAC1B,QAAQ,MAAM,sJAAsJ,aAAa,oIAEjL,QAAQ,KAAK,IAoFjB,QAAQ,QAAU,CACd,kCACA,2CAEJ,aAAa,QAAQ,WAAY","file":"/npm/stratostech-discord-html-transcripts@1.0.12/dist/index.js","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/stratostech-discord-html-transcripts@1.0.12/dist/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","\"use strict\";\nvar __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    var desc = Object.getOwnPropertyDescriptor(m, k);\n    if (!desc || (\"get\" in desc ? !m.__esModule : desc.writable || desc.configurable)) {\n      desc = { enumerable: true, get: function() { return m[k]; } };\n    }\n    Object.defineProperty(o, k2, desc);\n}) : (function(o, m, k, k2) {\n    if (k2 === undefined) k2 = k;\n    o[k2] = m[k];\n}));\nvar __exportStar = (this && this.__exportStar) || function(m, exports) {\n    for (var p in m) if (p !== \"default\" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.generateFromMessages = generateFromMessages;\nexports.createTranscript = createTranscript;\nconst discord_js_1 = require(\"discord.js\");\nconst generator_1 = __importDefault(require(\"./generator\"));\nconst types_1 = require(\"./types\");\n// version check\nconst versionPrefix = discord_js_1.version.split('.')[0];\nif (versionPrefix !== '14' && versionPrefix !== '15') {\n    console.error(`[discord-html-transcripts] Versions v3.x.x of discord-html-transcripts are only compatible with discord.js v14.x.x and v15.x.x, and you are using v${discord_js_1.version}.` +\n        `    For v13.x.x support, please install discord-html-transcripts v2.x.x using \"npm install discord-html-transcripts@^2\".`);\n    process.exit(1);\n}\n/**\n *\n * @param messages The messages to generate a transcript from\n * @param channel  The channel the messages are from (used for header and guild name)\n * @param options  The options to use when generating the transcript\n * @returns        The generated transcript\n */\nasync function generateFromMessages(messages, channel, options = {}) {\n    var _a, _b, _c, _d, _e, _f, _g;\n    // turn messages into an array\n    const transformedMessages = messages instanceof discord_js_1.Collection ? Array.from(messages.values()) : messages;\n    // const startTime = process.hrtime();\n    // render the messages\n    const html = await (0, generator_1.default)({\n        messages: transformedMessages,\n        channel,\n        saveImages: (_a = options.saveImages) !== null && _a !== void 0 ? _a : false,\n        callbacks: Object.assign({ resolveChannel: async (id) => channel.client.channels.fetch(id).catch(() => null), resolveUser: async (id) => channel.client.users.fetch(id).catch(() => null), resolveRole: channel.isDMBased() ? () => null : async (id) => { var _a; return (_a = channel.guild) === null || _a === void 0 ? void 0 : _a.roles.fetch(id).catch(() => null); } }, ((_b = options.callbacks) !== null && _b !== void 0 ? _b : {})),\n        poweredBy: (_c = options.poweredBy) !== null && _c !== void 0 ? _c : true,\n        footerText: (_d = options.footerText) !== null && _d !== void 0 ? _d : 'Exported {number} message{s}.',\n        favicon: (_e = options.favicon) !== null && _e !== void 0 ? _e : 'guild',\n        hydrate: (_f = options.hydrate) !== null && _f !== void 0 ? _f : false,\n    });\n    // get the time it took to render the messages\n    // const renderTime = process.hrtime(startTime);\n    // console.log(\n    //   `[discord-html-transcripts] Rendered ${transformedMessages.length} messages in ${renderTime[0]}s ${\n    //     renderTime[1] / 1000000\n    //   }ms`\n    // );\n    // return the html in the specified format\n    if (options.returnType === types_1.ExportReturnType.Buffer) {\n        return Buffer.from(html);\n    }\n    if (options.returnType === types_1.ExportReturnType.String) {\n        return html;\n    }\n    return new discord_js_1.AttachmentBuilder(Buffer.from(html), {\n        name: (_g = options.filename) !== null && _g !== void 0 ? _g : `transcript-${channel.id}.html`,\n    });\n}\n/**\n *\n * @param channel The channel to create a transcript from\n * @param options The options to use when creating the transcript\n * @returns       The generated transcript\n */\nasync function createTranscript(channel, options = {}) {\n    // validate type\n    if (!channel.isTextBased()) {\n        // @ts-expect-error(2339): run-time check\n        throw new TypeError(`Provided channel must be text-based, received ${channel.type}`);\n    }\n    // fetch messages\n    let allMessages = [];\n    let lastMessageId;\n    const { limit } = options;\n    const resolvedLimit = typeof limit === 'undefined' || limit === -1 ? Infinity : limit;\n    // until there are no more messages, keep fetching\n    // eslint-disable-next-line no-constant-condition\n    while (true) {\n        // create fetch options\n        const fetchLimitOptions = { limit: 100, before: lastMessageId };\n        if (!lastMessageId)\n            delete fetchLimitOptions.before;\n        // fetch messages\n        const messages = await channel.messages.fetch(fetchLimitOptions);\n        // add the messages to the array\n        allMessages.push(...messages.values());\n        lastMessageId = messages.lastKey();\n        // if there are no more messages, break\n        if (messages.size < 100)\n            break;\n        // if the limit has been reached, break\n        if (allMessages.length >= resolvedLimit)\n            break;\n    }\n    if (resolvedLimit < allMessages.length)\n        allMessages = allMessages.slice(0, limit);\n    // generate the transcript\n    return generateFromMessages(allMessages.reverse(), channel, options);\n}\nexports.default = {\n    createTranscript,\n    generateFromMessages,\n};\n__exportStar(require(\"./types\"), exports);\n"]}