discord-html-transcripts-fix 1.2.0 → 1.4.0

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.
@@ -98,6 +98,18 @@ async function buildAllContext(messages, channel) {
98
98
  : [];
99
99
  for (const r of memberRoles) includeRoleFromGuild(r.id);
100
100
 
101
+ // Collect user flag names (Staff, Partner, HypeSquad…)
102
+ const flagNames = [];
103
+ if (author.flags && typeof author.flags.has === 'function' && discord_js_1.UserFlags) {
104
+ for (const flagName of Object.keys(discord_js_1.UserFlags)) {
105
+ // Filter out numeric reverse-lookups
106
+ if (/^\d+$/.test(flagName)) continue;
107
+ try {
108
+ if (author.flags.has(discord_js_1.UserFlags[flagName])) flagNames.push(flagName);
109
+ } catch (_e) { /* ignore unknown flag */ }
110
+ }
111
+ }
112
+
101
113
  users[id] = {
102
114
  id,
103
115
  username: author.username,
@@ -107,6 +119,8 @@ async function buildAllContext(messages, channel) {
107
119
  bannerColor: member?.displayHexColor && member.displayHexColor !== '#000000' ? member.displayHexColor : null,
108
120
  bot: !!author.bot,
109
121
  system: !!author.system,
122
+ verifiedBot: flagNames.includes('VerifiedBot'),
123
+ flags: flagNames,
110
124
  joinedAt: member?.joinedAt ? member.joinedAt.toISOString() : null,
111
125
  createdAt: author.createdAt ? author.createdAt.toISOString() : null,
112
126
  roles: memberRoles.map((r) => ({
@@ -123,7 +137,11 @@ async function buildAllContext(messages, channel) {
123
137
 
124
138
  for (const message of messages) {
125
139
  if (message.author) includeUser(message.member, message.author);
126
- if (message.interaction?.user) includeUser(null, message.interaction.user);
140
+ if (message.interaction?.user) {
141
+ // FIX: try to find a member object for this user from later messages (interaction user may have authored their own messages elsewhere).
142
+ const memberMatch = message.interaction.member || (message.mentions?.members?.get?.(message.interaction.user.id)) || null;
143
+ includeUser(memberMatch, message.interaction.user);
144
+ }
127
145
  if (message.thread?.lastMessage?.author) {
128
146
  includeUser(message.thread.lastMessage.member, message.thread.lastMessage.author);
129
147
  }
@@ -76,7 +76,7 @@ function safeHref(url) {
76
76
  try {
77
77
  const u = new URL(url, 'https://example.invalid');
78
78
  const proto = u.protocol.toLowerCase();
79
- if (proto === 'http:' || proto === 'https:' || proto === 'mailto:' || proto === 'discord:') return url;
79
+ if (proto === 'http:' || proto === 'https:' || proto === 'mailto:') return url;
80
80
  return '#';
81
81
  } catch (_e) {
82
82
  return '#';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "discord-html-transcripts-fix",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
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",