sweety-html-transcripts 0.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/LICENSE +201 -0
- package/README.md +127 -0
- package/dist/adapters/core.d.ts +41 -0
- package/dist/adapters/core.js +30 -0
- package/dist/adapters/core.js.map +1 -0
- package/dist/adapters/discordjs.d.ts +26 -0
- package/dist/adapters/discordjs.js +102 -0
- package/dist/adapters/discordjs.js.map +1 -0
- package/dist/adapters/seyfert.d.ts +26 -0
- package/dist/adapters/seyfert.js +67 -0
- package/dist/adapters/seyfert.js.map +1 -0
- package/dist/downloader/images.d.ts +37 -0
- package/dist/downloader/images.js +119 -0
- package/dist/downloader/images.js.map +1 -0
- package/dist/generator/index.d.ts +34 -0
- package/dist/generator/index.js +81 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/renderers/attachment.d.ts +24 -0
- package/dist/generator/renderers/attachment.js +133 -0
- package/dist/generator/renderers/attachment.js.map +1 -0
- package/dist/generator/renderers/components.d.ts +8 -0
- package/dist/generator/renderers/components.js +179 -0
- package/dist/generator/renderers/components.js.map +1 -0
- package/dist/generator/renderers/content.d.ts +32 -0
- package/dist/generator/renderers/content.js +168 -0
- package/dist/generator/renderers/content.js.map +1 -0
- package/dist/generator/renderers/embed.d.ts +15 -0
- package/dist/generator/renderers/embed.js +77 -0
- package/dist/generator/renderers/embed.js.map +1 -0
- package/dist/generator/renderers/message.d.ts +15 -0
- package/dist/generator/renderers/message.js +95 -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 +76 -0
- package/dist/generator/renderers/reply.js.map +1 -0
- package/dist/generator/renderers/systemMessage.d.ts +19 -0
- package/dist/generator/renderers/systemMessage.js +109 -0
- package/dist/generator/renderers/systemMessage.js.map +1 -0
- package/dist/generator/transcript.d.ts +12 -0
- package/dist/generator/transcript.js +85 -0
- package/dist/generator/transcript.js.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +143 -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/types.d.ts +69 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/api.d.ts +19 -0
- package/dist/utils/api.js +364 -0
- package/dist/utils/api.js.map +1 -0
- package/dist/utils/cdn.d.ts +28 -0
- package/dist/utils/cdn.js +61 -0
- package/dist/utils/cdn.js.map +1 -0
- package/dist/utils/channel.d.ts +34 -0
- package/dist/utils/channel.js +51 -0
- package/dist/utils/channel.js.map +1 -0
- package/dist/utils/embeds.d.ts +2 -0
- package/dist/utils/embeds.js +17 -0
- package/dist/utils/embeds.js.map +1 -0
- package/dist/utils/guild.d.ts +9 -0
- package/dist/utils/guild.js +19 -0
- package/dist/utils/guild.js.map +1 -0
- package/dist/utils/message.d.ts +6 -0
- package/dist/utils/message.js +11 -0
- package/dist/utils/message.js.map +1 -0
- package/dist/utils/profiles.d.ts +18 -0
- package/dist/utils/profiles.js +67 -0
- package/dist/utils/profiles.js.map +1 -0
- package/dist/utils/replacer.d.ts +28 -0
- package/dist/utils/replacer.js +67 -0
- package/dist/utils/replacer.js.map +1 -0
- package/dist/utils/user.d.ts +18 -0
- package/dist/utils/user.js +38 -0
- package/dist/utils/user.js.map +1 -0
- package/dist/utils/utils.d.ts +32 -0
- package/dist/utils/utils.js +61 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,109 @@
|
|
|
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.SystemMessageTypes = void 0;
|
|
7
|
+
exports.default = SystemMessage;
|
|
8
|
+
exports.Highlight = Highlight;
|
|
9
|
+
exports.JoinMessage = JoinMessage;
|
|
10
|
+
const discord_components_react_render_1 = require("@penwin/discord-components-react-render");
|
|
11
|
+
const v10_1 = require("discord-api-types/v10");
|
|
12
|
+
const react_1 = __importDefault(require("react"));
|
|
13
|
+
const user_1 = require("../../utils/user");
|
|
14
|
+
const utils_1 = require("../../utils/utils");
|
|
15
|
+
exports.SystemMessageTypes = [
|
|
16
|
+
v10_1.MessageType.RecipientAdd,
|
|
17
|
+
v10_1.MessageType.UserJoin,
|
|
18
|
+
v10_1.MessageType.ChannelPinnedMessage,
|
|
19
|
+
v10_1.MessageType.GuildBoost,
|
|
20
|
+
v10_1.MessageType.GuildBoostTier1,
|
|
21
|
+
v10_1.MessageType.GuildBoostTier2,
|
|
22
|
+
v10_1.MessageType.GuildBoostTier3,
|
|
23
|
+
v10_1.MessageType.ThreadStarterMessage,
|
|
24
|
+
];
|
|
25
|
+
async function SystemMessage({ message, context, }) {
|
|
26
|
+
const member = await context.adapter.resolveGuildMember(message.guild_id, message.author.id);
|
|
27
|
+
const role = await context.adapter.resolveHighestGuildMemberRole(member, message.guild_id);
|
|
28
|
+
switch (message.type) {
|
|
29
|
+
case v10_1.MessageType.RecipientAdd:
|
|
30
|
+
case v10_1.MessageType.UserJoin:
|
|
31
|
+
return (react_1.default.createElement(discord_components_react_render_1.DiscordSystemMessage, { id: `m-${message.id}`, key: message.id, type: "join" },
|
|
32
|
+
react_1.default.createElement(JoinMessage, { member: message.member, fallbackUser: message.author })));
|
|
33
|
+
case v10_1.MessageType.ChannelPinnedMessage:
|
|
34
|
+
return (react_1.default.createElement(discord_components_react_render_1.DiscordSystemMessage, { id: `m-${message.id}`, key: message.id, type: "pin" },
|
|
35
|
+
react_1.default.createElement(Highlight, { color: (0, utils_1.convertToHEX)(role?.color) }, user_1.userUtils.displayName(message.author)),
|
|
36
|
+
" pinned",
|
|
37
|
+
' ',
|
|
38
|
+
react_1.default.createElement("i", { "data-goto": message.message_reference?.message_id }, "a message"),
|
|
39
|
+
" to this channel.",
|
|
40
|
+
message.reactions && message.reactions.length > 0 && (react_1.default.createElement(discord_components_react_render_1.DiscordReactions, { slot: "reactions" }, message.reactions.map((reaction, id) => (react_1.default.createElement(discord_components_react_render_1.DiscordReaction, { key: `${message.id}r${id}`, name: reaction.emoji.name, emoji: (0, utils_1.parseDiscordEmoji)(reaction.emoji), count: reaction.count })))))));
|
|
41
|
+
case v10_1.MessageType.GuildBoost:
|
|
42
|
+
case v10_1.MessageType.GuildBoostTier1:
|
|
43
|
+
case v10_1.MessageType.GuildBoostTier2:
|
|
44
|
+
case v10_1.MessageType.GuildBoostTier3:
|
|
45
|
+
return (react_1.default.createElement(discord_components_react_render_1.DiscordSystemMessage, { id: `m-${message.id}`, key: message.id, type: "boost" },
|
|
46
|
+
react_1.default.createElement(Highlight, { color: (0, utils_1.convertToHEX)(role?.color) }, user_1.userUtils.displayName(message.author)),
|
|
47
|
+
" boosted the server!"));
|
|
48
|
+
case v10_1.MessageType.ThreadStarterMessage:
|
|
49
|
+
return (react_1.default.createElement(discord_components_react_render_1.DiscordSystemMessage, { id: `ms-${message.id}`, key: message.id, type: "thread" },
|
|
50
|
+
react_1.default.createElement(Highlight, { color: (0, utils_1.convertToHEX)(role?.color) }, user_1.userUtils.displayName(message.author)),
|
|
51
|
+
" started a thread: ",
|
|
52
|
+
react_1.default.createElement("i", { "data-goto": message.message_reference?.message_id }, message.content)));
|
|
53
|
+
default:
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function Highlight({ children, color }) {
|
|
58
|
+
return react_1.default.createElement("i", { style: { color: color ?? 'white' } }, children);
|
|
59
|
+
}
|
|
60
|
+
const allJoinMessages = [
|
|
61
|
+
'{user} just joined the server - glhf!',
|
|
62
|
+
'{user} just joined. Everyone, look busy!',
|
|
63
|
+
'{user} just joined. Can I get a heal?',
|
|
64
|
+
'{user} joined your party.',
|
|
65
|
+
'{user} joined. You must construct additional pylons.',
|
|
66
|
+
'Ermagherd. {user} is here.',
|
|
67
|
+
'Welcome, {user}. Stay awhile and listen.',
|
|
68
|
+
'Welcome, {user}. We were expecting you ( ͡° ͜ʖ ͡°)',
|
|
69
|
+
'Welcome, {user}. We hope you brought pizza.',
|
|
70
|
+
'Welcome {user}. Leave your weapons by the door.',
|
|
71
|
+
'A wild {user} appeared.',
|
|
72
|
+
'Swoooosh. {user} just landed.',
|
|
73
|
+
'Brace yourselves {user} just joined the server.',
|
|
74
|
+
'{user} just joined. Hide your bananas.',
|
|
75
|
+
'{user} just arrived. Seems OP - please nerf.',
|
|
76
|
+
'{user} just slid into the server.',
|
|
77
|
+
'A {user} has spawned in the server.',
|
|
78
|
+
'Big {user} showed up!',
|
|
79
|
+
"Where's {user}? In the server!",
|
|
80
|
+
'{user} hopped into the server. Kangaroo!!',
|
|
81
|
+
'{user} just showed up. Hold my beer.',
|
|
82
|
+
'Challenger approaching - {user} has appeared!',
|
|
83
|
+
"It's a bird! It's a plane! Nevermind, it's just {user}.",
|
|
84
|
+
"It's {user}! Praise the sun! \\\\[T]/",
|
|
85
|
+
'Never gonna give {user} up. Never gonna let {user} down.',
|
|
86
|
+
'Ha! {user} has joined! You activated my trap card!',
|
|
87
|
+
'Cheers, love! {user} is here!',
|
|
88
|
+
'Hey! Listen! {user} has joined!',
|
|
89
|
+
"We've been expecting you {user}",
|
|
90
|
+
"It's dangerous to go alone, take {user}!",
|
|
91
|
+
"{user} has joined the server! It's super effective!",
|
|
92
|
+
'Cheers, love! {user} is here!',
|
|
93
|
+
'{user} is here, as the prophecy foretold.',
|
|
94
|
+
"{user} has arrived. Party's over.",
|
|
95
|
+
'Ready player {user}',
|
|
96
|
+
'{user} is here to kick butt and chew bubblegum. And {user} is all out of gum.',
|
|
97
|
+
"Hello. Is it {user} you're looking for?",
|
|
98
|
+
];
|
|
99
|
+
async function JoinMessage({ member, fallbackUser, highestRole, }) {
|
|
100
|
+
const randomMessage = allJoinMessages[Math.floor(Math.random() * allJoinMessages.length)];
|
|
101
|
+
return randomMessage
|
|
102
|
+
.split('{user}')
|
|
103
|
+
.flatMap((item, i) => [
|
|
104
|
+
item,
|
|
105
|
+
react_1.default.createElement(Highlight, { color: (0, utils_1.convertToHEX)(highestRole?.color), key: i }, member?.nick ?? user_1.userUtils.displayName(fallbackUser)),
|
|
106
|
+
])
|
|
107
|
+
.slice(0, -1);
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=systemMessage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"systemMessage.js","sourceRoot":"","sources":["../../../src/generator/renderers/systemMessage.tsx"],"names":[],"mappings":";;;;;;AAoBA,gCA8DC;AAED,8BAEC;AA0CD,kCAoBC;AApJD,6FAAkH;AAElH,+CAAoD;AACpD,kDAA0B;AAG1B,2CAA6C;AAC7C,6CAAoE;AAEvD,QAAA,kBAAkB,GAAG;IAChC,iBAAW,CAAC,YAAY;IACxB,iBAAW,CAAC,QAAQ;IACpB,iBAAW,CAAC,oBAAoB;IAChC,iBAAW,CAAC,UAAU;IACtB,iBAAW,CAAC,eAAe;IAC3B,iBAAW,CAAC,eAAe;IAC3B,iBAAW,CAAC,eAAe;IAC3B,iBAAW,CAAC,oBAAoB;CACjC,CAAC;AAEa,KAAK,UAAU,aAAa,CAAC,EAC1C,OAAO,EACP,OAAO,GAIR;IACC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,QAAS,EAAE,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC9F,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,MAAO,EAAE,OAAO,CAAC,QAAS,CAAC,CAAC;IAE7F,QAAQ,OAAO,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,iBAAW,CAAC,YAAY,CAAC;QAC9B,KAAK,iBAAW,CAAC,QAAQ;YACvB,OAAO,CACL,8BAAC,sDAAoB,IAAC,EAAE,E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IACrC,uBAAuB;IACvB,gCAAgC;IAChC,2CAA2C;IAC3C,sCAAsC;IACtC,+CAA+C;IAC/C,yDAAyD;IACzD,uCAAuC;IACvC,0DAA0D;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;AAEK,KAAK,UAAU,WAAW,CAAC,EAChC,MAAM,EACN,YAAY,EACZ,WAAW,GAKZ;IACC,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,CAAC;QACpB,IAAI;QACJ,8BAAC,SAAS,IAAC,KAAK,EAAE,IAAA,oBAAY,EAAC,WAAW,EAAE,KAAK,CAAC,EAAE,GAAG,EAAE,CAAC,IACvD,MAAM,EAAE,IAAI,IAAI,gBAAS,CAAC,WAAW,CAAC,YAAY,CAAC,CAC1C;KACb,CAAC;SACD,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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({ context }: {
|
|
11
|
+
context: RenderMessageContext;
|
|
12
|
+
}): Promise<React.JSX.Element>;
|
|
@@ -0,0 +1,85 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.default = DiscordMessages;
|
|
40
|
+
const discord_components_react_render_1 = require("@penwin/discord-components-react-render");
|
|
41
|
+
const react_1 = __importDefault(require("react"));
|
|
42
|
+
const content_1 = __importStar(require("./renderers/content"));
|
|
43
|
+
const message_1 = __importDefault(require("./renderers/message"));
|
|
44
|
+
const v10_1 = require("discord-api-types/v10");
|
|
45
|
+
const channel_1 = require("../utils/channel");
|
|
46
|
+
const guild_1 = require("../utils/guild");
|
|
47
|
+
const package_json_1 = require("../../package.json");
|
|
48
|
+
const github = package_json_1.repository?.url?.split(/\+|\.git/)?.[1].trim() ?? package_json_1.repository.url;
|
|
49
|
+
/**
|
|
50
|
+
* The core transcript component.
|
|
51
|
+
* Expects window.$discordMessage.profiles to be set for profile information.
|
|
52
|
+
*
|
|
53
|
+
* @param props Messages, channel details, callbacks, etc.
|
|
54
|
+
* @returns
|
|
55
|
+
*/
|
|
56
|
+
async function DiscordMessages({ context }) {
|
|
57
|
+
const { messages, channel, guild, ...options } = context;
|
|
58
|
+
return (react_1.default.createElement(discord_components_react_render_1.DiscordMessages, { style: { minHeight: '100vh' } },
|
|
59
|
+
react_1.default.createElement(discord_components_react_render_1.DiscordTranscriptHeader, { guild:
|
|
60
|
+
// channel.isDM() || channel.isDirectory() ? 'Direct Messages' : (channel as AllGuildTextableChannels).guild.name
|
|
61
|
+
// (channelUtils.isDM(channel) || channelUtils.isDirectory(channel)) ? 'Direct Messages' : channel.guild
|
|
62
|
+
guild?.name ?? 'Direct Messages', channel: channel_1.channelUtils.isDM(channel)
|
|
63
|
+
? channel.type === v10_1.ChannelType.DM
|
|
64
|
+
? (channel.recipients?.find((r) => r.id !== channel.id)?.username ?? 'Unknown Recipient')
|
|
65
|
+
: 'Unknown Recipient'
|
|
66
|
+
: channel_1.channelUtils.isDirectory(channel)
|
|
67
|
+
? 'Unknown Directory'
|
|
68
|
+
: channel.name, icon: channel_1.channelUtils.isDM(channel) || channel_1.channelUtils.isDirectory(channel)
|
|
69
|
+
? undefined
|
|
70
|
+
: ((context.guild ? guild_1.guildUtils.iconURL(context.guild, { size: 128 }) : undefined) ?? undefined) }, channel_1.channelUtils.isThread(channel) ? (`Thread channel in ${channel.parent_id ?? 'Unknown Channel'}`) : channel_1.channelUtils.isDM(channel) ? (`Direct Messages`) : channel_1.channelUtils.isVoice(channel) ? (`Voice Text Channel for ${channel.name}`) : channel.type === v10_1.ChannelType.GuildCategory ? (`Category Channel`) : 'topic' in channel && channel.topic ? (react_1.default.createElement(content_1.default, { content: channel.topic, context: { type: content_1.RenderType.REPLY, ...context } })) : channel_1.channelUtils.isDirectory(channel) ? (`This is the start of the directory.`) : (`This is the start of #${channel.name} channel.`)),
|
|
71
|
+
messages.map((message) => (react_1.default.createElement(message_1.default, { message: message, context: context, key: message.id }))),
|
|
72
|
+
react_1.default.createElement("div", { style: { textAlign: 'center', width: '100%' } },
|
|
73
|
+
options.footerText
|
|
74
|
+
? options.footerText
|
|
75
|
+
.replaceAll('{number}', messages.length.toString())
|
|
76
|
+
.replaceAll('{s}', messages.length > 1 ? 's' : '')
|
|
77
|
+
: `Exported ${messages.length} message${messages.length > 1 ? 's' : ''}.`,
|
|
78
|
+
' ',
|
|
79
|
+
options.poweredBy ? (react_1.default.createElement("span", { style: { textAlign: 'center' } },
|
|
80
|
+
"Powered by",
|
|
81
|
+
' ',
|
|
82
|
+
react_1.default.createElement("a", { href: github, style: { color: 'lightblue' } }, package_json_1.name),
|
|
83
|
+
".")) : null)));
|
|
84
|
+
}
|
|
85
|
+
//# sourceMappingURL=transcript.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transcript.js","sourceRoot":"","sources":["../../src/generator/transcript.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuBA,kCAoEC;AA3FD,6FAGiD;AACjD,kDAA0B;AAE1B,+DAAiE;AACjE,kEAAiD;AACjD,+CAAoD;AAEpD,8CAAgD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EAAE,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAAE,CAAC;qBAClD,UAAU,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC;gBACtD,CAAC,CAAC,YAAY,QAAQ,CAAC,MAAM,WAAW,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG;YAAE,GAAG;YAC/E,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,CACnB,wCAAM,KAAK,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;;gBACvB,GAAG;gBACd,qCAAG,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,IAC3C,mBAAW,CACV;oBAEC,CACR,CAAC,CAAC,CAAC,IAAI,CACJ,CACmB,CAC5B,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { TranscriptAdapter } from './adapters/core';
|
|
2
|
+
import { ExportReturnType, type CreateTranscriptOptions, type GenerateFromMessagesOptions, type ObjectType } from './types';
|
|
3
|
+
import type { APIMessageData } from './utils/channel';
|
|
4
|
+
export { TranscriptImageDownloader } from './downloader/images';
|
|
5
|
+
export { default as DiscordMessages } from './generator/transcript';
|
|
6
|
+
export * from './types';
|
|
7
|
+
export * from './adapters/core';
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* Generate a transcript from an array of messages.
|
|
11
|
+
* @param messages The messages to generate a transcript from
|
|
12
|
+
* @param options The options to use when generating the transcript
|
|
13
|
+
* @returns The generated transcript
|
|
14
|
+
*/
|
|
15
|
+
export declare function generateFromMessages<Adapter extends TranscriptAdapter<unknown>, T extends ExportReturnType = ExportReturnType.Attachment>(messages: APIMessageData[], options: GenerateFromMessagesOptions<T, Adapter>): Promise<ObjectType<T, Adapter>>;
|
|
16
|
+
/**
|
|
17
|
+
* Create a transcript from a channel.
|
|
18
|
+
* @param options The options to use when creating the transcript
|
|
19
|
+
* @returns The generated transcript
|
|
20
|
+
*/
|
|
21
|
+
export declare function createTranscript<Adapter extends TranscriptAdapter<unknown>, T extends ExportReturnType = ExportReturnType.Attachment>(options: CreateTranscriptOptions<T, Adapter>): Promise<ObjectType<T, Adapter>>;
|
|
22
|
+
declare const _default: {
|
|
23
|
+
createTranscript: typeof createTranscript;
|
|
24
|
+
generateFromMessages: typeof generateFromMessages;
|
|
25
|
+
};
|
|
26
|
+
export default _default;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
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.DiscordMessages = exports.TranscriptImageDownloader = void 0;
|
|
21
|
+
exports.generateFromMessages = generateFromMessages;
|
|
22
|
+
exports.createTranscript = createTranscript;
|
|
23
|
+
const seyfert_1 = require("seyfert");
|
|
24
|
+
const images_1 = require("./downloader/images");
|
|
25
|
+
const generator_1 = __importDefault(require("./generator"));
|
|
26
|
+
const types_1 = require("./types");
|
|
27
|
+
const channel_1 = require("./utils/channel");
|
|
28
|
+
const package_json_1 = require("../package.json");
|
|
29
|
+
// re-exports
|
|
30
|
+
var images_2 = require("./downloader/images");
|
|
31
|
+
Object.defineProperty(exports, "TranscriptImageDownloader", { enumerable: true, get: function () { return images_2.TranscriptImageDownloader; } });
|
|
32
|
+
var transcript_1 = require("./generator/transcript");
|
|
33
|
+
Object.defineProperty(exports, "DiscordMessages", { enumerable: true, get: function () { return __importDefault(transcript_1).default; } });
|
|
34
|
+
__exportStar(require("./types"), exports);
|
|
35
|
+
// adapter exports
|
|
36
|
+
__exportStar(require("./adapters/core"), exports);
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* Generate a transcript from an array of messages.
|
|
40
|
+
* @param messages The messages to generate a transcript from
|
|
41
|
+
* @param options The options to use when generating the transcript
|
|
42
|
+
* @returns The generated transcript
|
|
43
|
+
*/
|
|
44
|
+
async function generateFromMessages(messages, options) {
|
|
45
|
+
const { adapter, channel } = options;
|
|
46
|
+
const guild = 'guild_id' in channel && channel.guild_id ? await adapter.resolveGuild(channel.guild_id) : null;
|
|
47
|
+
// turn messages into an array
|
|
48
|
+
const transformedMessages = messages instanceof seyfert_1.Collection ? Array.from(messages.values()) : messages;
|
|
49
|
+
const allMessages = transformedMessages.map((message) => {
|
|
50
|
+
if (channel_1.channelUtils.isDM(channel) || channel_1.channelUtils.isDirectory(channel))
|
|
51
|
+
return message;
|
|
52
|
+
// dale a tu cuerpo alegría, macarena
|
|
53
|
+
// ts is dumb because for some reason guild_id doesn't exist sometimes
|
|
54
|
+
message.guild_id ?? (message.guild_id = guild?.id);
|
|
55
|
+
return message;
|
|
56
|
+
});
|
|
57
|
+
// figure out how the user wants images saved
|
|
58
|
+
let resolveImageSrc = options.callbacks?.resolveImageSrc ?? ((attachment) => attachment.url);
|
|
59
|
+
if (options.saveImages) {
|
|
60
|
+
if (options.callbacks?.resolveImageSrc) {
|
|
61
|
+
console.warn(`[${package_json_1.name}] You have specified both saveImages and resolveImageSrc, please only specify one. resolveImageSrc will be used.`);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
resolveImageSrc = new images_1.TranscriptImageDownloader().build();
|
|
65
|
+
console.log('Using default downloader');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
// render the messages
|
|
69
|
+
const html = await (0, generator_1.default)({
|
|
70
|
+
adapter,
|
|
71
|
+
channel,
|
|
72
|
+
guild,
|
|
73
|
+
messages: allMessages,
|
|
74
|
+
saveImages: options.saveImages ?? false,
|
|
75
|
+
callbacks: {
|
|
76
|
+
resolveImageSrc,
|
|
77
|
+
resolveChannel: async (id) => adapter.resolveChannel(id),
|
|
78
|
+
resolveUser: async (id) => adapter.resolveUser(id),
|
|
79
|
+
resolveRole: async (id) => (guild ? adapter.resolveRole(guild.id, id) : null),
|
|
80
|
+
...(options.callbacks ?? {}),
|
|
81
|
+
},
|
|
82
|
+
poweredBy: options.poweredBy ?? true,
|
|
83
|
+
footerText: options.footerText ?? 'Exported {number} message{s}.',
|
|
84
|
+
favicon: options.favicon ?? 'guild',
|
|
85
|
+
hydrate: options.hydrate ?? false,
|
|
86
|
+
});
|
|
87
|
+
// return the html in the specified format
|
|
88
|
+
if (options.returnType === types_1.ExportReturnType.Buffer) {
|
|
89
|
+
return Buffer.from(html);
|
|
90
|
+
}
|
|
91
|
+
if (options.returnType === types_1.ExportReturnType.String) {
|
|
92
|
+
return html;
|
|
93
|
+
}
|
|
94
|
+
return adapter.createTranscriptAttachment(html, options.filename ?? `transcript-${channel.id}.html`);
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Create a transcript from a channel.
|
|
98
|
+
* @param options The options to use when creating the transcript
|
|
99
|
+
* @returns The generated transcript
|
|
100
|
+
*/
|
|
101
|
+
async function createTranscript(options) {
|
|
102
|
+
const { channel, adapter } = options;
|
|
103
|
+
// validate type
|
|
104
|
+
if (!channel_1.channelUtils.isGuildTextable(channel))
|
|
105
|
+
throw new TypeError(`Provided channel must be text-based, received ${channel.type}`);
|
|
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
|
+
// calculate how many messages we still need to fetch
|
|
114
|
+
const remainingMessages = resolvedLimit - allMessages.length;
|
|
115
|
+
const fetchLimit = Math.min(100, remainingMessages);
|
|
116
|
+
// create fetch options
|
|
117
|
+
const fetchLimitOptions = { limit: fetchLimit, before: lastMessageId };
|
|
118
|
+
if (!lastMessageId)
|
|
119
|
+
delete fetchLimitOptions.before;
|
|
120
|
+
// fetch messages
|
|
121
|
+
const messages = await adapter.listChannelMessages(channel.id, fetchLimitOptions);
|
|
122
|
+
const filtered = typeof filter === 'function' ? messages.filter(filter) : messages;
|
|
123
|
+
// add the messages to the array
|
|
124
|
+
allMessages.push(...filtered);
|
|
125
|
+
// Get the last key of 'messages', not 'filteredMessages' because you will be refetching the same messages
|
|
126
|
+
lastMessageId = messages.at(-1)?.id;
|
|
127
|
+
// if there are no more messages, break
|
|
128
|
+
if (messages.length < fetchLimit)
|
|
129
|
+
break;
|
|
130
|
+
// if the limit has been reached, break
|
|
131
|
+
if (allMessages.length >= resolvedLimit)
|
|
132
|
+
break;
|
|
133
|
+
}
|
|
134
|
+
if (resolvedLimit < allMessages.length)
|
|
135
|
+
allMessages = allMessages.slice(0, limit);
|
|
136
|
+
// generate the transcript
|
|
137
|
+
return generateFromMessages(allMessages.reverse(), options);
|
|
138
|
+
}
|
|
139
|
+
exports.default = {
|
|
140
|
+
createTranscript,
|
|
141
|
+
generateFromMessages,
|
|
142
|
+
};
|
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K,EAAE,UAAU,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC;QACvE,IAAI,CAAC,aAAa;YAAE,OAAO,iBAAiB,CAAC,MAAM,CAAC;QAEpD,iBAAiB;QACjB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,mBAAmB,CAAC,OAAO,CAAC,EAAE,EAAE,iBAAiB,CAAC,CAAC;QAClF,MAAM,QAAQ,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAEnF,gCAAgC;QAChC,WAAW,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;QAC9B,0GAA0G;QAC1G,aAAa,GAAG,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;QAEpC,uCAAuC;QACvC,IAAI,QAAQ,CAAC,MAAM,GAAG,UAAU;YAAE,MAAM;QAExC,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,CAAa,WAAW,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;AAC1E,CAAC;AAED,kBAAe;IACb,gBAAgB;IAChB,oBAAoB;CACrB,CAAC"}
|
|
@@ -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/types.d.ts
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { APIMessage } from 'discord-api-types/v10';
|
|
2
|
+
import type { TranscriptAdapter } from './adapters/core';
|
|
3
|
+
import type { RenderMessageContext } from './generator';
|
|
4
|
+
import type { AllAPIChannel } from './utils/channel';
|
|
5
|
+
export type AttachmentTypes = 'audio' | 'video' | 'image' | 'file';
|
|
6
|
+
export declare enum ExportReturnType {
|
|
7
|
+
Buffer = "buffer",
|
|
8
|
+
String = "string",
|
|
9
|
+
Attachment = "attachment"
|
|
10
|
+
}
|
|
11
|
+
export type ObjectType<T extends ExportReturnType, Adapter extends TranscriptAdapter<unknown>> = T extends ExportReturnType.Buffer ? Buffer : T extends ExportReturnType.String ? string : ReturnType<Adapter['createTranscriptAttachment']>;
|
|
12
|
+
export type GenerateFromMessagesOptions<T extends ExportReturnType, Adapter extends TranscriptAdapter<unknown>> = Partial<{
|
|
13
|
+
/**
|
|
14
|
+
* The type of object to return
|
|
15
|
+
* @default ExportReturnType.ATTACHMENT
|
|
16
|
+
*/
|
|
17
|
+
returnType: T;
|
|
18
|
+
/**
|
|
19
|
+
* Downloads images and encodes them as base64 data urls
|
|
20
|
+
* @default false
|
|
21
|
+
*/
|
|
22
|
+
saveImages: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Callbacks for resolving channels, users, and roles
|
|
25
|
+
*/
|
|
26
|
+
callbacks: Partial<RenderMessageContext['callbacks']>;
|
|
27
|
+
/**
|
|
28
|
+
* The name of the file to return if returnType is ExportReturnType.ATTACHMENT
|
|
29
|
+
* @default 'transcript-{channel-id}.html'
|
|
30
|
+
*/
|
|
31
|
+
filename: string;
|
|
32
|
+
/**
|
|
33
|
+
* Whether to include the "Powered by sweety-html-transcripts" footer
|
|
34
|
+
* @default true
|
|
35
|
+
*/
|
|
36
|
+
poweredBy: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The message right before "Powered by" text. Remember to put the {s}
|
|
39
|
+
* @default 'Exported {number} message{s}.'
|
|
40
|
+
*/
|
|
41
|
+
footerText: string;
|
|
42
|
+
/**
|
|
43
|
+
* Whether to show the guild icon or a custom icon as the favicon
|
|
44
|
+
* 'guild' - use the guild icon
|
|
45
|
+
* or pass in a url to use a custom icon
|
|
46
|
+
* @default "guild"
|
|
47
|
+
*/
|
|
48
|
+
favicon: 'guild' | (string & {});
|
|
49
|
+
/**
|
|
50
|
+
* Whether to hydrate the html server-side
|
|
51
|
+
* @default false - the returned html will be hydrated client-side
|
|
52
|
+
*/
|
|
53
|
+
hydrate: boolean;
|
|
54
|
+
}> & RequiredTranscriptData<Adapter>;
|
|
55
|
+
export type RequiredTranscriptData<Adapter extends TranscriptAdapter<unknown>> = {
|
|
56
|
+
adapter: Adapter;
|
|
57
|
+
channel: AllAPIChannel;
|
|
58
|
+
};
|
|
59
|
+
export type CreateTranscriptOptions<T extends ExportReturnType, Adapter extends TranscriptAdapter<unknown>> = Partial<GenerateFromMessagesOptions<T, Adapter> & {
|
|
60
|
+
/**
|
|
61
|
+
* The max amount of messages to fetch. Use `-1` to recursively fetch.
|
|
62
|
+
*/
|
|
63
|
+
limit: number;
|
|
64
|
+
/**
|
|
65
|
+
* Filter messages of the channel
|
|
66
|
+
* @default (() => true)
|
|
67
|
+
*/
|
|
68
|
+
filter: (message: APIMessage) => boolean;
|
|
69
|
+
}> & RequiredTranscriptData<Adapter>;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExportReturnType = void 0;
|
|
4
|
+
var ExportReturnType;
|
|
5
|
+
(function (ExportReturnType) {
|
|
6
|
+
ExportReturnType["Buffer"] = "buffer";
|
|
7
|
+
ExportReturnType["String"] = "string";
|
|
8
|
+
ExportReturnType["Attachment"] = "attachment";
|
|
9
|
+
})(ExportReturnType || (exports.ExportReturnType = ExportReturnType = {}));
|
|
10
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;;AAOA,IAAY,gBAIX;AAJD,WAAY,gBAAgB;IAC1B,qCAAiB,CAAA;IACjB,qCAAiB,CAAA;IACjB,6CAAyB,CAAA;AAC3B,CAAC,EAJW,gBAAgB,gCAAhB,gBAAgB,QAI3B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { ApplicationEmoji, Attachment, Channel, Emoji, Guild, GuildEmoji, GuildMember, MessageReaction, MessageSnapshot, ReactionEmoji, Role, Sticker, User } from 'discord.js';
|
|
2
|
+
import { type Message } from 'discord.js';
|
|
3
|
+
import type { APIAttachment, APIEmoji, APIGuild, APIGuildMember, APIMessage, APIMessageSnapshot, APIReaction, APIRole, APISticker, APIUser } from 'discord-api-types/v10';
|
|
4
|
+
import type { AllAPIChannel } from './channel';
|
|
5
|
+
declare class APIUtils {
|
|
6
|
+
message(message: Message): Promise<APIMessage>;
|
|
7
|
+
user(user: User): APIUser;
|
|
8
|
+
attachment(attachment: Attachment): APIAttachment;
|
|
9
|
+
reaction(reaction: MessageReaction): APIReaction;
|
|
10
|
+
emoji(emoji: GuildEmoji | ReactionEmoji | ApplicationEmoji | Emoji): APIEmoji;
|
|
11
|
+
sticker(sticker: Sticker): APISticker;
|
|
12
|
+
member(member: GuildMember): APIGuildMember;
|
|
13
|
+
channel(channel: Channel): AllAPIChannel;
|
|
14
|
+
snapshot(snapshot: MessageSnapshot): APIMessageSnapshot;
|
|
15
|
+
role(role: Role): APIRole;
|
|
16
|
+
guild(guild: Guild): APIGuild;
|
|
17
|
+
}
|
|
18
|
+
export declare const apiUtils: APIUtils;
|
|
19
|
+
export {};
|