discord-html-transcripts-fix 1.8.0 → 1.8.2

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.
@@ -138,9 +138,17 @@ async function DiscordMessage({ message, context }) {
138
138
  // no longer render a separate "/cmd opt:val by user" line.
139
139
  const slashData = buildSlashCommandData(message);
140
140
 
141
+ // FIX: pass timestamp as ISO string. React would otherwise stringify a
142
+ // Date via toString() (locale-dependent like "Tue May 26 2026 …"),
143
+ // which skyra's <discord-message> often fails to parse — falling back
144
+ // to new Date() == transcript creation time. ISO is round-trip safe.
145
+ const createdAtIso = message.createdAt instanceof Date
146
+ ? message.createdAt.toISOString()
147
+ : (typeof message.createdAt === 'string' ? message.createdAt : undefined);
148
+
141
149
  return ((0, jsx_runtime_1.jsxs)("discord-message", {
142
150
  id: `m-${message.id}`,
143
- timestamp: message.createdAt,
151
+ timestamp: createdAtIso,
144
152
  edited: message.editedAt !== null,
145
153
  server: (isCrossGuildReply || isCrosspost || isCrossposted) ? true : undefined,
146
154
  highlight: message.mentions.everyone || pinned,
@@ -18,11 +18,16 @@ async function SystemMessage({ message, context }) {
18
18
  const color = message.member?.roles?.color?.hexColor;
19
19
  const authorId = author?.id;
20
20
  const ctx = context || {};
21
+ // FIX: pass message.createdAt as ISO string so skyra renders the original
22
+ // timestamp instead of falling back to "now" (= transcript creation time).
23
+ const ts = message.createdAt instanceof Date
24
+ ? message.createdAt.toISOString()
25
+ : (typeof message.createdAt === 'string' ? message.createdAt : undefined);
21
26
 
22
27
  switch (message.type) {
23
28
  case discord_js_1.MessageType.RecipientAdd:
24
29
  case discord_js_1.MessageType.UserJoin:
25
- return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, type: "join", children: (0, jsx_runtime_1.jsx)(JoinMessage, { member: message.member, fallbackUser: author, seed: message.id, context: ctx }) }, message.id));
30
+ return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "join", children: (0, jsx_runtime_1.jsx)(JoinMessage, { member: message.member, fallbackUser: author, seed: message.id, context: ctx }) }, message.id));
26
31
 
27
32
  case discord_js_1.MessageType.ChannelPinnedMessage: {
28
33
  const refId = message.reference?.messageId;
@@ -36,7 +41,7 @@ async function SystemMessage({ message, context }) {
36
41
  ? (0, jsx_runtime_1.jsx)("i", { "data-goto": refId, className: "dht-jump", role: "button", tabIndex: 0, children: linkLabel })
37
42
  : (0, jsx_runtime_1.jsx)("strong", { children: linkLabel });
38
43
  const parts = template.includes('{message}') ? template.split('{message}') : null;
39
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "pin", children: parts
44
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "pin", children: parts
40
45
  ? [
41
46
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
42
47
  ' ',
@@ -57,7 +62,7 @@ async function SystemMessage({ message, context }) {
57
62
  case discord_js_1.MessageType.GuildBoostTier1:
58
63
  case discord_js_1.MessageType.GuildBoostTier2:
59
64
  case discord_js_1.MessageType.GuildBoostTier3:
60
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
65
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "boost", children: [
61
66
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
62
67
  ' ',
63
68
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "boosted", children: t(ctx, 'boosted', 'boosted the server!') }),
@@ -67,7 +72,7 @@ async function SystemMessage({ message, context }) {
67
72
  case discord_js_1.MessageType.ThreadCreated: {
68
73
  const refId = message.reference?.messageId;
69
74
  const label = message.content || 'New thread';
70
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "thread", children: [
75
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "thread", children: [
71
76
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
72
77
  ' ',
73
78
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "threadStarted", children: t(ctx, 'threadStarted', 'started a thread:') }),
@@ -79,7 +84,7 @@ async function SystemMessage({ message, context }) {
79
84
  }
80
85
 
81
86
  case discord_js_1.MessageType.ChannelNameChange:
82
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: [
87
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "edit", children: [
83
88
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
84
89
  ' ',
85
90
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "changedChannelName", children: t(ctx, 'changedChannelName', 'changed the channel name:') }),
@@ -88,7 +93,7 @@ async function SystemMessage({ message, context }) {
88
93
  ] }, message.id));
89
94
 
90
95
  case discord_js_1.MessageType.ChannelIconChange:
91
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: [
96
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "edit", children: [
92
97
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
93
98
  ' ',
94
99
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "changedChannelIcon", children: t(ctx, 'changedChannelIcon', 'changed the channel icon.') }),
@@ -97,7 +102,7 @@ async function SystemMessage({ message, context }) {
97
102
  case discord_js_1.MessageType.ChatInputCommand:
98
103
  case discord_js_1.MessageType.ContextMenuCommand: {
99
104
  const cmd = message.interaction?.commandName ? '/' + message.interaction.commandName : 'a command';
100
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
105
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "call", children: [
101
106
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
102
107
  ' ',
103
108
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "usedCommand", children: t(ctx, 'usedCommand', 'used') }),
@@ -107,7 +112,7 @@ async function SystemMessage({ message, context }) {
107
112
  }
108
113
 
109
114
  case discord_js_1.MessageType.Call:
110
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
115
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "call", children: [
111
116
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
112
117
  ' ',
113
118
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "startedCall", children: t(ctx, 'startedCall', 'started a call.') }),
@@ -116,7 +121,7 @@ async function SystemMessage({ message, context }) {
116
121
  case discord_js_1.MessageType.ChannelFollowAdd: {
117
122
  const followText = t(ctx, 'addedFollow', 'added {target} to follow this channel.');
118
123
  const parts = followText.split('{target}');
119
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: [
124
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "edit", children: [
120
125
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
121
126
  ' ',
122
127
  parts[0],
@@ -126,7 +131,7 @@ async function SystemMessage({ message, context }) {
126
131
  }
127
132
 
128
133
  case discord_js_1.MessageType.RecipientRemove:
129
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "leave", children: [
134
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "leave", children: [
130
135
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
131
136
  ' ',
132
137
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "left", children: t(ctx, 'left', 'left.') }),
@@ -141,7 +146,7 @@ async function SystemMessage({ message, context }) {
141
146
  const action = fields.find((f) => /action_type|action/i.test(f.name))?.value || '';
142
147
  const blocked = e?.description || '';
143
148
  const channelId = fields.find((f) => /channel/i.test(f.name))?.value;
144
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
149
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "boost", children: [
145
150
  (0, jsx_runtime_1.jsx)("span", { "data-i18n": "autoModBlocked", children: t(ctx, 'autoModBlocked', 'AutoMod blocked a message.') }),
146
151
  ruleName && (0, jsx_runtime_1.jsxs)("span", { className: "dht-automod-rule", children: [' · Rule: ', (0, jsx_runtime_1.jsx)("strong", { children: ruleName })] }),
147
152
  action && (0, jsx_runtime_1.jsxs)("span", { className: "dht-automod-rule", children: [' · Action: ', action] }),
@@ -151,34 +156,34 @@ async function SystemMessage({ message, context }) {
151
156
  ] }, message.id));
152
157
  }
153
158
  case discord_js_1.MessageType.StageStart:
154
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
159
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "call", children: [
155
160
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
156
161
  ' started a stage: ',
157
162
  (0, jsx_runtime_1.jsx)("strong", { children: message.content || '' })
158
163
  ] }, message.id));
159
164
  case discord_js_1.MessageType.StageEnd:
160
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "leave", children: [
165
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "leave", children: [
161
166
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
162
167
  ' ended the stage.'
163
168
  ] }, message.id));
