discord-html-transcripts-fix 1.4.0 → 1.7.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.
package/dist/types.d.ts CHANGED
@@ -54,6 +54,20 @@ export type GenerateFromMessagesOptions<T extends ExportReturnType> = Partial<{
54
54
  * @default false - the returned html will be hydrated client-side
55
55
  */
56
56
  hydrate: boolean;
57
+ /**
58
+ * Stats footer rendered at the bottom (e.g. "12 messages · 3 participants · 2 images · …").
59
+ * - `false` to disable entirely
60
+ * - `{ enabled: false }` to disable
61
+ * - `{ template: '{messages} Nachrichten · {participants} Teilnehmer · {images} Bilder · {from} → {to} · {span}' }`
62
+ * to render with a custom string. Supported placeholders:
63
+ * `{messages}` `{participants}` `{images}` `{from}` `{to}` `{span}`
64
+ *
65
+ * Defaults to the localized "X messages · Y participants · …" string.
66
+ */
67
+ statsFooter: false | {
68
+ enabled?: boolean;
69
+ template?: string;
70
+ };
57
71
  }>;
58
72
  export type CreateTranscriptOptions<T extends ExportReturnType> = Partial<GenerateFromMessagesOptions<T> & {
59
73
  /**
@@ -79,25 +79,34 @@ async function buildAllContext(messages, channel) {
79
79
  if (seenUserIds.has(id)) return;
80
80
  seenUserIds.add(id);
81
81
 
82
+ // Compute member roles first so we can derive the name color from the
83
+ // highest *listed* role (top of the role list), matching how Discord
84
+ // colors usernames. Falls back to displayHexColor (highest *colored*
85
+ // role) and finally to null.
86
+ const memberRoles = member && member.roles && member.roles.cache
87
+ ? Array.from(member.roles.cache.values())
88
+ .filter((r) => r.id !== guild?.id)
89
+ .sort((a, b) => b.position - a.position)
90
+ : [];
91
+ for (const r of memberRoles) includeRoleFromGuild(r.id);
92
+
93
+ const topRoleHex = memberRoles[0]?.hexColor;
94
+ const displayHex = member?.displayHexColor;
95
+ const effectiveColor = (topRoleHex && topRoleHex !== '#000000')
96
+ ? topRoleHex
97
+ : (displayHex && displayHex !== '#000000' ? displayHex : null);
98
+
82
99
  // legacy profile (used by <discord-mention>)
83
100
  profiles[id] = {
84
101
  author: member?.nickname ?? author.displayName ?? author.username,
85
102
  avatar: member?.displayAvatarURL?.({ size: 64 }) ?? author.displayAvatarURL?.({ size: 64 }),
86
- roleColor: member?.displayHexColor,
103
+ roleColor: effectiveColor,
87
104
  roleIcon: member?.roles?.icon?.iconURL?.() ?? undefined,
88
105
  roleName: member?.roles?.hoist?.name ?? undefined,
89
106
  bot: !!author.bot,
90
107
  verified: author.flags?.has?.(discord_js_1.UserFlags.VerifiedBot) ?? false,
91
108
  };
92
109
 
93
- // extended record (used by popup)
94
- const memberRoles = member && member.roles && member.roles.cache
95
- ? Array.from(member.roles.cache.values())
96
- .filter((r) => r.id !== guild?.id)
97
- .sort((a, b) => b.position - a.position)
98
- : [];
99
- for (const r of memberRoles) includeRoleFromGuild(r.id);
100
-
101
110
  // Collect user flag names (Staff, Partner, HypeSquad…)
102
111
  const flagNames = [];
103
112
  if (author.flags && typeof author.flags.has === 'function' && discord_js_1.UserFlags) {
@@ -116,7 +125,7 @@ async function buildAllContext(messages, channel) {
116
125
  displayName: member?.nickname || author.displayName || author.username,
117
126
  globalName: author.globalName || null,
118
127
  avatar: member?.displayAvatarURL?.({ size: 128 }) || author.displayAvatarURL?.({ size: 128 }) || null,
119
- bannerColor: member?.displayHexColor && member.displayHexColor !== '#000000' ? member.displayHexColor : null,
128
+ bannerColor: effectiveColor,
120
129
  bot: !!author.bot,
121
130
  system: !!author.system,
122
131
  verifiedBot: flagNames.includes('VerifiedBot'),
package/package.json CHANGED
@@ -1,35 +1,26 @@
1
1
  {
2
2
  "name": "discord-html-transcripts-fix",
3
- "version": "1.4.0",
3
+ "version": "1.7.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",
7
7
  "license": "Apache-2.0",
8
+ "keywords": [
9
+ "discord",
10
+ "discord.js",
11
+ "transcript",
12
+ "html",
13
+ "logger",
14
+ "components-v2",
15
+ "ticket"
16
+ ],
8
17
  "files": [
9
18
  "dist/**/*.js",
10
19
  "dist/**/*.d.ts",
11
- "dist/**/*.js.map"
20
+ "dist/**/*.js.map",
21
+ "README.md",
22
+ "LICENSE"
12
23
  ],
13
- "devDependencies": {
14
- "@eslint/eslintrc": "^3.3.3",
15
- "@eslint/js": "^9.39.2",
16
- "@types/debug": "^4.1.12",
17
- "@types/node": "^24.10.4",
18
- "@types/react": "^19.2.7",
19
- "@types/react-dom": "^19.2.3",
20
- "@typescript-eslint/eslint-plugin": "^8.50.0",
21
- "@typescript-eslint/parser": "^8.50.0",
22
- "discord.js": "^14.25.1",
23
- "dotenv": "^17.2.3",
24
- "eslint": "^9.39.2",
25
- "globals": "^16.5.0",
26
- "husky": "^9.1.7",
27
- "prettier": "^3.7.4",
28
- "pretty-quick": "^4.2.2",
29
- "sharp": "^0.34.5",
30
- "ts-node": "^10.9.2",
31
- "typescript": "^5.9.3"
32
- },
33
24
  "dependencies": {
34
25
  "@lit-labs/ssr": "^3.3.1",
35
26
  "@skyra/discord-components-core": "^4.0.2",
@@ -46,12 +37,9 @@
46
37
  "discord.js": "^14.0.0 || ^15.0.0"
47
38
  },
48
39
  "scripts": {
49
- "test": "echo \"Error: no test specified\" && exit 1",
50
- "build": "tsc -p tsconfig.json",
51
- "test:typescript": "ts-node --project tsconfig.test.json ./tests/generate.ts",
52
- "test:send-components-v2": "ts-node ./tests/components-v2-send.ts",
53
- "lint": "prettier --write --cache . && eslint --cache --fix .",
54
- "typecheck": "tsc -p tsconfig.eslint.json"
40
+ "prepublishOnly": "node -e \"require('fs').accessSync('dist/index.js'); require('fs').accessSync('dist/index.d.ts');\" || (echo 'dist/index.js or dist/index.d.ts missing — refusing to publish' && exit 1)"
55
41
  },
56
- "author": ""
42
+ "publishConfig": {
43
+ "access": "public"
44
+ }
57
45
  }