@getoeteter/discord-transcripts 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/lib/discord-adapter.js +1 -1
- package/dist/lib/markdown.js +1 -1
- package/dist/types/discord.d.ts +4 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
Generate standalone HTML transcripts from Discord channels. Works with discord.js v14.
|
|
4
4
|
|
|
5
|
-
The generated HTML files are completely self-contained
|
|
5
|
+
The generated HTML files are completely self-contained - no external dependencies, no JavaScript frameworks. Just open the file in a browser.
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
9
9
|
```bash
|
|
10
10
|
npm install @getoeteter/discord-transcripts
|
|
11
11
|
# or
|
|
12
|
-
|
|
12
|
+
bun add @getoeteter/discord-transcripts
|
|
13
13
|
```
|
|
14
14
|
|
|
15
15
|
Requires `discord.js` ^14.0.0 as a peer dependency.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var e=this&&this.__rest||function(e,i){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&i.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&(String.fromCharCode(102,117,110,99,116,105,111,110))==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)i.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(t[o[n]]=e[o[n]])}return t};import{generateTranscriptHtml as i}from"./generator.js";export async function createTranscript(o,n={}){const{limit:a=100,before:r,after:
|
|
1
|
+
var e=this&&this.__rest||function(e,i){var t={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&i.indexOf(o)<0&&(t[o]=e[o]);if(null!=e&&(String.fromCharCode(102,117,110,99,116,105,111,110))==typeof Object.getOwnPropertySymbols){var n=0;for(o=Object.getOwnPropertySymbols(e);n<o.length;n++)i.indexOf(o[n])<0&&Object.prototype.propertyIsEnumerable.call(e,o[n])&&(t[o[n]]=e[o[n]])}return t};import{generateTranscriptHtml as i}from"./generator.js";export async function createTranscript(o,n={}){const{limit:a=100,before:r,after:d,filename:l,resolveRoles:s=1}=n,c=e(n,[(String.fromCharCode(108,105,109,105,116)),(String.fromCharCode(98,101,102,111,114,101)),(String.fromCharCode(97,102,116,101,114)),(String.fromCharCode(102,105,108,101,110,97,109,101)),(String.fromCharCode(114,101,115,111,108,118,101,82,111,108,101,115))]),m=Math.min(Math.max(1,a),5e3),u=await(async function(e,i,t,o){var n,a;const r=[];let d=t;if(o){let t=o;for(;r.length<i;){const o=await e.messages.fetch(Object.assign({limit:Math.min(100,i-r.length)},t?{after:t}:{}));if(0===o.size)break;const a=[...o.values()].sort((e,i)=>e.createdTimestamp-i.createdTimestamp);r.push(...a),t=null===(n=a[a.length-1])||void 0===n?void 0:n.id}return r}for(;r.length<i;){const t=await e.messages.fetch(Object.assign({limit:Math.min(100,i-r.length)},d?{before:d}:{}));if(0===t.size)break;r.push(...t.values()),d=null===(a=t.last())||void 0===a?void 0:a.id}return r.reverse()})(o,m,r,d),p=o.guild,h=(function(e){const i={};return e.roles.cache.forEach(e=>{i[e.id]={id:e.id,name:e.name,color:e.color,position:e.position}}),i})(p),v=(function(e){const i={};return e.channels.cache.forEach(e=>{i[e.id]={id:e.id,name:e.name,type:e.type}}),i})(p),f=s?await(async function(e,i){const t={},o=[...new Set(i.map(e=>e.author.id))];for(const i of o)try{const o=await e.members.fetch(i);t[i]=o.roles.cache.map(e=>e.id)}catch(e){}return t})(p,u):{},g={guild:{id:p.id,name:p.name,icon:p.icon},channel:{id:o.id,name:o.name,type:o.type,topic:o.topic},messages:u.map(t),roles:h,channels:v,memberRoles:f,generatedAt:(new Date).toISOString(),totalMessages:u.length},y=i(g,c);return{html:y,buffer:Buffer.from(y,(String.fromCharCode(117,116,102,45,56))),filename:null!=l?l:`transcript-${o.name}-${(new Date).toISOString().split("T")[0]}.html`,messageCount:u.length}}function t(e){var i,n,a,r,d,l,s;return{id:e.id,type:e.type,content:e.content,author:{id:e.author.id,username:e.author.username,globalName:e.author.globalName,avatar:e.author.avatar,bot:e.author.bot,discriminator:e.author.discriminator},timestamp:e.createdAt.toISOString(),editedTimestamp:null!==(n=null===(i=e.editedAt)||void 0===i?void 0:i.toISOString())&&void 0!==n?n:null,pinned:e.pinned,webhookId:e.webhookId,mentions:e.mentions.users.map(e=>({id:e.id,username:e.username})),attachments:e.attachments.map(e=>({id:e.id,filename:e.name,description:e.description,contentType:e.contentType,size:e.size,url:e.url,width:e.width,height:e.height,spoiler:e.spoiler})),embeds:e.embeds.map(e=>{var i,t,o,n,a;return{title:null!==(i=e.title)&&void 0!==i?i:void 0,type:e.data.type,description:null!==(t=e.description)&&void 0!==t?t:void 0,url:null!==(o=e.url)&&void 0!==o?o:void 0,timestamp:null!==(n=e.timestamp)&&void 0!==n?n:void 0,color:null!==(a=e.color)&&void 0!==a?a:void 0,footer:e.footer?{text:e.footer.text,iconUrl:e.footer.iconURL}:void 0,image:e.image?{url:e.image.url,width:e.image.width,height:e.image.height}:void 0,thumbnail:e.thumbnail?{url:e.thumbnail.url,width:e.thumbnail.width,height:e.thumbnail.height}:void 0,video:e.video?{url:e.video.url,proxyUrl:e.video.proxyURL,width:e.video.width,height:e.video.height}:void 0,provider:e.provider?{name:e.provider.name,url:e.provider.url}:void 0,author:e.author?{name:e.author.name,url:e.author.url,iconUrl:e.author.iconURL}:void 0,fields:e.fields.map(e=>({name:e.name,value:e.value,inline:e.inline}))}}),reactions:e.reactions.cache.map(e=>{var i,t;return{emoji:{id:e.emoji.id,name:null!==(i=e.emoji.name)&&void 0!==i?i:"❓",animated:null!==(t=e.emoji.animated)&&void 0!==t?t:0},count:e.count}}),messageReference:e.reference?{messageId:null!==(a=e.reference.messageId)&&void 0!==a?a:void 0,channelId:null!==(r=e.reference.channelId)&&void 0!==r?r:void 0,guildId:null!==(d=e.reference.guildId)&&void 0!==d?d:void 0}:void 0,referencedMessage:(null===(l=e.reference)||void 0===l?void 0:l.messageId)&&e.channel.messages.cache.has(e.reference.messageId)?t(e.channel.messages.cache.get(e.reference.messageId)):void 0,stickers:e.stickers.map(e=>({id:e.id,name:e.name,formatType:e.format,url:e.url})),thread:e.thread?{id:e.thread.id,name:e.thread.name,messageCount:null!==(s=e.thread.messageCount)&&void 0!==s?s:void 0}:void 0,components:e.components.map(e=>o(e.toJSON()))}}function o(e){var i,t,n,a;const r={type:e.type};return void 0!==e.style&&(r.style=e.style),e.label&&(r.label=e.label),e.custom_id&&(r.customId=e.custom_id),e.url&&(r.url=e.url),e.disabled&&(r.disabled=e.disabled),e.emoji&&(r.emoji={id:null!==(i=e.emoji.id)&&void 0!==i?i:void 0,name:null!==(t=e.emoji.name)&&void 0!==t?t:"",animated:null!==(n=e.emoji.animated)&&void 0!==n?n:0}),e.content&&(r.content=e.content),void 0!==e.accent_color&&(r.accentColor=e.accent_color),e.spoiler&&(r.spoiler=e.spoiler),e.accessory&&(r.accessory={type:e.accessory.type,media:e.accessory.media,description:e.accessory.description,spoiler:e.accessory.spoiler}),e.items&&(r.items=e.items.map(e=>({media:e.media,description:e.description,spoiler:e.spoiler}))),e.file&&(r.file={url:e.file.url,contentType:e.file.content_type}),void 0!==e.spacing&&(r.spacing=e.spacing),void 0!==e.divider&&(r.divider=e.divider),e.media&&(r.media={url:e.media.url}),e.description&&(r.description=e.description),(null===(a=e.components)||void 0===a?void 0:a.length)&&(r.components=e.components.map(o)),r}
|
package/dist/lib/markdown.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"sanitize-html";const t={allowedTags:[(String.fromCharCode(115,116,114,111,110,103)),"em","u","s",(String.fromCharCode(99,111,100,101)),(String.fromCharCode(112,114,101)),"br",(String.fromCharCode(115,112,97,110)),(String.fromCharCode(100,105,118)),(String.fromCharCode(98,108,111,99,107,113,117,111,116,101)),"h1","h2","h3","ul","ol","li","a",(String.fromCharCode(105,109,103))],allowedAttributes:{span:[(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(100,97,116,97,45,42)),(String.fromCharCode(115,116,121,108,101))],div:[(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(100,97,116,97,45,42))],a:[(String.fromCharCode(104,114,101,102)),(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(116,97,114,103,101,116)),(String.fromCharCode(114,101,108))],code:[(String.fromCharCode(99,108,97,115,115))],pre:[(String.fromCharCode(99,108,97,115,115))],img:[(String.fromCharCode(115,114,99)),(String.fromCharCode(97,108,116)),(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(119,105,100,116,104)),(String.fromCharCode(104,101,105,103,104,116)),(String.fromCharCode(108,111,97,100,105,110,103))],blockquote:[(String.fromCharCode(99,108,97,115,115))]},allowedStyles:{span:{color:[/^#[0-9a-fA-F]{6}$/],"background-color":[/^rgba\(\d{1,3},\d{1,3},\d{1,3},[\d.]+\)$/]}},allowedSchemes:[(String.fromCharCode(104,116,116,112,115)),(String.fromCharCode(104,116,116,112))]};function r(e){return e.replace(/&/g,(String.fromCharCode(38,97,109,112,59))).replace(/</g,(String.fromCharCode(38,108,116,59))).replace(/>/g,(String.fromCharCode(38,103,116,59))).replace(/"/g,(String.fromCharCode(38,113,117,111,116,59))).replace(/'/g,(String.fromCharCode(38,35,48,51,57,59)))}export function parseDiscordMarkdown(n,a,l,s){if(!n)return"";let i=r(n);const c=[];return i=i.replace(/```(\w+\n)?([\s\S]*?)```/g,(e,t,o)=>{const n=null==t?void 0:t.trim(),a=n?` class="language-${r(n)}"`:"",l=c.length;return c.push(`<pre class="discord-code-block"><code${a}>${o}</code></pre>`),`${l}`}),i=i.replace(/`([^`\n]+)`/g,(e,t)=>{const r=c.length;return c.push(`<code class="discord-inline-code">${t}</code>`),`${r}`}),i=i.replace(/^### (.+)$/gm,(String.fromCharCode(60,104,51,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,104,101,97,100,101,114,34,62,36,49,60,47,104,51,62))),i=i.replace(/^## (.+)$/gm,(String.fromCharCode(60,104,50,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,104,101,97,100,101,114,34,62,36,49,60,47,104,50,62))),i=i.replace(/^# (.+)$/gm,(String.fromCharCode(60,104,49,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,104,101,97,100,101,114,34,62,36,49,60,47,104,49,62))),i=i.replace(/^>>> ([\s\S]+)$/gm,(String.fromCharCode(60,98,108,111,99,107,113,117,111,116,101,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,98,108,111,99,107,113,117,111,116,101,34,62,36,49,60,47,98,108,111,99,107,113,117,111,116,101,62))),i=i.replace(/^> (.+)$/gm,(String.fromCharCode(60,98,108,111,99,107,113,117,111,116,101,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,98,108,111,99,107,113,117,111,116,101,34,62,36,49,60,47,98,108,111,99,107,113,117,111,116,101,62))),i=i.replace(/^- (.+)$/gm,(String.fromCharCode(60,108,105,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,108,105,115,116,45,105,116,101,109,34,62,36,49,60,47,108,105,62))),i=i.replace(/\*\*\*(.+?)\*\*\*/g,(String.fromCharCode(60,115,116,114,111,110,103,62,60,101,109,62,36,49,60,47,101,109,62,60,47,115,116,114,111,110,103,62))),i=i.replace(/\*\*(.+?)\*\*/g,(String.fromCharCode(60,115,116,114,111,110,103,62,36,49,60,47,115,116,114,111,110,103,62))),i=i.replace(/__(.+?)__/g,(String.fromCharCode(60,117,62,36,49,60,47,117,62))),i=i.replace(/\*(.+?)\*/g,(String.fromCharCode(60,101,109,62,36,49,60,47,101,109,62))),i=i.replace(/(?<!\w)_(.+?)_(?!\w)/g,(String.fromCharCode(60,101,109,62,36,49,60,47,101,109,62))),i=i.replace(/~~(.+?)~~/g,(String.fromCharCode(60,115,62,36,49,60,47,115,62))),i=i.replace(/\|\|(.+?)\|\|/g,(String.fromCharCode(60,115,112,97,110,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,115,112,111,105,108,101,114,34,32,100,97,116,97,45,115,112,111,105,108,101,114,61,34,116,114,117,101,34,62,36,49,60,47,115,112,97,110,62))),i=i.replace(/\[([^\]]+)\]\((<)?((https?:\/\/)[^\s)]+?)(>)?\)/g,(String.fromCharCode(60,97,32,104,114,101,102,61,34,36,51,34,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,108,105,110,107,34,32,116,97,114,103,101,116,61,34,95,98,108,97,110,107,34,32,114,101,108,61,34,110,111,111,112,101,110,101,114,32,110,111,114,101,102,101,114,114,101,114,34,62,36,49,60,47,97,62))),i=i.replace(/(?<![="'])(https?:\/\/[^\s<]+)/g,(String.fromCharCode(60,97,32,104,114,101,102,61,34,36,49,34,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,108,105,110,107,34,32,116,97,114,103,101,116,61,34,95,98,108,97,110,107,34,32,114,101,108,61,34,110,111,111,112,101,110,101,114,32,110,111,114,101,102,101,114,114,101,114,34,62,36,49,60,47,97,62))),i=i.replace(/<@!?(\d+)>/g,(e,t)=>{var o;const n=null==s?void 0:s.find(e=>e.id===t),a=null!==(o=null==n?void 0:n.username)&&void 0!==o?o:(String.fromCharCode(85,110,107,110,111,119,110,32,85,115,101,114));return`<span class="discord-mention" data-mention-type="user" data-mention-id="${r(t)}">@${r(a)}</span>`}),i=i.replace(/<@&(\d+)>/g,(e,t)=>{var o;const n=null==a?void 0:a[t],l=null!==(o=null==n?void 0:n.name)&&void 0!==o?o:(String.fromCharCode(85,110,107,110,111,119,110,32,82,111,108,101));let s="";return(null==n?void 0:n.color)&&(s=` style="color:#${n.color.toString(16).padStart(6,"0")};background-color:rgba(${n.color>>16&255},${n.color>>8&255},${255&n.color},0.1)"`),`<span class="discord-mention discord-role-mention" data-mention-type="role" data-mention-id="${r(t)}"${s}>@${r(l)}</span>`}),i=i.replace(/<#(\d+)>/g,(e,t)=>{var o;const n=null==l?void 0:l[t],a=null!==(o=null==n?void 0:n.name)&&void 0!==o?o:(String.fromCharCode(117,110,107,110,111,119,110,45,99,104,97,110,110,101,108));return`<span class="discord-mention" data-mention-type="channel" data-mention-id="${r(t)}">#${r(a)}</span>`}),i=i.replace(/@(everyone|here)/g,(String.fromCharCode(60,115,112,97,110,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,109,101,110,116,105,111,110,32,100,105,115,99,111,114,100,45,109,101,110,116,105,111,110,45,101,118,101,114,121,111,110,101,34,62,64,36,49,60,47,115,112,97,110,62))),i=i.replace(/<(a?):(\w+):(\d+)>/g,(e,t,o,n)=>`<img src="https://cdn.discordapp.com/emojis/${n}.${t?"gif":"webp"}?size=48&quality=lossless" alt=":${r(o)}:" class="discord-custom-emoji" width="22" height="22" loading="lazy" />`),i=i.replace(/<t:(\d+)(?::([tTdDfFR]))?>/g,(e,t,n)=>{const a=(function(e,t){switch(t){case"t":return e.toLocaleTimeString((String.fromCharCode(101,110,45,85,83)),{hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});case"T":return e.toLocaleTimeString((String.fromCharCode(101,110,45,85,83)),{hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116)),second:(String.fromCharCode(50,45,100,105,103,105,116))});case"d":return e.toLocaleDateString((String.fromCharCode(101,110,45,85,83)));case"D":return e.toLocaleDateString((String.fromCharCode(101,110,45,85,83)),{day:(String.fromCharCode(110,117,109,101,114,105,99)),month:(String.fromCharCode(108,111,110,103)),year:(String.fromCharCode(110,117,109,101,114,105,99))});case"f":return e.toLocaleString((String.fromCharCode(101,110,45,85,83)),{day:(String.fromCharCode(110,117,109,101,114,105,99)),month:(String.fromCharCode(108,111,110,103)),year:(String.fromCharCode(110,117,109,101,114,105,99)),hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});case"F":return e.toLocaleString((String.fromCharCode(101,110,45,85,83)),{weekday:(String.fromCharCode(108,111,110,103)),day:(String.fromCharCode(110,117,109,101,114,105,99)),month:(String.fromCharCode(108,111,110,103)),year:(String.fromCharCode(110,117,109,101,114,105,99)),hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});case"R":return o(e);default:return e.toLocaleString((String.fromCharCode(101,110,45,85,83)))}})(new Date(1e3*parseInt(t)),n||"f");return`<span class="discord-timestamp">${r(a)}</span>`}),i=i.replace(/\n/g,(String.fromCharCode(60,98,114,32,47,62))),c.length>0&&(i=i.replace(/\uE000(\d+)\uE001/g,(e,t)=>c[parseInt(t)])),e(i,t)}function o(e){const t=Date.now()-e.getTime(),r=Math.abs(t),o=t>0,n=Math.floor(r/1e3),a=Math.floor(n/60),l=Math.floor(a/60),s=Math.floor(l/24),i=Math.floor(s/30),c=Math.floor(s/365);let d,g;c>0?(d=(String.fromCharCode(121,101,97,114)),g=c):i>0?(d=(String.fromCharCode(109,111,110,116,104)),g=i):s>0?(d=(String.fromCharCode(100,97,121)),g=s):l>0?(d=(String.fromCharCode(104,111,117,114)),g=l):a>0?(d=(String.fromCharCode(109,105,110,117,116,101)),g=a):(d=(String.fromCharCode(115,101,99,111,110,100)),g=n);const u=1!==g?"s":"";return o?`${g} ${d}${u} ago`:`in ${g} ${d}${u}`}export function formatMessageTimestamp(e,t=(String.fromCharCode(97,98,115,111,108,117,116,101))){const r=new Date(e),n=r.toLocaleString((String.fromCharCode(101,110,45,85,83)),{month:(String.fromCharCode(50,45,100,105,103,105,116)),day:(String.fromCharCode(50,45,100,105,103,105,116)),year:(String.fromCharCode(110,117,109,101,114,105,99)),hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});switch(t){case"relative":return o(r);case"both":return`${n} (${o(r)})`;default:return n}}export function getAvatarUrl(e,t,r){if(t){const r=t.startsWith("a_")?"gif":(String.fromCharCode(119,101,98,112));return`https://cdn.discordapp.com/avatars/${e}/${t}.${r}?size=128`}return`https://cdn.discordapp.com/embed/avatars/${r?parseInt(r)%5:(BigInt(e)>>BigInt(22))%BigInt(6)}.png`}export function colorIntToHex(e){return`#${e.toString(16).padStart(6,"0")}`}export function formatFileSize(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}export function isImageAttachment(e){return!!(null==e?void 0:e.startsWith((String.fromCharCode(105,109,97,103,101,47))))}export function isVideoAttachment(e){return!!(null==e?void 0:e.startsWith((String.fromCharCode(118,105,100,101,111,47))))}export function isAudioAttachment(e){return!!(null==e?void 0:e.startsWith((String.fromCharCode(97,117,100,105,111,47))))}
|
|
1
|
+
import e from"sanitize-html";const t={allowedTags:[(String.fromCharCode(115,116,114,111,110,103)),"em","u","s",(String.fromCharCode(99,111,100,101)),(String.fromCharCode(112,114,101)),"br",(String.fromCharCode(115,112,97,110)),(String.fromCharCode(100,105,118)),(String.fromCharCode(98,108,111,99,107,113,117,111,116,101)),"h1","h2","h3","ul","ol","li","a",(String.fromCharCode(105,109,103))],allowedAttributes:{span:[(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(100,97,116,97,45,42)),(String.fromCharCode(115,116,121,108,101))],div:[(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(100,97,116,97,45,42))],a:[(String.fromCharCode(104,114,101,102)),(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(116,97,114,103,101,116)),(String.fromCharCode(114,101,108))],code:[(String.fromCharCode(99,108,97,115,115))],pre:[(String.fromCharCode(99,108,97,115,115))],img:[(String.fromCharCode(115,114,99)),(String.fromCharCode(97,108,116)),(String.fromCharCode(99,108,97,115,115)),(String.fromCharCode(119,105,100,116,104)),(String.fromCharCode(104,101,105,103,104,116)),(String.fromCharCode(108,111,97,100,105,110,103))],blockquote:[(String.fromCharCode(99,108,97,115,115))],ul:[(String.fromCharCode(99,108,97,115,115))],li:[(String.fromCharCode(99,108,97,115,115))]},allowedStyles:{span:{color:[/^#[0-9a-fA-F]{6}$/],"background-color":[/^rgba\(\d{1,3},\d{1,3},\d{1,3},[\d.]+\)$/]}},allowedSchemes:[(String.fromCharCode(104,116,116,112,115)),(String.fromCharCode(104,116,116,112))]};function r(e){return e.replace(/&/g,(String.fromCharCode(38,97,109,112,59))).replace(/</g,(String.fromCharCode(38,108,116,59))).replace(/>/g,(String.fromCharCode(38,103,116,59))).replace(/"/g,(String.fromCharCode(38,113,117,111,116,59))).replace(/'/g,(String.fromCharCode(38,35,48,51,57,59)))}export function parseDiscordMarkdown(n,a,l,s){if(!n)return"";let i=r(n);const c=[];return i=i.replace(/```(\w+\n)?([\s\S]*?)```/g,(e,t,o)=>{const n=null==t?void 0:t.trim(),a=!t&&o.startsWith("\n")?o.slice(1):o,l=n?` class="language-${r(n)}"`:"",s=c.length;return c.push(`<pre class="discord-code-block"><code${l}>${a}</code></pre>`),`${s}`}),i=i.replace(/`([^`\n]+)`/g,(e,t)=>{const r=c.length;return c.push(`<code class="discord-inline-code">${t}</code>`),`${r}`}),i=i.replace(/^### (.+)$/gm,(String.fromCharCode(60,104,51,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,104,101,97,100,101,114,34,62,36,49,60,47,104,51,62))),i=i.replace(/^## (.+)$/gm,(String.fromCharCode(60,104,50,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,104,101,97,100,101,114,34,62,36,49,60,47,104,50,62))),i=i.replace(/^# (.+)$/gm,(String.fromCharCode(60,104,49,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,104,101,97,100,101,114,34,62,36,49,60,47,104,49,62))),i=i.replace(/^>>> ([\s\S]+)$/gm,(String.fromCharCode(60,98,108,111,99,107,113,117,111,116,101,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,98,108,111,99,107,113,117,111,116,101,34,62,36,49,60,47,98,108,111,99,107,113,117,111,116,101,62))),i=i.replace(/^> (.+)$/gm,(String.fromCharCode(60,98,108,111,99,107,113,117,111,116,101,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,98,108,111,99,107,113,117,111,116,101,34,62,36,49,60,47,98,108,111,99,107,113,117,111,116,101,62))),i=i.replace(/(^- .+$(?:\n^- .+$)*)/gm,e=>`<ul class="discord-list">${e.split("\n").map(e=>e.replace(/^- (.+)$/,'<li class="discord-list-item">$1</li>')).join("")}</ul>`),i=i.replace(/\*\*\*(.+?)\*\*\*/g,(String.fromCharCode(60,115,116,114,111,110,103,62,60,101,109,62,36,49,60,47,101,109,62,60,47,115,116,114,111,110,103,62))),i=i.replace(/\*\*(.+?)\*\*/g,(String.fromCharCode(60,115,116,114,111,110,103,62,36,49,60,47,115,116,114,111,110,103,62))),i=i.replace(/__(.+?)__/g,(String.fromCharCode(60,117,62,36,49,60,47,117,62))),i=i.replace(/\*(.+?)\*/g,(String.fromCharCode(60,101,109,62,36,49,60,47,101,109,62))),i=i.replace(/(?<!\w)_(.+?)_(?!\w)/g,(String.fromCharCode(60,101,109,62,36,49,60,47,101,109,62))),i=i.replace(/~~(.+?)~~/g,(String.fromCharCode(60,115,62,36,49,60,47,115,62))),i=i.replace(/\|\|(.+?)\|\|/g,(String.fromCharCode(60,115,112,97,110,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,115,112,111,105,108,101,114,34,32,100,97,116,97,45,115,112,111,105,108,101,114,61,34,116,114,117,101,34,62,36,49,60,47,115,112,97,110,62))),i=i.replace(/\[([^\]]+)\]\((<)?((https?:\/\/)[^\s)]+?)(>)?\)/g,(String.fromCharCode(60,97,32,104,114,101,102,61,34,36,51,34,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,108,105,110,107,34,32,116,97,114,103,101,116,61,34,95,98,108,97,110,107,34,32,114,101,108,61,34,110,111,111,112,101,110,101,114,32,110,111,114,101,102,101,114,114,101,114,34,62,36,49,60,47,97,62))),i=i.replace(/(?<![="'])(https?:\/\/[^\s<]+)/g,(String.fromCharCode(60,97,32,104,114,101,102,61,34,36,49,34,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,108,105,110,107,34,32,116,97,114,103,101,116,61,34,95,98,108,97,110,107,34,32,114,101,108,61,34,110,111,111,112,101,110,101,114,32,110,111,114,101,102,101,114,114,101,114,34,62,36,49,60,47,97,62))),i=i.replace(/<@!?(\d+)>/g,(e,t)=>{var o;const n=null==s?void 0:s.find(e=>e.id===t),a=null!==(o=null==n?void 0:n.username)&&void 0!==o?o:(String.fromCharCode(85,110,107,110,111,119,110,32,85,115,101,114));return`<span class="discord-mention" data-mention-type="user" data-mention-id="${r(t)}">@${r(a)}</span>`}),i=i.replace(/<@&(\d+)>/g,(e,t)=>{var o;const n=null==a?void 0:a[t],l=null!==(o=null==n?void 0:n.name)&&void 0!==o?o:(String.fromCharCode(85,110,107,110,111,119,110,32,82,111,108,101));let s="";return(null==n?void 0:n.color)&&(s=` style="color:#${n.color.toString(16).padStart(6,"0")};background-color:rgba(${n.color>>16&255},${n.color>>8&255},${255&n.color},0.1)"`),`<span class="discord-mention discord-role-mention" data-mention-type="role" data-mention-id="${r(t)}"${s}>@${r(l)}</span>`}),i=i.replace(/<#(\d+)>/g,(e,t)=>{var o;const n=null==l?void 0:l[t],a=null!==(o=null==n?void 0:n.name)&&void 0!==o?o:(String.fromCharCode(117,110,107,110,111,119,110,45,99,104,97,110,110,101,108));return`<span class="discord-mention" data-mention-type="channel" data-mention-id="${r(t)}">#${r(a)}</span>`}),i=i.replace(/@(everyone|here)/g,(String.fromCharCode(60,115,112,97,110,32,99,108,97,115,115,61,34,100,105,115,99,111,114,100,45,109,101,110,116,105,111,110,32,100,105,115,99,111,114,100,45,109,101,110,116,105,111,110,45,101,118,101,114,121,111,110,101,34,62,64,36,49,60,47,115,112,97,110,62))),i=i.replace(/<(a?):(\w+):(\d+)>/g,(e,t,o,n)=>`<img src="https://cdn.discordapp.com/emojis/${n}.${t?"gif":"webp"}?size=48&quality=lossless" alt=":${r(o)}:" class="discord-custom-emoji" width="22" height="22" loading="lazy" />`),i=i.replace(/<t:(\d+)(?::([tTdDfFR]))?>/g,(e,t,n)=>{const a=(function(e,t){switch(t){case"t":return e.toLocaleTimeString((String.fromCharCode(101,110,45,85,83)),{hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});case"T":return e.toLocaleTimeString((String.fromCharCode(101,110,45,85,83)),{hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116)),second:(String.fromCharCode(50,45,100,105,103,105,116))});case"d":return e.toLocaleDateString((String.fromCharCode(101,110,45,85,83)));case"D":return e.toLocaleDateString((String.fromCharCode(101,110,45,85,83)),{day:(String.fromCharCode(110,117,109,101,114,105,99)),month:(String.fromCharCode(108,111,110,103)),year:(String.fromCharCode(110,117,109,101,114,105,99))});case"f":return e.toLocaleString((String.fromCharCode(101,110,45,85,83)),{day:(String.fromCharCode(110,117,109,101,114,105,99)),month:(String.fromCharCode(108,111,110,103)),year:(String.fromCharCode(110,117,109,101,114,105,99)),hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});case"F":return e.toLocaleString((String.fromCharCode(101,110,45,85,83)),{weekday:(String.fromCharCode(108,111,110,103)),day:(String.fromCharCode(110,117,109,101,114,105,99)),month:(String.fromCharCode(108,111,110,103)),year:(String.fromCharCode(110,117,109,101,114,105,99)),hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});case"R":return o(e);default:return e.toLocaleString((String.fromCharCode(101,110,45,85,83)))}})(new Date(1e3*parseInt(t)),n||"f");return`<span class="discord-timestamp">${r(a)}</span>`}),i=i.replace(/\n/g,(String.fromCharCode(60,98,114,32,47,62))),c.length>0&&(i=i.replace(/\uE000(\d+)\uE001/g,(e,t)=>c[parseInt(t)])),e(i,t)}function o(e){const t=Date.now()-e.getTime(),r=Math.abs(t),o=t>0,n=Math.floor(r/1e3),a=Math.floor(n/60),l=Math.floor(a/60),s=Math.floor(l/24),i=Math.floor(s/30),c=Math.floor(s/365);let d,u;c>0?(d=(String.fromCharCode(121,101,97,114)),u=c):i>0?(d=(String.fromCharCode(109,111,110,116,104)),u=i):s>0?(d=(String.fromCharCode(100,97,121)),u=s):l>0?(d=(String.fromCharCode(104,111,117,114)),u=l):a>0?(d=(String.fromCharCode(109,105,110,117,116,101)),u=a):(d=(String.fromCharCode(115,101,99,111,110,100)),u=n);const g=1!==u?"s":"";return o?`${u} ${d}${g} ago`:`in ${u} ${d}${g}`}export function formatMessageTimestamp(e,t=(String.fromCharCode(97,98,115,111,108,117,116,101))){const r=new Date(e),n=r.toLocaleString((String.fromCharCode(101,110,45,85,83)),{month:(String.fromCharCode(50,45,100,105,103,105,116)),day:(String.fromCharCode(50,45,100,105,103,105,116)),year:(String.fromCharCode(110,117,109,101,114,105,99)),hour:(String.fromCharCode(50,45,100,105,103,105,116)),minute:(String.fromCharCode(50,45,100,105,103,105,116))});switch(t){case"relative":return o(r);case"both":return`${n} (${o(r)})`;default:return n}}export function getAvatarUrl(e,t,r){if(t){const r=t.startsWith("a_")?"gif":(String.fromCharCode(119,101,98,112));return`https://cdn.discordapp.com/avatars/${e}/${t}.${r}?size=128`}return`https://cdn.discordapp.com/embed/avatars/${r?parseInt(r)%5:(BigInt(e)>>BigInt(22))%BigInt(6)}.png`}export function colorIntToHex(e){return`#${e.toString(16).padStart(6,"0")}`}export function formatFileSize(e){return e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:e<1073741824?`${(e/1048576).toFixed(1)} MB`:`${(e/1073741824).toFixed(1)} GB`}export function isImageAttachment(e){return!!(null==e?void 0:e.startsWith((String.fromCharCode(105,109,97,103,101,47))))}export function isVideoAttachment(e){return!!(null==e?void 0:e.startsWith((String.fromCharCode(118,105,100,101,111,47))))}export function isAudioAttachment(e){return!!(null==e?void 0:e.startsWith((String.fromCharCode(97,117,100,105,111,47))))}
|
package/dist/types/discord.d.ts
CHANGED
|
@@ -200,6 +200,10 @@ export interface DiscordComponent {
|
|
|
200
200
|
spacing?: number;
|
|
201
201
|
/** Whether Separator shows a divider line */
|
|
202
202
|
divider?: boolean;
|
|
203
|
+
/** Media reference for Thumbnail (type 11) */
|
|
204
|
+
media?: {
|
|
205
|
+
url: string;
|
|
206
|
+
};
|
|
203
207
|
/** Description for Thumbnail (type 11) */
|
|
204
208
|
description?: string;
|
|
205
209
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@getoeteter/discord-transcripts",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Discord.js HTML transcript generator",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"build": "tsc && node scripts/obfuscate.mjs",
|
|
18
18
|
"typecheck": "tsc --noEmit",
|
|
19
19
|
"clean": "rm -rf dist",
|
|
20
|
-
"prepublishOnly": "
|
|
20
|
+
"prepublishOnly": "bun run clean && bun run build"
|
|
21
21
|
},
|
|
22
22
|
"keywords": [
|
|
23
23
|
"discord",
|