164
169
  case discord_js_1.MessageType.StageSpeaker:
165
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
170
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "call", children: [
166
171
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
167
172
  ' is now a speaker.'
168
173
  ] }, message.id));
169
174
  case discord_js_1.MessageType.StageRaiseHand:
170
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
175
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "call", children: [
171
176
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
172
177
  ' requested to speak.'
173
178
  ] }, message.id));
174
179
  case discord_js_1.MessageType.StageTopic:
175
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: [
180
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "edit", children: [
176
181
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
177
182
  ' changed the stage topic: ',
178
183
  (0, jsx_runtime_1.jsx)("strong", { children: message.content || '' })
179
184
  ] }, message.id));
180
185
  case discord_js_1.MessageType.GuildApplicationPremiumSubscription:
181
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
186
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "boost", children: [
182
187
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
183
188
  ' subscribed ',
184
189
  (0, jsx_runtime_1.jsx)("strong", { children: message.applicationId ? `app ${message.applicationId}` : 'an app' }),
@@ -187,7 +192,7 @@ async function SystemMessage({ message, context }) {
187
192
 
188
193
  case discord_js_1.MessageType.RoleSubscriptionPurchase: {
189
194
  const roleName = message.roleSubscriptionData?.tierName || message.content || 'a role';
190
- return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
195
+ return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "boost", children: [
191
196
  (0, jsx_runtime_1.jsx)(Highlight, { color, userId: authorId, children: authorName }),
192
197
  ' ',
193
198
  t(ctx, 'roleSubPurchased', 'subscribed to {role}!').replace('{role}', roleName),
@@ -198,10 +203,10 @@ async function SystemMessage({ message, context }) {
198
203
  case discord_js_1.MessageType.GuildIncidentReportFalseAlarm:
199
204
  case discord_js_1.MessageType.GuildIncidentAlertModeEnabled:
200
205
  case discord_js_1.MessageType.GuildIncidentAlertModeDisabled:
201
- return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: (0, jsx_runtime_1.jsx)("span", { "data-i18n": "serverAlert", children: t(ctx, 'serverAlert', 'Server safety alert.') }) }, message.id));
206
+ return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "boost", children: (0, jsx_runtime_1.jsx)("span", { "data-i18n": "serverAlert", children: t(ctx, 'serverAlert', 'Server safety alert.') }) }, message.id));
202
207
 
203
208
  case discord_js_1.MessageType.PollResult:
204
- return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: (0, jsx_runtime_1.jsx)("span", { "data-i18n": "pollEnded", children: t(ctx, 'pollEnded', 'A poll ended.') }) }, message.id));
209
+ return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, timestamp: ts, type: "edit", children: (0, jsx_runtime_1.jsx)("span", { "data-i18n": "pollEnded", children: t(ctx, 'pollEnded', 'A poll ended.') }) }, message.id));
205
210
 
206
211
  // These render through the normal pipeline
207
212
  case discord_js_1.MessageType.Default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-html-transcripts-fix",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "A nicely formatted html transcript generator for discord.js. Bugfix fork with support for the latest discord.js and Components v2.",
5
5
  "main": "dist/index.js",
6
6
  "types": "./dist/index.d.ts",