spectre-html-transcripts 3.3.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/LICENSE +201 -0
- package/README.md +153 -0
- package/dist/downloader/images.d.ts +43 -0
- package/dist/downloader/images.js +125 -0
- package/dist/downloader/images.js.map +1 -0
- package/dist/generator/index.d.ts +20 -0
- package/dist/generator/index.js +79 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/renderers/attachment.d.ts +24 -0
- package/dist/generator/renderers/attachment.js +49 -0
- package/dist/generator/renderers/attachment.js.map +1 -0
- package/dist/generator/renderers/components/Button.d.ts +9 -0
- package/dist/generator/renderers/components/Button.js +19 -0
- package/dist/generator/renderers/components/Button.js.map +1 -0
- package/dist/generator/renderers/components/Container.d.ts +5 -0
- package/dist/generator/renderers/components/Container.js +22 -0
- package/dist/generator/renderers/components/Container.js.map +1 -0
- package/dist/generator/renderers/components/Media Gallery.d.ts +6 -0
- package/dist/generator/renderers/components/Media Gallery.js +39 -0
- package/dist/generator/renderers/components/Media Gallery.js.map +1 -0
- package/dist/generator/renderers/components/Select Menu.d.ts +5 -0
- package/dist/generator/renderers/components/Select Menu.js +41 -0
- package/dist/generator/renderers/components/Select Menu.js.map +1 -0
- package/dist/generator/renderers/components/Spacing.d.ts +6 -0
- package/dist/generator/renderers/components/Spacing.js +17 -0
- package/dist/generator/renderers/components/Spacing.js.map +1 -0
- package/dist/generator/renderers/components/Thumbnail.d.ts +5 -0
- package/dist/generator/renderers/components/Thumbnail.js +16 -0
- package/dist/generator/renderers/components/Thumbnail.js.map +1 -0
- package/dist/generator/renderers/components/section/Section.d.ts +10 -0
- package/dist/generator/renderers/components/section/Section.js +21 -0
- package/dist/generator/renderers/components/section/Section.js.map +1 -0
- package/dist/generator/renderers/components/section/SectionAccessory.d.ts +6 -0
- package/dist/generator/renderers/components/section/SectionAccessory.js +19 -0
- package/dist/generator/renderers/components/section/SectionAccessory.js.map +1 -0
- package/dist/generator/renderers/components/section/SectionContent.d.ts +6 -0
- package/dist/generator/renderers/components/section/SectionContent.js +15 -0
- package/dist/generator/renderers/components/section/SectionContent.js.map +1 -0
- package/dist/generator/renderers/components/styles.d.ts +29 -0
- package/dist/generator/renderers/components/styles.js +110 -0
- package/dist/generator/renderers/components/styles.js.map +1 -0
- package/dist/generator/renderers/components/utils.d.ts +36 -0
- package/dist/generator/renderers/components/utils.js +98 -0
- package/dist/generator/renderers/components/utils.js.map +1 -0
- package/dist/generator/renderers/components.d.ts +15 -0
- package/dist/generator/renderers/components.js +62 -0
- package/dist/generator/renderers/components.js.map +1 -0
- package/dist/generator/renderers/content.d.ts +31 -0
- package/dist/generator/renderers/content.js +137 -0
- package/dist/generator/renderers/content.js.map +1 -0
- package/dist/generator/renderers/embed.d.ts +12 -0
- package/dist/generator/renderers/embed.js +53 -0
- package/dist/generator/renderers/embed.js.map +1 -0
- package/dist/generator/renderers/message.d.ts +7 -0
- package/dist/generator/renderers/message.js +69 -0
- package/dist/generator/renderers/message.js.map +1 -0
- package/dist/generator/renderers/reply.d.ts +7 -0
- package/dist/generator/renderers/reply.js +59 -0
- package/dist/generator/renderers/reply.js.map +1 -0
- package/dist/generator/renderers/systemMessage.d.ts +13 -0
- package/dist/generator/renderers/systemMessage.js +133 -0
- package/dist/generator/renderers/systemMessage.js.map +1 -0
- package/dist/generator/transcript.d.ts +10 -0
- package/dist/generator/transcript.js +86 -0
- package/dist/generator/transcript.js.map +1 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +148 -0
- package/dist/index.js.map +1 -0
- package/dist/static/client.d.ts +2 -0
- package/dist/static/client.js +30 -0
- package/dist/static/client.js.map +1 -0
- package/dist/test.js +65 -0
- package/dist/types.d.ts +75 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buildProfiles.d.ts +11 -0
- package/dist/utils/buildProfiles.js +41 -0
- package/dist/utils/buildProfiles.js.map +1 -0
- package/dist/utils/djsAdapter.d.ts +9 -0
- package/dist/utils/djsAdapter.js +96 -0
- package/dist/utils/djsAdapter.js.map +1 -0
- package/dist/utils/embeds.d.ts +1 -0
- package/dist/utils/embeds.js +17 -0
- package/dist/utils/embeds.js.map +1 -0
- package/dist/utils/extend.d.ts +8 -0
- package/dist/utils/extend.js +8 -0
- package/dist/utils/extend.js.map +1 -0
- package/dist/utils/utils.d.ts +14 -0
- package/dist/utils/utils.js +44 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type GuildMember, type Message, type User } from 'discord.js-selfbot-v13';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export default function SystemMessage({ message }: {
|
|
4
|
+
message: Message;
|
|
5
|
+
}): Promise<React.JSX.Element | undefined>;
|
|
6
|
+
export declare function Highlight({ children, color }: {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
color?: string;
|
|
9
|
+
}): React.JSX.Element;
|
|
10
|
+
export declare function JoinMessage({ member, fallbackUser }: {
|
|
11
|
+
member: GuildMember | null;
|
|
12
|
+
fallbackUser: User;
|
|
13
|
+
}): (string | React.JSX.Element)[];
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = SystemMessage;
|
|
7
|
+
exports.Highlight = Highlight;
|
|
8
|
+
exports.JoinMessage = JoinMessage;
|
|
9
|
+
const discord_components_react_1 = require("@derockdev/discord-components-react");
|
|
10
|
+
const discord_js_selfbot_v13_1 = require("discord.js-selfbot-v13");
|
|
11
|
+
const react_1 = __importDefault(require("react"));
|
|
12
|
+
const utils_1 = require("../../utils/utils");
|
|
13
|
+
async function SystemMessage({ message }) {
|
|
14
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
15
|
+
switch (message.type) {
|
|
16
|
+
case discord_js_selfbot_v13_1.MessageType.RecipientAdd:
|
|
17
|
+
case discord_js_selfbot_v13_1.MessageType.UserJoin:
|
|
18
|
+
return (react_1.default.createElement(discord_components_react_1.DiscordSystemMessage, { id: `m-${message.id}`, key: message.id, type: "join" },
|
|
19
|
+
react_1.default.createElement(JoinMessage, { member: message.member, fallbackUser: message.author })));
|
|
20
|
+
case discord_js_selfbot_v13_1.MessageType.ChannelPinnedMessage:
|
|
21
|
+
return (react_1.default.createElement(discord_components_react_1.DiscordSystemMessage, { id: `m-${message.id}`, key: message.id, type: "pin" },
|
|
22
|
+
react_1.default.createElement(Highlight, { color: (_b = (_a = message.member) === null || _a === void 0 ? void 0 : _a.roles.color) === null || _b === void 0 ? void 0 : _b.hexColor }, (_c = message.author.displayName) !== null && _c !== void 0 ? _c : message.author.username),
|
|
23
|
+
' ',
|
|
24
|
+
"pinned ",
|
|
25
|
+
react_1.default.createElement("i", { "data-goto": (_d = message.reference) === null || _d === void 0 ? void 0 : _d.messageId }, "a message"),
|
|
26
|
+
" to this channel.",
|
|
27
|
+
message.reactions.cache.size > 0 && (react_1.default.createElement(discord_components_react_1.DiscordReactions, { slot: "reactions" }, message.reactions.cache.map((reaction, id) => (react_1.default.createElement(discord_components_react_1.DiscordReaction, { key: `${message.id}r${id}`, name: reaction.emoji.name, emoji: (0, utils_1.parseDiscordEmoji)(reaction.emoji), count: reaction.count })))))));
|
|
28
|
+
case discord_js_selfbot_v13_1.MessageType.GuildBoost:
|
|
29
|
+
case discord_js_selfbot_v13_1.MessageType.GuildBoostTier1:
|
|
30
|
+
case discord_js_selfbot_v13_1.MessageType.GuildBoostTier2:
|
|
31
|
+
case discord_js_selfbot_v13_1.MessageType.GuildBoostTier3:
|
|
32
|
+
return (react_1.default.createElement(discord_components_react_1.DiscordSystemMessage, { id: `m-${message.id}`, key: message.id, type: "boost" },
|
|
33
|
+
react_1.default.createElement(Highlight, { color: (_f = (_e = message.member) === null || _e === void 0 ? void 0 : _e.roles.color) === null || _f === void 0 ? void 0 : _f.hexColor }, (_g = message.author.displayName) !== null && _g !== void 0 ? _g : message.author.username),
|
|
34
|
+
' ',
|
|
35
|
+
"boosted the server!"));
|
|
36
|
+
case discord_js_selfbot_v13_1.MessageType.ThreadStarterMessage:
|
|
37
|
+
return (react_1.default.createElement(discord_components_react_1.DiscordSystemMessage, { id: `ms-${message.id}`, key: message.id, type: "thread" },
|
|
38
|
+
react_1.default.createElement(Highlight, { color: (_j = (_h = message.member) === null || _h === void 0 ? void 0 : _h.roles.color) === null || _j === void 0 ? void 0 : _j.hexColor }, (_k = message.author.displayName) !== null && _k !== void 0 ? _k : message.author.username),
|
|
39
|
+
' ',
|
|
40
|
+
"started a thread: ",
|
|
41
|
+
react_1.default.createElement("i", { "data-goto": (_l = message.reference) === null || _l === void 0 ? void 0 : _l.messageId }, message.content)));
|
|
42
|
+
// TODO: implement support for these:
|
|
43
|
+
case discord_js_selfbot_v13_1.MessageType.Default:
|
|
44
|
+
case discord_js_selfbot_v13_1.MessageType.RecipientRemove:
|
|
45
|
+
case discord_js_selfbot_v13_1.MessageType.Call:
|
|
46
|
+
case discord_js_selfbot_v13_1.MessageType.ChannelNameChange:
|
|
47
|
+
case discord_js_selfbot_v13_1.MessageType.ChannelIconChange:
|
|
48
|
+
case discord_js_selfbot_v13_1.MessageType.ChannelFollowAdd:
|
|
49
|
+
case discord_js_selfbot_v13_1.MessageType.GuildDiscoveryDisqualified:
|
|
50
|
+
case discord_js_selfbot_v13_1.MessageType.GuildDiscoveryRequalified:
|
|
51
|
+
case discord_js_selfbot_v13_1.MessageType.GuildDiscoveryGracePeriodInitialWarning:
|
|
52
|
+
case discord_js_selfbot_v13_1.MessageType.GuildDiscoveryGracePeriodFinalWarning:
|
|
53
|
+
case discord_js_selfbot_v13_1.MessageType.ThreadCreated:
|
|
54
|
+
case discord_js_selfbot_v13_1.MessageType.Reply:
|
|
55
|
+
case discord_js_selfbot_v13_1.MessageType.ChatInputCommand:
|
|
56
|
+
case discord_js_selfbot_v13_1.MessageType.GuildInviteReminder:
|
|
57
|
+
case discord_js_selfbot_v13_1.MessageType.ContextMenuCommand:
|
|
58
|
+
case discord_js_selfbot_v13_1.MessageType.AutoModerationAction:
|
|
59
|
+
case discord_js_selfbot_v13_1.MessageType.RoleSubscriptionPurchase:
|
|
60
|
+
case discord_js_selfbot_v13_1.MessageType.InteractionPremiumUpsell:
|
|
61
|
+
case discord_js_selfbot_v13_1.MessageType.StageStart:
|
|
62
|
+
case discord_js_selfbot_v13_1.MessageType.StageEnd:
|
|
63
|
+
case discord_js_selfbot_v13_1.MessageType.StageSpeaker:
|
|
64
|
+
case discord_js_selfbot_v13_1.MessageType.StageRaiseHand:
|
|
65
|
+
case discord_js_selfbot_v13_1.MessageType.StageTopic:
|
|
66
|
+
case discord_js_selfbot_v13_1.MessageType.GuildApplicationPremiumSubscription:
|
|
67
|
+
case discord_js_selfbot_v13_1.MessageType.GuildIncidentAlertModeEnabled:
|
|
68
|
+
case discord_js_selfbot_v13_1.MessageType.GuildIncidentAlertModeDisabled:
|
|
69
|
+
case discord_js_selfbot_v13_1.MessageType.GuildIncidentReportRaid:
|
|
70
|
+
case discord_js_selfbot_v13_1.MessageType.GuildIncidentReportFalseAlarm:
|
|
71
|
+
case discord_js_selfbot_v13_1.MessageType.PurchaseNotification:
|
|
72
|
+
case discord_js_selfbot_v13_1.MessageType.PollResult:
|
|
73
|
+
return undefined;
|
|
74
|
+
default:
|
|
75
|
+
return undefined;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function Highlight({ children, color }) {
|
|
79
|
+
return react_1.default.createElement("i", { style: { color: color !== null && color !== void 0 ? color : 'white' } }, children);
|
|
80
|
+
}
|
|
81
|
+
const allJoinMessages = [
|
|
82
|
+
'{user} just joined the server - glhf!',
|
|
83
|
+
'{user} just joined. Everyone, look busy!',
|
|
84
|
+
'{user} just joined. Can I get a heal?',
|
|
85
|
+
'{user} joined your party.',
|
|
86
|
+
'{user} joined. You must construct additional pylons.',
|
|
87
|
+
'Ermagherd. {user} is here.',
|
|
88
|
+
'Welcome, {user}. Stay awhile and listen.',
|
|
89
|
+
'Welcome, {user}. We were expecting you ( อกยฐ อส อกยฐ)',
|
|
90
|
+
'Welcome, {user}. We hope you brought pizza.',
|
|
91
|
+
'Welcome {user}. Leave your weapons by the door.',
|
|
92
|
+
'A wild {user} appeared.',
|
|
93
|
+
'Swoooosh. {user} just landed.',
|
|
94
|
+
'Brace yourselves {user} just joined the server.',
|
|
95
|
+
'{user} just joined. Hide your bananas.',
|
|
96
|
+
'{user} just arrived. Seems OP - please nerf.',
|
|
97
|
+
'{user} just slid into the server.',
|
|
98
|
+
'A {user} has spawned in the server.',
|
|
99
|
+
'Big {user} showed up!',
|
|
100
|
+
"Where's {user}? In the server!",
|
|
101
|
+
'{user} hopped into the server. Kangaroo!!',
|
|
102
|
+
'{user} just showed up. Hold my beer.',
|
|
103
|
+
'Challenger approaching - {user} has appeared!',
|
|
104
|
+
"It's a bird! It's a plane! Nevermind, it's just {user}.",
|
|
105
|
+
"It's {user}! Praise the sun! \\\\[T]/",
|
|
106
|
+
'Never gonna give {user} up. Never gonna let {user} down.',
|
|
107
|
+
'Ha! {user} has joined! You activated my trap card!',
|
|
108
|
+
'Cheers, love! {user} is here!',
|
|
109
|
+
'Hey! Listen! {user} has joined!',
|
|
110
|
+
"We've been expecting you {user}",
|
|
111
|
+
"It's dangerous to go alone, take {user}!",
|
|
112
|
+
"{user} has joined the server! It's super effective!",
|
|
113
|
+
'Cheers, love! {user} is here!',
|
|
114
|
+
'{user} is here, as the prophecy foretold.',
|
|
115
|
+
"{user} has arrived. Party's over.",
|
|
116
|
+
'Ready player {user}',
|
|
117
|
+
'{user} is here to kick butt and chew bubblegum. And {user} is all out of gum.',
|
|
118
|
+
"Hello. Is it {user} you're looking for?",
|
|
119
|
+
];
|
|
120
|
+
function JoinMessage({ member, fallbackUser }) {
|
|
121
|
+
const randomMessage = allJoinMessages[Math.floor(Math.random() * allJoinMessages.length)];
|
|
122
|
+
return randomMessage
|
|
123
|
+
.split('{user}')
|
|
124
|
+
.flatMap((item, i) => {
|
|
125
|
+
var _a, _b, _c;
|
|
126
|
+
return [
|
|
127
|
+
item,
|
|
128
|
+
react_1.default.createElement(Highlight, { color: (_a = member === null || member === void 0 ? void 0 : member.roles.color) === null || _a === void 0 ? void 0 : _a.hexColor, key: i }, (_c = (_b = member === null || member === void 0 ? void 0 : member.nickname) !== null && _b !== void 0 ? _b : fallbackUser.displayName) !== null && _c !== void 0 ? _c : fallbackUser.username),
|
|
129
|
+
];
|
|
130
|
+
})
|
|
131
|
+
.slice(0, -1);
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=systemMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemMessage.js","sourceRoot":"","sources":["../../../src/generator/renderers/systemMessage.tsx"],"names":[],"mappings":";;;;;AAKA,gCA4FC;AAED,8BAEC;AA0CD,kCAYC;AA3JD,kFAA8G;AAC9G,mEAAgG;AAChG,kDAA0B;AAC1B,6CAAsD;AAEvC,KAAK,UAAU,aAAa,CAAC,EAAE,OAAO,EAAwB;;IAC3E,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,oCAAW,CAAC,YAAY,CAAC;QAC9B,KAAK,oCAAW,CAAC,QAAQ;YACvB,OAAO,CACL,8BAAC,+CAAoB,IAAC,EAAE,EAAE,KAAK,OAAO,CAAC,EAAE,EAAE,EAAE,GAAG,EAAE,OAAO,CAAC,EAAE,EAAE,IAAI,EAAC,MAAM;gBACvE,8BAAC,WAAW,IAAC,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,YAAY,EAAE,OAAO,CAAC,MAAM,GAAI,CAChD,CACxB,CAAC;QAEJ,KAAK,oCAAW,CAAC,oBAAoB;YACnC,OAAO,CACL,8BAAC,+CAAoB,IAAC,EAAE,EAAE,KAAK,OAAO,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;IAC1D,oDAAoD;IACpD,+BAA+B;IAC/B,iCAAiC;IACjC,iCAAiC;IACjC,0CAA0C;IAC1C,qDAAqD;IACrD,+BAA+B;IAC/B,2CAA2C;IAC3C,mCAAmC;IACnC,qBAAqB;IACrB,+EAA+E;IAC/E,yCAAyC;CAC1C,CAAC;AAEF,SAAgB,WAAW,CAAC,EAAE,MAAM,EAAE,YAAY,EAAsD;IACtG,MAAM,aAAa,GAAG,eAAe,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,eAAe,CAAC,MAAM,CAAC,CAAC,CAAC;IAE1F,OAAO,aAAa;SACjB,KAAK,CAAC,QAAQ,CAAC;SACf,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,EAAE;;QAAC,OAAA;YACpB,IAAI;YACJ,8BAAC,SAAS,IAAC,KAAK,EAAE,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,KAAK,CAAC,KAAK,0CAAE,QAAQ,EAAE,GAAG,EAAE,CAAC,IACpD,MAAA,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ,mCAAI,YAAY,CAAC,WAAW,mCAAI,YAAY,CAAC,QAAQ,CAC5D;SACb,CAAA;KAAA,CAAC;SACD,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { RenderMessageContext } from '.';
|
|
3
|
+
/**
|
|
4
|
+
* The core transcript component.
|
|
5
|
+
* Expects window.$discordMessage.profiles to be set for profile information.
|
|
6
|
+
*
|
|
7
|
+
* @param props Messages, channel details, callbacks, etc.
|
|
8
|
+
* @returns
|
|
9
|
+
*/
|
|
10
|
+
export default function DiscordMessages({ messages, channel, callbacks, ...options }: RenderMessageContext): Promise<React.JSX.Element>;
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
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
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
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]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
47
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.default = DiscordMessages;
|
|
51
|
+
const discord_components_react_1 = require("@derockdev/discord-components-react");
|
|
52
|
+
const react_1 = __importDefault(require("react"));
|
|
53
|
+
const djsAdapter_1 = require("../utils/djsAdapter");
|
|
54
|
+
const content_1 = __importStar(require("./renderers/content"));
|
|
55
|
+
const message_1 = __importDefault(require("./renderers/message"));
|
|
56
|
+
const styles_1 = require("./renderers/components/styles");
|
|
57
|
+
/**
|
|
58
|
+
* The core transcript component.
|
|
59
|
+
* Expects window.$discordMessage.profiles to be set for profile information.
|
|
60
|
+
*
|
|
61
|
+
* @param props Messages, channel details, callbacks, etc.
|
|
62
|
+
* @returns
|
|
63
|
+
*/
|
|
64
|
+
async function DiscordMessages(_a) {
|
|
65
|
+
var _b, _c, _d, _e, _f, _g, _h, _j;
|
|
66
|
+
var { messages, channel, callbacks } = _a, options = __rest(_a, ["messages", "channel", "callbacks"]);
|
|
67
|
+
return (react_1.default.createElement(discord_components_react_1.DiscordMessages, { style: { minHeight: '100vh' } },
|
|
68
|
+
react_1.default.createElement("style", { dangerouslySetInnerHTML: { __html: styles_1.globalStyles } }),
|
|
69
|
+
react_1.default.createElement(discord_components_react_1.DiscordHeader, { guild: (0, djsAdapter_1.isDMBasedChannel)(channel) ? 'Direct Messages' : (_b = channel.guild) === null || _b === void 0 ? void 0 : _b.name, channel: (0, djsAdapter_1.isDMBasedChannel)(channel)
|
|
70
|
+
? ((_d = (_c = channel.recipient) === null || _c === void 0 ? void 0 : _c.tag) !== null && _d !== void 0 ? _d : 'Unknown Recipient')
|
|
71
|
+
: channel.name, icon: (0, djsAdapter_1.isDMBasedChannel)(channel) ? undefined : ((_g = (_f = (_e = channel.guild) === null || _e === void 0 ? void 0 : _e.iconURL) === null || _f === void 0 ? void 0 : _f.call(_e, { size: 128 })) !== null && _g !== void 0 ? _g : undefined) }, (0, djsAdapter_1.isThreadChannel)(channel) ? (`Thread channel in ${(_j = (_h = channel.parent) === null || _h === void 0 ? void 0 : _h.name) !== null && _j !== void 0 ? _j : 'Unknown Channel'}`) : (0, djsAdapter_1.isDMBasedChannel)(channel) ? (`Direct Messages`) : (0, djsAdapter_1.isVoiceBasedChannel)(channel) ? (`Voice Text Channel for ${channel.name}`) : 'topic' in channel && channel.topic ? (react_1.default.createElement(content_1.default, { content: channel.topic, context: Object.assign({ messages, channel, callbacks, type: content_1.RenderType.REPLY }, options) })) : (`This is the start of #${channel.name} channel.`)),
|
|
72
|
+
messages.map((message) => (react_1.default.createElement(message_1.default, { message: message, context: Object.assign({ messages, channel, callbacks }, options), key: message.id }))),
|
|
73
|
+
react_1.default.createElement("div", { style: { textAlign: 'center', width: '100%' } },
|
|
74
|
+
options.footerText
|
|
75
|
+
? options.footerText
|
|
76
|
+
.replaceAll('{number}', messages.length.toString())
|
|
77
|
+
.replaceAll('{s}', messages.length > 1 ? 's' : '')
|
|
78
|
+
: `Exported ${messages.length} message${messages.length > 1 ? 's' : ''}.`,
|
|
79
|
+
' ',
|
|
80
|
+
options.poweredBy ? (react_1.default.createElement("span", { style: { textAlign: 'center' } },
|
|
81
|
+
"Powered by",
|
|
82
|
+
' ',
|
|
83
|
+
react_1.default.createElement("a", { href: "https://github.com/ItzDerock/discord-html-transcripts", style: { color: 'lightblue' } }, "spectre-html-transcripts"),
|
|
84
|
+
".")) : null)));
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=transcript.js.map
|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E,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CACnB,wCAAM,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;;gBACvB,GAAG;gBACd,qCAAG,IAAI,EAAC,uDAAuD,EAAC,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,+BAEzF;oBAEC,CACR,CAAC,CAAC,CAAC,IAAI,CACJ,CACmB,CAC5B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type Channel, type Message } from 'discord.js-selfbot-v13';
|
|
2
|
+
import DiscordMessages from './generator';
|
|
3
|
+
import { ExportReturnType, type CreateTranscriptOptions, type GenerateFromMessagesOptions, type ObjectType } from './types';
|
|
4
|
+
import { TranscriptImageDownloader } from './downloader/images';
|
|
5
|
+
import { isTextBasedChannel, isDMBasedChannel } from './utils/djsAdapter';
|
|
6
|
+
export { default as DiscordMessages } from './generator/transcript';
|
|
7
|
+
export { TranscriptImageDownloader } from './downloader/images';
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param messages The messages to generate a transcript from
|
|
11
|
+
* @param channel The channel the messages are from (used for header and guild name)
|
|
12
|
+
* @param options The options to use when generating the transcript
|
|
13
|
+
* @returns The generated transcript
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateFromMessages<T extends ExportReturnType = ExportReturnType.Attachment>(messages: Message[] | any, channel: Channel, options?: GenerateFromMessagesOptions<T>): Promise<ObjectType<T>>;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param channel The channel to create a transcript from
|
|
19
|
+
* @param options The options to use when creating the transcript
|
|
20
|
+
* @returns The generated transcript
|
|
21
|
+
*/
|
|
22
|
+
export declare function createTranscript<T extends ExportReturnType = ExportReturnType.Attachment>(channel: any, options?: CreateTranscriptOptions<T>): Promise<ObjectType<T>>;
|
|
23
|
+
declare const _default: {
|
|
24
|
+
createTranscript: typeof createTranscript;
|
|
25
|
+
generateFromMessages: typeof generateFromMessages;
|
|
26
|
+
TranscriptImageDownloader: typeof TranscriptImageDownloader;
|
|
27
|
+
ExportReturnType: typeof ExportReturnType;
|
|
28
|
+
isTextBasedChannel: typeof isTextBasedChannel;
|
|
29
|
+
isDMBasedChannel: typeof isDMBasedChannel;
|
|
30
|
+
DiscordMessages: typeof DiscordMessages;
|
|
31
|
+
version: string;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
34
|
+
export * from './types';
|
|
35
|
+
export * from './utils/djsAdapter';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,148 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
exports.TranscriptImageDownloader = exports.DiscordMessages = void 0;
|
|
21
|
+
exports.generateFromMessages = generateFromMessages;
|
|
22
|
+
exports.createTranscript = createTranscript;
|
|
23
|
+
const discord_js_selfbot_v13_1 = require("discord.js-selfbot-v13");
|
|
24
|
+
const generator_1 = __importDefault(require("./generator"));
|
|
25
|
+
const types_1 = require("./types");
|
|
26
|
+
const images_1 = require("./downloader/images");
|
|
27
|
+
const djsAdapter_1 = require("./utils/djsAdapter");
|
|
28
|
+
// re-exports
|
|
29
|
+
var transcript_1 = require("./generator/transcript");
|
|
30
|
+
Object.defineProperty(exports, "DiscordMessages", { enumerable: true, get: function () { return __importDefault(transcript_1).default; } });
|
|
31
|
+
var images_2 = require("./downloader/images");
|
|
32
|
+
Object.defineProperty(exports, "TranscriptImageDownloader", { enumerable: true, get: function () { return images_2.TranscriptImageDownloader; } });
|
|
33
|
+
// version check
|
|
34
|
+
const versionPrefix = discord_js_selfbot_v13_1.version.split('.')[0];
|
|
35
|
+
if (versionPrefix !== '14' && versionPrefix !== '15' && versionPrefix !== '3') {
|
|
36
|
+
console.error(`[spectre-html-transcripts] Versions v3.x.x of spectre-html-transcripts are only compatible with discord.js v14.x.x, v15.x.x, and discord.js-selfbot-v13 (v3.x.x). You are using v${discord_js_selfbot_v13_1.version}.` +
|
|
37
|
+
` For older v13 support, please install spectre-html-transcripts v2.x.x using "npm install spectre-html-transcripts@^2"`);
|
|
38
|
+
process.exit(1);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
* @param messages The messages to generate a transcript from
|
|
43
|
+
* @param channel The channel the messages are from (used for header and guild name)
|
|
44
|
+
* @param options The options to use when generating the transcript
|
|
45
|
+
* @returns The generated transcript
|
|
46
|
+
*/
|
|
47
|
+
async function generateFromMessages(messages, channel, options = {}) {
|
|
48
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
|
|
49
|
+
// turn messages into an array
|
|
50
|
+
const transformedMessages = messages && typeof messages.values === 'function' ? Array.from(messages.values()) : messages;
|
|
51
|
+
// figure out how the user wants images saved
|
|
52
|
+
let resolveImageSrc = (_b = (_a = options.callbacks) === null || _a === void 0 ? void 0 : _a.resolveImageSrc) !== null && _b !== void 0 ? _b : ((attachment) => attachment.url);
|
|
53
|
+
if (options.saveImages) {
|
|
54
|
+
if ((_c = options.callbacks) === null || _c === void 0 ? void 0 : _c.resolveImageSrc) {
|
|
55
|
+
console.warn(`[spectre-html-transcripts] You have specified both saveImages and resolveImageSrc, please only specify one. resolveImageSrc will be used.`);
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
// If the channel's client exposes a token (selfbot), attach it so private CDN images can be fetched
|
|
59
|
+
const token = (_d = channel.client) === null || _d === void 0 ? void 0 : _d.token;
|
|
60
|
+
const downloader = new images_1.TranscriptImageDownloader();
|
|
61
|
+
if (token)
|
|
62
|
+
downloader.withToken(token);
|
|
63
|
+
resolveImageSrc = downloader.build();
|
|
64
|
+
console.log('Using default downloader');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
// render the messages
|
|
68
|
+
const html = await (0, generator_1.default)({
|
|
69
|
+
messages: transformedMessages,
|
|
70
|
+
channel,
|
|
71
|
+
saveImages: (_e = options.saveImages) !== null && _e !== void 0 ? _e : true,
|
|
72
|
+
callbacks: Object.assign({ resolveImageSrc, resolveChannel: async (id) => channel.client.channels.fetch(id).catch(() => null), resolveUser: async (id) => channel.client.users.fetch(id).catch(() => null), resolveRole: (0, djsAdapter_1.isDMBasedChannel)(channel) ? () => null : async (id) => { var _a; return (_a = channel.guild) === null || _a === void 0 ? void 0 : _a.roles.fetch(id).catch(() => null); } }, ((_f = options.callbacks) !== null && _f !== void 0 ? _f : {})),
|
|
73
|
+
poweredBy: (_g = options.poweredBy) !== null && _g !== void 0 ? _g : true,
|
|
74
|
+
footerText: (_h = options.footerText) !== null && _h !== void 0 ? _h : 'Exported {number} message{s}.',
|
|
75
|
+
favicon: (_j = options.favicon) !== null && _j !== void 0 ? _j : 'guild',
|
|
76
|
+
hydrate: (_k = options.hydrate) !== null && _k !== void 0 ? _k : false,
|
|
77
|
+
});
|
|
78
|
+
// get the time it took to render the messages
|
|
79
|
+
// const renderTime = process.hrtime(startTime);
|
|
80
|
+
// console.log(
|
|
81
|
+
// `[discord-html-transcripts] Rendered ${transformedMessages.length} messages in ${renderTime[0]}s ${
|
|
82
|
+
// renderTime[1] / 1000000
|
|
83
|
+
// }ms`
|
|
84
|
+
// );
|
|
85
|
+
// return the html in the specified format
|
|
86
|
+
if (options.returnType === types_1.ExportReturnType.Buffer) {
|
|
87
|
+
return Buffer.from(html);
|
|
88
|
+
}
|
|
89
|
+
if (options.returnType === types_1.ExportReturnType.String) {
|
|
90
|
+
return html;
|
|
91
|
+
}
|
|
92
|
+
// Return a lightweight attachment-like object to avoid depending on a runtime MessageAttachment export
|
|
93
|
+
return { attachment: Buffer.from(html), name: (_l = options.filename) !== null && _l !== void 0 ? _l : `transcript-${channel.id}.html` };
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param channel The channel to create a transcript from
|
|
98
|
+
* @param options The options to use when creating the transcript
|
|
99
|
+
* @returns The generated transcript
|
|
100
|
+
*/
|
|
101
|
+
async function createTranscript(channel, options = {}) {
|
|
102
|
+
// validate type
|
|
103
|
+
if (!(0, djsAdapter_1.isTextBasedChannel)(channel)) {
|
|
104
|
+
throw new TypeError(`Provided channel must be text-based, received ${channel.type}`);
|
|
105
|
+
}
|
|
106
|
+
// fetch messages
|
|
107
|
+
let allMessages = [];
|
|
108
|
+
let lastMessageId;
|
|
109
|
+
const { limit, filter } = options;
|
|
110
|
+
const resolvedLimit = typeof limit === 'undefined' || limit === -1 ? Infinity : limit;
|
|
111
|
+
// until there are no more messages, keep fetching
|
|
112
|
+
while (true) {
|
|
113
|
+
// create fetch options
|
|
114
|
+
const fetchLimitOptions = { limit: 100, before: lastMessageId };
|
|
115
|
+
if (!lastMessageId)
|
|
116
|
+
delete fetchLimitOptions.before;
|
|
117
|
+
// fetch messages
|
|
118
|
+
const messages = await channel.messages.fetch(fetchLimitOptions);
|
|
119
|
+
const filteredMessages = typeof filter === 'function' ? messages.filter(filter) : messages;
|
|
120
|
+
// add the messages to the array
|
|
121
|
+
allMessages.push(...filteredMessages.values());
|
|
122
|
+
// Get the last key of 'messages', not 'filteredMessages' because you will be refetching the same messages
|
|
123
|
+
lastMessageId = messages.lastKey();
|
|
124
|
+
// if there are no more messages, break
|
|
125
|
+
if (messages.size < 100)
|
|
126
|
+
break;
|
|
127
|
+
// if the limit has been reached, break
|
|
128
|
+
if (allMessages.length >= resolvedLimit)
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
if (resolvedLimit < allMessages.length)
|
|
132
|
+
allMessages = allMessages.slice(0, limit);
|
|
133
|
+
// generate the transcript
|
|
134
|
+
return generateFromMessages(allMessages.reverse(), channel, options);
|
|
135
|
+
}
|
|
136
|
+
exports.default = {
|
|
137
|
+
createTranscript,
|
|
138
|
+
generateFromMessages,
|
|
139
|
+
TranscriptImageDownloader: images_1.TranscriptImageDownloader,
|
|
140
|
+
ExportReturnType: types_1.ExportReturnType,
|
|
141
|
+
isTextBasedChannel: djsAdapter_1.isTextBasedChannel,
|
|
142
|
+
isDMBasedChannel: djsAdapter_1.isDMBasedChannel,
|
|
143
|
+
DiscordMessages: generator_1.default,
|
|
144
|
+
version: discord_js_selfbot_v13_1.version,
|
|
145
|
+
};
|
|
146
|
+
__exportStar(require("./types"), exports);
|
|
147
|
+
__exportStar(require("./utils/djsAdapter"), exports);
|
|
148
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAiCA,oDAgEC;AAQD,4CA0CC;AAnJD,mEAA6E;AAC7E,4DAA0C;AAC1C,mCAKiB;AACjB,gDAA2F;AAC3F,mDAA0E;AAE1E,aAAa;AACb,qDAAoE;AAA3D,8HAAA,OAAO,OAAmB;AACnC,8CAAgE;AAAvD,mHAAA,yBAAyB,OAAA;AAElC,gBAAgB;AAChB,MAAM,aAAa,GAAG,gCAAO,CAAC,KAA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O,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAE3F,gCAAgC;QAChC,WAAW,CAAC,IAAI,CAAC,GAAG,gBAAgB,CAAC,MAAM,EAAE,CAAC,CAAC;QAC/C,0GAA0G;QAC1G,aAAa,GAAG,QAAQ,CAAC,OAAO,EAAE,CAAC;QAEnC,uCAAuC;QACvC,IAAI,QAAQ,CAAC,IAAI,GAAG,GAAG;YAAE,MAAM;QAE/B,uCAAuC;QACvC,IAAI,WAAW,CAAC,MAAM,IAAI,aAAa;YAAE,MAAM;IACjD,CAAC;IAED,IAAI,aAAa,GAAG,WAAW,CAAC,MAAM;QAAE,WAAW,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAElF,0BAA0B;IAC1B,OAAO,oBAAoB,CAAI,WAAW,CAAC,OAAO,EAAE,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED,kBAAe;IACb,gBAAgB;IAChB,oBAAoB;IACpB,yBAAyB,EAAzB,kCAAyB;IACzB,gBAAgB,EAAhB,wBAAgB;IAChB,kBAAkB,EAAlB,+BAAkB;IAClB,gBAAgB,EAAhB,6BAAgB;IAChB,eAAe,EAAf,mBAAe;IACf,OAAO,EAAP,gCAAO;CACR,CAAC;AACF,0CAAwB;AACxB,qDAAmC"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
export declare const scrollToMessage = "document.addEventListener(\"click\",t=>{let e=t.target;if(!e)return;let o=e?.getAttribute(\"data-goto\");if(o){let r=document.getElementById(`m-${o}`);r?(r.scrollIntoView({behavior:\"smooth\",block:\"center\"}),r.style.backgroundColor=\"rgba(148, 156, 247, 0.1)\",r.style.transition=\"background-color 0.5s ease\",setTimeout(()=>{r.style.backgroundColor=\"transparent\"},1e3)):console.warn(\"Message ${goto} not found.\")}});";
|
|
2
|
+
export declare const revealSpoiler = "const s=document.querySelectorAll(\".discord-spoiler\");s.forEach(s=>s.addEventListener(\"click\",()=>{if(s.classList.contains(\"discord-spoiler\")){s.classList.remove(\"discord-spoiler\");s.classList.add(\"discord-spoiler--revealed\");}}));";
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// TODO: create some sort of build system to compile this file
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.revealSpoiler = exports.scrollToMessage = void 0;
|
|
5
|
+
/*
|
|
6
|
+
// whenever user clicks on element with data-goto attribute, scroll to that message
|
|
7
|
+
document.addEventListener('click', (e) => {
|
|
8
|
+
const target = e.target;
|
|
9
|
+
if(!target) return;
|
|
10
|
+
|
|
11
|
+
const goto = target?.getAttribute('data-goto');
|
|
12
|
+
|
|
13
|
+
if (goto) {
|
|
14
|
+
const message = document.getElementById(`m-\${goto}`);
|
|
15
|
+
if (message) {
|
|
16
|
+
message.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
17
|
+
message.style.backgroundColor = 'rgba(148, 156, 247, 0.1)';
|
|
18
|
+
message.style.transition = 'background-color 0.5s ease';
|
|
19
|
+
setTimeout(() => {
|
|
20
|
+
message.style.backgroundColor = 'transparent';
|
|
21
|
+
}, 1000);
|
|
22
|
+
} else {
|
|
23
|
+
console.warn(`Message \${goto} not found.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
*/
|
|
28
|
+
exports.scrollToMessage = 'document.addEventListener("click",t=>{let e=t.target;if(!e)return;let o=e?.getAttribute("data-goto");if(o){let r=document.getElementById(`m-${o}`);r?(r.scrollIntoView({behavior:"smooth",block:"center"}),r.style.backgroundColor="rgba(148, 156, 247, 0.1)",r.style.transition="background-color 0.5s ease",setTimeout(()=>{r.style.backgroundColor="transparent"},1e3)):console.warn("Message ${goto} not found.")}});';
|
|
29
|
+
exports.revealSpoiler = 'const s=document.querySelectorAll(".discord-spoiler");s.forEach(s=>s.addEventListener("click",()=>{if(s.classList.contains("discord-spoiler")){s.classList.remove("discord-spoiler");s.classList.add("discord-spoiler--revealed");}}));';
|
|
30
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/static/client.ts"],"names":[],"mappings":";AAAA,8DAA8D;;;AAE9D;;;;;;;;;;;;;;;;;;;;;;EAsBE;AACW,QAAA,eAAe,GAC1B,2ZAA2Z,CAAC;AAEjZ,QAAA,aAAa,GACxB,yOAAyO,CAAC"}
|
package/dist/test.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Test script for spectre-html-transcripts
|
|
5
|
+
* This script tests the basic functionality of the module
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require('fs');
|
|
9
|
+
const path = require('path');
|
|
10
|
+
|
|
11
|
+
// Import the compiled module
|
|
12
|
+
const spectre = require('./index.js');
|
|
13
|
+
|
|
14
|
+
console.log('๐งช Testing spectre-html-transcripts...\n');
|
|
15
|
+
|
|
16
|
+
// Test 1: Check if module exports exist
|
|
17
|
+
console.log('โ
Test 1: Module exports');
|
|
18
|
+
console.log('Available exports:', Object.keys(spectre));
|
|
19
|
+
console.log('');
|
|
20
|
+
|
|
21
|
+
// Test 2: Check if main functions exist
|
|
22
|
+
console.log('โ
Test 2: Main functions');
|
|
23
|
+
console.log('createTranscript exists:', typeof spectre.createTranscript === 'function');
|
|
24
|
+
console.log('generateFromMessages exists:', typeof spectre.generateFromMessages === 'function');
|
|
25
|
+
console.log('');
|
|
26
|
+
|
|
27
|
+
// Test 3: Check types export
|
|
28
|
+
console.log('โ
Test 3: Types export');
|
|
29
|
+
console.log('ExportReturnType exists:', 'ExportReturnType' in spectre);
|
|
30
|
+
console.log('CreateTranscriptOptions exists:', 'CreateTranscriptOptions' in spectre);
|
|
31
|
+
console.log('GenerateFromMessagesOptions exists:', 'GenerateFromMessagesOptions' in spectre);
|
|
32
|
+
console.log('ObjectType exists:', 'ObjectType' in spectre);
|
|
33
|
+
console.log('');
|
|
34
|
+
|
|
35
|
+
// Test 4: Check downloader export
|
|
36
|
+
console.log('โ
Test 4: Downloader export');
|
|
37
|
+
console.log('TranscriptImageDownloader exists:', 'TranscriptImageDownloader' in spectre);
|
|
38
|
+
console.log('ResolveImageCallback exists:', 'ResolveImageCallback' in spectre);
|
|
39
|
+
console.log('');
|
|
40
|
+
|
|
41
|
+
// Test 5: Check adapter exports
|
|
42
|
+
console.log('โ
Test 5: Adapter exports');
|
|
43
|
+
console.log('isTextBasedChannel exists:', typeof spectre.isTextBasedChannel === 'function');
|
|
44
|
+
console.log('isDMBasedChannel exists:', typeof spectre.isDMBasedChannel === 'function');
|
|
45
|
+
console.log('isThreadChannel exists:', typeof spectre.isThreadChannel === 'function');
|
|
46
|
+
console.log('isVoiceBasedChannel exists:', typeof spectre.isVoiceBasedChannel === 'function');
|
|
47
|
+
console.log('getChannelTypeFrom exists:', typeof spectre.getChannelTypeFrom === 'function');
|
|
48
|
+
console.log('');
|
|
49
|
+
|
|
50
|
+
// Test 6: Check DiscordMessages component
|
|
51
|
+
console.log('โ
Test 6: DiscordMessages component');
|
|
52
|
+
console.log('DiscordMessages exists:', typeof spectre.DiscordMessages === 'function');
|
|
53
|
+
console.log('');
|
|
54
|
+
|
|
55
|
+
// Test 7: Check version
|
|
56
|
+
console.log('โ
Test 7: Version');
|
|
57
|
+
console.log('discord.js-selfbot-v13 version:', spectre.version);
|
|
58
|
+
console.log('');
|
|
59
|
+
|
|
60
|
+
console.log('๐ All basic tests passed!');
|
|
61
|
+
console.log('The spectre-html-transcripts module is working correctly.');
|
|
62
|
+
console.log('');
|
|
63
|
+
console.log('๐ To test with actual Discord data, use the test scripts in the tests/ directory:');
|
|
64
|
+
console.log(' npm run test:typescript');
|
|
65
|
+
console.log(' npm run test:send-components-v2');
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import type { Message } from 'discord.js-selfbot-v13';
|
|
2
|
+
import type { RenderMessageContext } from './generator';
|
|
3
|
+
export interface ImageHostConfig {
|
|
4
|
+
enabled: boolean;
|
|
5
|
+
service: 'freeimage' | 'imgbb' | 'custom';
|
|
6
|
+
apiKey?: string;
|
|
7
|
+
customApiUrl?: string;
|
|
8
|
+
customUploadEndpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
export type AttachmentTypes = 'audio' | 'video' | 'image' | 'file';
|
|
11
|
+
export declare enum ExportReturnType {
|
|
12
|
+
Buffer = "buffer",
|
|
13
|
+
String = "string",
|
|
14
|
+
Attachment = "attachment"
|
|
15
|
+
}
|
|
16
|
+
export type ObjectType<T extends ExportReturnType> = T extends ExportReturnType.Buffer ? Buffer : T extends ExportReturnType.String ? string : any;
|
|
17
|
+
export type GenerateFromMessagesOptions<T extends ExportReturnType> = Partial<{
|
|
18
|
+
/**
|
|
19
|
+
* The type of object to return
|
|
20
|
+
* @default ExportReturnType.ATTACHMENT
|
|
21
|
+
*/
|
|
22
|
+
returnType: T;
|
|
23
|
+
/**
|
|
24
|
+
* Downloads images and encodes them as base64 data urls
|
|
25
|
+
* @default false
|
|
26
|
+
*/
|
|
27
|
+
saveImages: boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Callbacks for resolving channels, users, and roles
|
|
30
|
+
*/
|
|
31
|
+
callbacks: Partial<RenderMessageContext['callbacks']>;
|
|
32
|
+
/**
|
|
33
|
+
* The name of the file to return if returnType is ExportReturnType.ATTACHMENT
|
|
34
|
+
* @default 'transcript-{channel-id}.html'
|
|
35
|
+
*/
|
|
36
|
+
filename: string;
|
|
37
|
+
/**
|
|
38
|
+
* Whether to include the "Powered by spectre-html-transcripts" footer
|
|
39
|
+
* @default true
|
|
40
|
+
*/
|
|
41
|
+
poweredBy: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* The message right before "Powered by" text. Remember to put the {s}
|
|
44
|
+
* @default 'Exported {number} message{s}.'
|
|
45
|
+
*/
|
|
46
|
+
footerText: string;
|
|
47
|
+
/**
|
|
48
|
+
* Whether to show the guild icon or a custom icon as the favicon
|
|
49
|
+
* 'guild' - use the guild icon
|
|
50
|
+
* or pass in a url to use a custom icon
|
|
51
|
+
* @default "guild"
|
|
52
|
+
*/
|
|
53
|
+
favicon: 'guild' | string;
|
|
54
|
+
/**
|
|
55
|
+
* Whether to hydrate the html server-side
|
|
56
|
+
* @default false - the returned html will be hydrated client-side
|
|
57
|
+
*/
|
|
58
|
+
hydrate: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* Image hosting configuration to upload images to external services
|
|
61
|
+
* This prevents image loss and reduces HTML file size
|
|
62
|
+
*/
|
|
63
|
+
imageHost?: ImageHostConfig;
|
|
64
|
+
}>;
|
|
65
|
+
export type CreateTranscriptOptions<T extends ExportReturnType> = Partial<GenerateFromMessagesOptions<T> & {
|
|
66
|
+
/**
|
|
67
|
+
* The max amount of messages to fetch. Use `-1` to recursively fetch.
|
|
68
|
+
*/
|
|
69
|
+
limit: number;
|
|
70
|
+
/**
|
|
71
|
+
* Filter messages of the channel
|
|
72
|
+
* @default (() => true)
|
|
73
|
+
*/
|
|
74
|
+
filter: (message: Message) => boolean;
|
|
75
|
+
}>;
|