discord-html-transcripts-fix 1.1.0 → 1.2.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/README.md +86 -78
- package/dist/downloader/images.js +60 -85
- package/dist/generator/index.js +194 -43
- package/dist/generator/renderers/attachment.js +27 -36
- package/dist/generator/renderers/components/Container.js +36 -14
- package/dist/generator/renderers/components/Media Gallery.js +24 -18
- package/dist/generator/renderers/components.js +7 -2
- package/dist/generator/renderers/content.js +48 -48
- package/dist/generator/renderers/embed.js +55 -34
- package/dist/generator/renderers/message.js +159 -46
- package/dist/generator/renderers/reply.js +47 -39
- package/dist/generator/renderers/systemMessage.js +131 -70
- package/dist/generator/transcript.js +42 -56
- package/dist/index.js +59 -84
- package/dist/static/client.js +216 -208
- package/dist/types.js +1 -0
- package/dist/utils/buildProfiles.js +51 -59
- package/dist/utils/utils.js +73 -26
- package/package.json +1 -1
|
@@ -1,53 +1,61 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
2
|
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
3
|
+
var ownKeys = function(o){ownKeys = Object.getOwnPropertyNames || function (o){var ar=[];for (var k in o) if (Object.prototype.hasOwnProperty.call(o,k)) ar[ar.length]=k;return ar;};return ownKeys(o);};
|
|
4
|
+
return function (mod){if (mod && mod.__esModule) return mod;var result={};if (mod != null) for (var k=ownKeys(mod), i=0; i<k.length; i++) if (k[i] !== "default") Object.defineProperty(result,k[i],{get:function(){return mod[k[i]];}});Object.defineProperty(result,"default",{value:mod,enumerable:true});return result;};
|
|
34
5
|
})();
|
|
35
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
7
|
exports.default = MessageReply;
|
|
37
8
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
9
|
const discord_js_1 = require("discord.js");
|
|
39
10
|
const content_1 = __importStar(require("./content"));
|
|
11
|
+
|
|
12
|
+
function t(context, key, fallback) {
|
|
13
|
+
const dict = context?.i18n?.[context?.lang] || context?.i18n?.en || {};
|
|
14
|
+
return dict[key] || fallback || key;
|
|
15
|
+
}
|
|
16
|
+
|
|
40
17
|
async function MessageReply({ message, context }) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
18
|
+
if (!message.reference) return null;
|
|
19
|
+
|
|
20
|
+
const isCrossGuild = message.reference.guildId !== message.guild?.id;
|
|
21
|
+
|
|
22
|
+
// Cross-guild reply: show a placeholder pill instead of silently dropping.
|
|
23
|
+
if (isCrossGuild) {
|
|
24
|
+
return (0, jsx_runtime_1.jsx)("discord-reply", {
|
|
25
|
+
slot: "reply",
|
|
26
|
+
server: true,
|
|
27
|
+
children: (0, jsx_runtime_1.jsx)("em", { "data-i18n": "crossServerReply", children: t(context, 'crossServerReply', 'Message from another server') })
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
46
31
|
const referencedMessage = context.messages.find((m) => m.id === message.reference.messageId);
|
|
47
32
|
if (!referencedMessage)
|
|
48
33
|
return (0, jsx_runtime_1.jsx)("discord-reply", { slot: "reply", children: "Message could not be loaded." });
|
|
49
|
-
|
|
34
|
+
|
|
35
|
+
const isCrossPost = referencedMessage.reference && referencedMessage.reference.guildId !== message.guild?.id;
|
|
50
36
|
const isCommand = referencedMessage.interaction !== null;
|
|
51
|
-
|
|
37
|
+
const author = referencedMessage.member?.nickname ?? referencedMessage.author.displayName ?? referencedMessage.author.username;
|
|
38
|
+
const avatar = referencedMessage.author.avatarURL?.({ size: 32 }) ?? undefined;
|
|
39
|
+
const roleColor = referencedMessage.member?.displayHexColor ?? undefined;
|
|
40
|
+
const op = referencedMessage.author.id === message?.channel?.ownerId && message?.channel?.isThread?.();
|
|
41
|
+
|
|
42
|
+
return ((0, jsx_runtime_1.jsx)("discord-reply", {
|
|
43
|
+
slot: "reply",
|
|
44
|
+
edited: !isCommand && referencedMessage.editedAt !== null,
|
|
45
|
+
attachment: referencedMessage.attachments.size > 0,
|
|
46
|
+
author: author,
|
|
47
|
+
avatar: avatar,
|
|
48
|
+
roleColor: roleColor,
|
|
49
|
+
bot: !isCrossPost && referencedMessage.author.bot,
|
|
50
|
+
verified: referencedMessage.author.flags?.has?.(discord_js_1.UserFlags.VerifiedBot),
|
|
51
|
+
op: op,
|
|
52
|
+
server: isCrossPost ?? undefined,
|
|
53
|
+
command: isCommand,
|
|
54
|
+
children: referencedMessage.content
|
|
55
|
+
? (0, jsx_runtime_1.jsx)("span", { "data-goto": referencedMessage.id, className: "reply-inline", children: (0, jsx_runtime_1.jsx)(content_1.default, { content: referencedMessage.content, context: Object.assign({}, context, { type: content_1.RenderType.REPLY }) }) })
|
|
56
|
+
: isCommand
|
|
57
|
+
? (0, jsx_runtime_1.jsx)("em", { "data-goto": referencedMessage.id, children: "Click to see command." })
|
|
58
|
+
: (0, jsx_runtime_1.jsx)("em", { "data-goto": referencedMessage.id, children: "Click to see attachment." })
|
|
59
|
+
}));
|
|
52
60
|
}
|
|
53
|
-
//# sourceMappingURL=reply.js.map
|
|
61
|
+
//# sourceMappingURL=reply.js.map
|
|
@@ -6,94 +6,145 @@ exports.JoinMessage = JoinMessage;
|
|
|
6
6
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
7
7
|
const discord_js_1 = require("discord.js");
|
|
8
8
|
const utils_1 = require("../../utils/utils");
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
|
|
10
|
+
function t(context, key, fallback) {
|
|
11
|
+
const dict = context?.i18n?.[context?.lang] || context?.i18n?.en || {};
|
|
12
|
+
return dict[key] || fallback || key;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async function SystemMessage({ message, context }) {
|
|
16
|
+
const author = message.author;
|
|
17
|
+
const authorName = author?.displayName ?? author?.username ?? 'Unknown';
|
|
18
|
+
const color = message.member?.roles?.color?.hexColor;
|
|
19
|
+
const ctx = context || {};
|
|
20
|
+
|
|
11
21
|
switch (message.type) {
|
|
12
22
|
case discord_js_1.MessageType.RecipientAdd:
|
|
13
23
|
case discord_js_1.MessageType.UserJoin:
|
|
14
|
-
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: message.
|
|
24
|
+
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));
|
|
25
|
+
|
|
15
26
|
case discord_js_1.MessageType.ChannelPinnedMessage:
|
|
16
|
-
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "pin", children: [
|
|
27
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "pin", children: [
|
|
28
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
29
|
+
' ',
|
|
30
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "pinned", children: t(ctx, 'pinned', 'pinned a message to this channel.') }),
|
|
31
|
+
(0, jsx_runtime_1.jsx)("i", { "data-goto": message.reference?.messageId, children: " (jump)" }),
|
|
32
|
+
] }, message.id));
|
|
33
|
+
|
|
17
34
|
case discord_js_1.MessageType.GuildBoost:
|
|
18
35
|
case discord_js_1.MessageType.GuildBoostTier1:
|
|
19
36
|
case discord_js_1.MessageType.GuildBoostTier2:
|
|
20
37
|
case discord_js_1.MessageType.GuildBoostTier3:
|
|
21
|
-
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
|
|
38
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
|
|
39
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
40
|
+
' ',
|
|
41
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "boosted", children: t(ctx, 'boosted', 'boosted the server!') }),
|
|
42
|
+
] }, message.id));
|
|
43
|
+
|
|
22
44
|
case discord_js_1.MessageType.ThreadStarterMessage:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
45
|
+
case discord_js_1.MessageType.ThreadCreated:
|
|
46
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "thread", children: [
|
|
47
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
48
|
+
' ',
|
|
49
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "threadStarted", children: t(ctx, 'threadStarted', 'started a thread:') }),
|
|
50
|
+
' ',
|
|
51
|
+
(0, jsx_runtime_1.jsx)("i", { "data-goto": message.reference?.messageId, children: message.content || 'New thread' }),
|
|
52
|
+
] }, message.id));
|
|
53
|
+
|
|
54
|
+
case discord_js_1.MessageType.ChannelNameChange:
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: [
|
|
56
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
57
|
+
' ',
|
|
58
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "changedChannelName", children: t(ctx, 'changedChannelName', 'changed the channel name:') }),
|
|
59
|
+
' ',
|
|
60
|
+
(0, jsx_runtime_1.jsx)("strong", { children: message.content }),
|
|
61
|
+
] }, message.id));
|
|
62
|
+
|
|
63
|
+
case discord_js_1.MessageType.ChannelIconChange:
|
|
64
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: [
|
|
65
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
66
|
+
' ',
|
|
67
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "changedChannelIcon", children: t(ctx, 'changedChannelIcon', 'changed the channel icon.') }),
|
|
68
|
+
] }, message.id));
|
|
69
|
+
|
|
39
70
|
case discord_js_1.MessageType.ChatInputCommand:
|
|
40
71
|
case discord_js_1.MessageType.ContextMenuCommand: {
|
|
41
|
-
const authorName = message.author.displayName || message.author.username;
|
|
42
|
-
const color = message.member?.roles?.color?.hexColor;
|
|
43
72
|
const cmd = message.interaction?.commandName ? '/' + message.interaction.commandName : 'a command';
|
|
44
|
-
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
73
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
|
|
74
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
75
|
+
' ',
|
|
76
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "usedCommand", children: t(ctx, 'usedCommand', 'used') }),
|
|
77
|
+
' ',
|
|
78
|
+
(0, jsx_runtime_1.jsx)("strong", { children: cmd }),
|
|
79
|
+
] }, message.id));
|
|
50
80
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
81
|
+
|
|
82
|
+
case discord_js_1.MessageType.Call:
|
|
83
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "call", children: [
|
|
84
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
85
|
+
' ',
|
|
86
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "startedCall", children: t(ctx, 'startedCall', 'started a call.') }),
|
|
87
|
+
] }, message.id));
|
|
88
|
+
|
|
89
|
+
case discord_js_1.MessageType.ChannelFollowAdd:
|
|
90
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: [
|
|
91
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
92
|
+
' ',
|
|
93
|
+
t(ctx, 'addedFollow', 'added {target} to follow this channel.').replace('{target}', message.content || ''),
|
|
94
|
+
] }, message.id));
|
|
95
|
+
|
|
96
|
+
case discord_js_1.MessageType.RecipientRemove:
|
|
97
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "leave", children: [
|
|
98
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
99
|
+
' ',
|
|
100
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "left", children: t(ctx, 'left', 'left.') }),
|
|
101
|
+
] }, message.id));
|
|
102
|
+
|
|
103
|
+
case discord_js_1.MessageType.AutoModerationAction: {
|
|
104
|
+
// Discord packs detail into the first embed: matched_keyword, blocked_content, channel_id, rule_name
|
|
105
|
+
const e = message.embeds?.[0];
|
|
106
|
+
const ruleName = e?.fields?.find?.((f) => /rule/i.test(f.name))?.value || e?.title || '';
|
|
107
|
+
const blocked = e?.description || '';
|
|
108
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
|
|
109
|
+
(0, jsx_runtime_1.jsx)("span", { "data-i18n": "autoModBlocked", children: t(ctx, 'autoModBlocked', 'AutoMod blocked a message.') }),
|
|
110
|
+
ruleName && (0, jsx_runtime_1.jsxs)("span", { className: "dht-automod-rule", children: [' · ', (0, utils_1.escapeHtml)(ruleName)] }),
|
|
111
|
+
blocked && (0, jsx_runtime_1.jsx)("blockquote", { className: "dht-automod-content", children: blocked }),
|
|
112
|
+
] }, message.id));
|
|
55
113
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "
|
|
114
|
+
|
|
115
|
+
case discord_js_1.MessageType.RoleSubscriptionPurchase: {
|
|
116
|
+
const roleName = message.roleSubscriptionData?.tierName || message.content || 'a role';
|
|
117
|
+
return ((0, jsx_runtime_1.jsxs)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: [
|
|
118
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color, children: authorName }),
|
|
119
|
+
' ',
|
|
120
|
+
t(ctx, 'roleSubPurchased', 'subscribed to {role}!').replace('{role}', roleName),
|
|
121
|
+
] }, message.id));
|
|
60
122
|
}
|
|
61
|
-
|
|
62
|
-
return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: 'AutoMod blocked a message.' }, message.id));
|
|
123
|
+
|
|
63
124
|
case discord_js_1.MessageType.GuildIncidentReportRaid:
|
|
64
125
|
case discord_js_1.MessageType.GuildIncidentReportFalseAlarm:
|
|
65
126
|
case discord_js_1.MessageType.GuildIncidentAlertModeEnabled:
|
|
66
127
|
case discord_js_1.MessageType.GuildIncidentAlertModeDisabled:
|
|
67
|
-
return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, type: "boost", children: 'Server safety alert.' }, message.id));
|
|
128
|
+
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));
|
|
129
|
+
|
|
68
130
|
case discord_js_1.MessageType.PollResult:
|
|
69
|
-
return ((0, jsx_runtime_1.jsx)("discord-system-message", { id: `m-${message.id}`, type: "edit", children: 'A poll ended.' }, message.id));
|
|
70
|
-
|
|
131
|
+
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));
|
|
132
|
+
|
|
133
|
+
// These render through the normal pipeline
|
|
71
134
|
case discord_js_1.MessageType.Default:
|
|
72
135
|
case discord_js_1.MessageType.Reply:
|
|
73
136
|
return undefined;
|
|
74
|
-
|
|
75
|
-
case discord_js_1.MessageType.GuildDiscoveryDisqualified:
|
|
76
|
-
case discord_js_1.MessageType.GuildDiscoveryRequalified:
|
|
77
|
-
case discord_js_1.MessageType.GuildDiscoveryGracePeriodInitialWarning:
|
|
78
|
-
case discord_js_1.MessageType.GuildDiscoveryGracePeriodFinalWarning:
|
|
79
|
-
case discord_js_1.MessageType.GuildInviteReminder:
|
|
80
|
-
case discord_js_1.MessageType.RoleSubscriptionPurchase:
|
|
81
|
-
case discord_js_1.MessageType.InteractionPremiumUpsell:
|
|
82
|
-
case discord_js_1.MessageType.StageStart:
|
|
83
|
-
case discord_js_1.MessageType.StageEnd:
|
|
84
|
-
case discord_js_1.MessageType.StageSpeaker:
|
|
85
|
-
case discord_js_1.MessageType.StageRaiseHand:
|
|
86
|
-
case discord_js_1.MessageType.StageTopic:
|
|
87
|
-
case discord_js_1.MessageType.GuildApplicationPremiumSubscription:
|
|
88
|
-
case discord_js_1.MessageType.PurchaseNotification:
|
|
89
|
-
return undefined;
|
|
137
|
+
|
|
90
138
|
default:
|
|
91
139
|
return undefined;
|
|
92
140
|
}
|
|
93
141
|
}
|
|
142
|
+
|
|
94
143
|
function Highlight({ children, color }) {
|
|
95
|
-
|
|
144
|
+
const safe = typeof color === 'string' && /^#[0-9a-fA-F]{3,8}$/.test(color) ? color : 'white';
|
|
145
|
+
return (0, jsx_runtime_1.jsx)("i", { style: { color: safe }, children: children });
|
|
96
146
|
}
|
|
147
|
+
|
|
97
148
|
const allJoinMessages = [
|
|
98
149
|
'{user} just joined the server - glhf!',
|
|
99
150
|
'{user} just joined. Everyone, look busy!',
|
|
@@ -126,24 +177,34 @@ const allJoinMessages = [
|
|
|
126
177
|
"We've been expecting you {user}",
|
|
127
178
|
"It's dangerous to go alone, take {user}!",
|
|
128
179
|
"{user} has joined the server! It's super effective!",
|
|
129
|
-
'Cheers, love! {user} is here!',
|
|
130
180
|
'{user} is here, as the prophecy foretold.',
|
|
131
181
|
"{user} has arrived. Party's over.",
|
|
132
182
|
'Ready player {user}',
|
|
133
183
|
'{user} is here to kick butt and chew bubblegum. And {user} is all out of gum.',
|
|
134
184
|
"Hello. Is it {user} you're looking for?",
|
|
135
185
|
];
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
186
|
+
|
|
187
|
+
// Deterministic — seed off message.id so the message text stays stable across re-renders.
|
|
188
|
+
function pickJoinMessage(seed) {
|
|
189
|
+
if (!seed) return allJoinMessages[0];
|
|
190
|
+
try {
|
|
191
|
+
// Hash snowflake → index. BigInt safe for snowflakes.
|
|
192
|
+
let n = 0;
|
|
193
|
+
for (let i = 0; i < seed.length; i++) n = (n * 31 + seed.charCodeAt(i)) >>> 0;
|
|
194
|
+
return allJoinMessages[n % allJoinMessages.length];
|
|
195
|
+
} catch (_e) {
|
|
196
|
+
return allJoinMessages[0];
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function JoinMessage({ member, fallbackUser, seed, context }) {
|
|
201
|
+
const template = pickJoinMessage(seed);
|
|
202
|
+
return template
|
|
139
203
|
.split('{user}')
|
|
140
|
-
.flatMap((item, i) =>
|
|
141
|
-
var _a, _b, _c;
|
|
142
|
-
return [
|
|
204
|
+
.flatMap((item, i) => [
|
|
143
205
|
item,
|
|
144
|
-
(0, jsx_runtime_1.jsx)(Highlight, { color:
|
|
145
|
-
]
|
|
146
|
-
})
|
|
206
|
+
(0, jsx_runtime_1.jsx)(Highlight, { color: member?.roles?.color?.hexColor, children: member?.nickname ?? fallbackUser.displayName ?? fallbackUser.username }, i),
|
|
207
|
+
])
|
|
147
208
|
.slice(0, -1);
|
|
148
209
|
}
|
|
149
|
-
//# sourceMappingURL=systemMessage.js.map
|
|
210
|
+
//# sourceMappingURL=systemMessage.js.map
|
|
@@ -1,51 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
18
5
|
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
6
|
+
var ownKeys = function(o){ownKeys = Object.getOwnPropertyNames || function (o){var ar=[];for (var k in o) if (Object.prototype.hasOwnProperty.call(o,k)) ar[ar.length]=k;return ar;};return ownKeys(o);};
|
|
7
|
+
return function (mod){if (mod && mod.__esModule) return mod;var result={};if (mod != null) for (var k=ownKeys(mod), i=0; i<k.length; i++) if (k[i] !== "default") Object.defineProperty(result,k[i],{get:function(){return mod[k[i]];}});Object.defineProperty(result,"default",{value:mod,enumerable:true});return result;};
|
|
34
8
|
})();
|
|
35
9
|
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
10
|
var t = {};
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
-
t[p] = s[p];
|
|
11
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
39
12
|
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
13
|
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
-
t[p[i]] = s[p[i]];
|
|
14
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
43
15
|
}
|
|
44
16
|
return t;
|
|
45
17
|
};
|
|
46
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
-
};
|
|
49
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
19
|
exports.default = DiscordMessages;
|
|
51
20
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
@@ -53,24 +22,41 @@ const discord_js_1 = require("discord.js");
|
|
|
53
22
|
const content_1 = __importStar(require("./renderers/content"));
|
|
54
23
|
const message_1 = __importDefault(require("./renderers/message"));
|
|
55
24
|
const TranscriptHeader_1 = require("./renderers/components/TranscriptHeader");
|
|
56
|
-
|
|
57
|
-
* The core transcript component.
|
|
58
|
-
* Expects window.$discordMessage.profiles to be set for profile information.
|
|
59
|
-
*
|
|
60
|
-
* @param props Messages, channel details, callbacks, etc.
|
|
61
|
-
* @returns
|
|
62
|
-
*/
|
|
25
|
+
|
|
63
26
|
async function DiscordMessages(_a) {
|
|
64
|
-
var _b, _c, _d, _e, _f;
|
|
65
27
|
var { messages, channel, callbacks } = _a, options = __rest(_a, ["messages", "channel", "callbacks"]);
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
28
|
+
const dateSeps = options.dateSeps || [];
|
|
29
|
+
|
|
30
|
+
return ((0, jsx_runtime_1.jsxs)("discord-messages", { style: { minHeight: '100vh' }, children: [
|
|
31
|
+
(0, jsx_runtime_1.jsx)(TranscriptHeader_1.TranscriptHeader, {
|
|
32
|
+
guildName: channel.isDMBased() ? 'Direct Messages' : channel.guild.name,
|
|
33
|
+
guildIcon: channel.isDMBased() ? undefined : (channel.guild.iconURL({ size: 128 }) ?? undefined),
|
|
34
|
+
channelName: channel.isDMBased()
|
|
35
|
+
? channel.type === discord_js_1.ChannelType.DM
|
|
36
|
+
? (channel.recipient?.tag ?? 'Unknown Recipient')
|
|
37
|
+
: 'Unknown Recipient'
|
|
38
|
+
: channel.name,
|
|
39
|
+
children: channel.isThread() ? (`Thread channel in ${channel.parent?.name ?? 'Unknown Channel'}`)
|
|
40
|
+
: channel.isDMBased() ? (`Direct Messages`)
|
|
41
|
+
: channel.isVoiceBased() ? (`Voice Text Channel for ${channel.name}`)
|
|
42
|
+
: channel.type === discord_js_1.ChannelType.GuildCategory ? (`Category Channel`)
|
|
43
|
+
: 'topic' in channel && channel.topic
|
|
44
|
+
? (0, jsx_runtime_1.jsx)(content_1.default, { content: channel.topic, context: Object.assign({ messages, channel, callbacks, type: content_1.RenderType.REPLY }, options) })
|
|
45
|
+
: (`This is the start of #${channel.name} channel.`)
|
|
46
|
+
}),
|
|
47
|
+
messages.map((message, idx) => [
|
|
48
|
+
dateSeps[idx] && (0, jsx_runtime_1.jsx)("div", { className: "dht-date-sep", children: dateSeps[idx] }, `sep-${idx}`),
|
|
49
|
+
(0, jsx_runtime_1.jsx)(message_1.default, { message: message, context: Object.assign({ messages, channel, callbacks }, options) }, message.id)
|
|
50
|
+
]),
|
|
51
|
+
(0, jsx_runtime_1.jsxs)("div", { style: { textAlign: 'center', width: '100%' }, children: [
|
|
52
|
+
options.footerText
|
|
53
|
+
? options.footerText.replaceAll('{number}', messages.length.toString()).replaceAll('{s}', messages.length > 1 ? 's' : '')
|
|
54
|
+
: `Exported ${messages.length} message${messages.length > 1 ? 's' : ''}.`,
|
|
55
|
+
' ',
|
|
56
|
+
options.poweredBy
|
|
57
|
+
? (0, jsx_runtime_1.jsxs)("span", { style: { textAlign: 'center' }, children: ["Powered by ", (0, jsx_runtime_1.jsx)("a", { href: "https://github.com/ItzDerock/discord-html-transcripts", style: { color: 'lightblue' }, children: "discord-html-transcripts" }), "."] })
|
|
58
|
+
: null
|
|
59
|
+
] })
|
|
60
|
+
] }));
|
|
75
61
|
}
|
|
76
|
-
//# sourceMappingURL=transcript.js.map
|
|
62
|
+
//# sourceMappingURL=transcript.js.map
|