discord-html-transcripts-fix 1.0.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 +94 -0
- package/dist/downloader/images.d.ts +36 -0
- package/dist/downloader/images.js +114 -0
- package/dist/downloader/images.js.map +1 -0
- package/dist/generator/index.d.ts +18 -0
- package/dist/generator/index.js +66 -0
- package/dist/generator/index.js.map +1 -0
- package/dist/generator/renderers/attachment.d.ts +21 -0
- package/dist/generator/renderers/attachment.js +67 -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 +9 -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 +19 -0
- package/dist/generator/renderers/components/Container.js.map +1 -0
- package/dist/generator/renderers/components/DiscordHighlightedCode.d.ts +6 -0
- package/dist/generator/renderers/components/DiscordHighlightedCode.js +199 -0
- package/dist/generator/renderers/components/DiscordHighlightedCode.js.map +1 -0
- package/dist/generator/renderers/components/DiscordImage.d.ts +6 -0
- package/dist/generator/renderers/components/DiscordImage.js +21 -0
- package/dist/generator/renderers/components/DiscordImage.js.map +1 -0
- package/dist/generator/renderers/components/Media Gallery.d.ts +5 -0
- package/dist/generator/renderers/components/Media Gallery.js +32 -0
- package/dist/generator/renderers/components/Media Gallery.js.map +1 -0
- package/dist/generator/renderers/components/Select Menu.d.ts +7 -0
- package/dist/generator/renderers/components/Select Menu.js +31 -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 +14 -0
- package/dist/generator/renderers/components/Spacing.js.map +1 -0
- package/dist/generator/renderers/components/Thumbnail.d.ts +4 -0
- package/dist/generator/renderers/components/Thumbnail.js +13 -0
- package/dist/generator/renderers/components/Thumbnail.js.map +1 -0
- package/dist/generator/renderers/components/TranscriptHeader.d.ts +8 -0
- package/dist/generator/renderers/components/TranscriptHeader.js +13 -0
- package/dist/generator/renderers/components/TranscriptHeader.js.map +1 -0
- package/dist/generator/renderers/components/section/Section.d.ts +9 -0
- package/dist/generator/renderers/components/section/Section.js +19 -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 +16 -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 +12 -0
- package/dist/generator/renderers/components/section/SectionContent.js.map +1 -0
- package/dist/generator/renderers/components/styles.d.ts +21 -0
- package/dist/generator/renderers/components/styles.js +149 -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 +11 -0
- package/dist/generator/renderers/components.js +65 -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 +152 -0
- package/dist/generator/renderers/content.js.map +1 -0
- package/dist/generator/renderers/embed.d.ts +11 -0
- package/dist/generator/renderers/embed.js +44 -0
- package/dist/generator/renderers/embed.js.map +1 -0
- package/dist/generator/renderers/message.d.ts +6 -0
- package/dist/generator/renderers/message.js +59 -0
- package/dist/generator/renderers/message.js.map +1 -0
- package/dist/generator/renderers/reply.d.ts +6 -0
- package/dist/generator/renderers/reply.js +53 -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 +115 -0
- package/dist/generator/renderers/systemMessage.js.map +1 -0
- package/dist/generator/transcript.d.ts +9 -0
- package/dist/generator/transcript.js +76 -0
- package/dist/generator/transcript.js.map +1 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +138 -0
- package/dist/index.js.map +1 -0
- package/dist/static/client.d.ts +3 -0
- package/dist/static/client.js +31 -0
- package/dist/static/client.js.map +1 -0
- package/dist/types.d.ts +68 -0
- package/dist/types.js +17 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buildProfiles.d.ts +11 -0
- package/dist/utils/buildProfiles.js +42 -0
- package/dist/utils/buildProfiles.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/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 +15 -0
- package/dist/utils/utils.js +50 -0
- package/dist/utils/utils.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.globalStyles = exports.ButtonStyleMapping = exports.baseImageStyle = exports.containerStyle = void 0;
|
|
4
|
+
const discord_js_1 = require("discord.js");
|
|
5
|
+
// Container styles
|
|
6
|
+
exports.containerStyle = {
|
|
7
|
+
display: 'grid',
|
|
8
|
+
gap: '4px',
|
|
9
|
+
width: '100%',
|
|
10
|
+
maxWidth: '500px',
|
|
11
|
+
borderRadius: '8px',
|
|
12
|
+
overflow: 'hidden',
|
|
13
|
+
};
|
|
14
|
+
// Base image style
|
|
15
|
+
exports.baseImageStyle = {
|
|
16
|
+
overflow: 'hidden',
|
|
17
|
+
position: 'relative',
|
|
18
|
+
background: '#2b2d31',
|
|
19
|
+
};
|
|
20
|
+
// Button style mapping
|
|
21
|
+
exports.ButtonStyleMapping = {
|
|
22
|
+
[discord_js_1.ButtonStyle.Primary]: 'primary',
|
|
23
|
+
[discord_js_1.ButtonStyle.Secondary]: 'secondary',
|
|
24
|
+
[discord_js_1.ButtonStyle.Success]: 'success',
|
|
25
|
+
[discord_js_1.ButtonStyle.Danger]: 'destructive',
|
|
26
|
+
[discord_js_1.ButtonStyle.Link]: 'secondary',
|
|
27
|
+
};
|
|
28
|
+
// TODO: minify
|
|
29
|
+
exports.globalStyles = `
|
|
30
|
+
.discord-container {
|
|
31
|
+
display: grid;
|
|
32
|
+
gap: 4px;
|
|
33
|
+
width: 100%;
|
|
34
|
+
max-width: 500px;
|
|
35
|
+
border-radius: 8px;
|
|
36
|
+
overflow: hidden;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.discord-base-image {
|
|
40
|
+
overflow: hidden;
|
|
41
|
+
position: relative;
|
|
42
|
+
background: #2b2d31;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.discord-button {
|
|
46
|
+
color: #ffffff !important;
|
|
47
|
+
padding: 2px 16px;
|
|
48
|
+
border-radius: 8px;
|
|
49
|
+
text-decoration: none !important;
|
|
50
|
+
display: inline-flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
justify-content: center;
|
|
53
|
+
font-size: 14px;
|
|
54
|
+
font-weight: 500;
|
|
55
|
+
height: 32px;
|
|
56
|
+
min-height: 32px;
|
|
57
|
+
min-width: 60px;
|
|
58
|
+
cursor: pointer;
|
|
59
|
+
font-family: Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
60
|
+
text-align: center;
|
|
61
|
+
box-sizing: border-box;
|
|
62
|
+
border: none;
|
|
63
|
+
outline: none;
|
|
64
|
+
transition: background-color 0.2s ease;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.discord-button-primary {
|
|
68
|
+
background-color: hsl(234.935 calc(1*85.556%) 64.706% /1);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.discord-button-secondary {
|
|
72
|
+
background-color: hsl(240 calc(1*4%) 60.784% /0.12156862745098039);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.discord-button-success {
|
|
76
|
+
background-color: hsl(145.97 calc(1*100%) 26.275% /1);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.discord-button-destructive {
|
|
80
|
+
background-color: hsl(355.636 calc(1*64.706%) 50% /1);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.discord-select-menu {
|
|
84
|
+
margin-top: 2px;
|
|
85
|
+
margin-bottom: 2px;
|
|
86
|
+
position: relative;
|
|
87
|
+
width: 100%;
|
|
88
|
+
max-width: 500px;
|
|
89
|
+
height: 40px;
|
|
90
|
+
background-color: #2b2d31;
|
|
91
|
+
border-radius: 4px;
|
|
92
|
+
color: #b5bac1;
|
|
93
|
+
cursor: pointer;
|
|
94
|
+
font-family: Whitney, "Helvetica Neue", Helvetica, Arial, sans-serif;
|
|
95
|
+
font-size: 14px;
|
|
96
|
+
display: flex;
|
|
97
|
+
align-items: center;
|
|
98
|
+
padding: 0 8px;
|
|
99
|
+
justify-content: space-between;
|
|
100
|
+
box-sizing: border-box;
|
|
101
|
+
border: 1px solid #1e1f22;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.discord-header {
|
|
105
|
+
display: flex;
|
|
106
|
+
flex-direction: row;
|
|
107
|
+
max-height: 5rem;
|
|
108
|
+
padding: 0.5rem;
|
|
109
|
+
gap: 0.5rem;
|
|
110
|
+
border-bottom: 1px solid rgba(79, 84, 92, 0.48);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.discord-header-icon {
|
|
114
|
+
float: left;
|
|
115
|
+
width: 5rem;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
.discord-header-icon > div {
|
|
119
|
+
background-color: rgb(79, 84, 92);
|
|
120
|
+
border-radius: 50%;
|
|
121
|
+
width: 5rem;
|
|
122
|
+
height: 5rem;
|
|
123
|
+
text-align: center;
|
|
124
|
+
align-items: center;
|
|
125
|
+
justify-content: center;
|
|
126
|
+
display: flex;
|
|
127
|
+
font-size: xx-large;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.discord-header-icon > img {
|
|
131
|
+
border-radius: 50%;
|
|
132
|
+
width: auto;
|
|
133
|
+
height: 100%;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
.discord-header-text {
|
|
137
|
+
flex-grow: 1;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
.discord-header-text-guild {
|
|
141
|
+
font-size: 1.5rem;
|
|
142
|
+
font-weight: bold;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
.reply-inline {
|
|
146
|
+
white-space: collapse;
|
|
147
|
+
}
|
|
148
|
+
`;
|
|
149
|
+
//# sourceMappingURL=styles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.js","sourceRoot":"","sources":["../../../../src/generator/renderers/components/styles.ts"],"names":[],"mappings":";;;AACA,2CAAyC;AAEzC,mBAAmB;AACN,QAAA,cAAc,GAAG;IAC5B,OAAO,EAAE,MAAM;IACf,GAAG,EAAE,KAAK;IACV,KAAK,EAAE,MAAM;IACb,QAAQ,EAAE,OAAO;IACjB,YAAY,EAAE,KAAK;IACnB,QAAQ,EAAE,QAAQ;CACK,CAAC;AAE1B,mBAAmB;AACN,QAAA,cAAc,GAAG;IAC5B,QAAQ,EAAE,QAAQ;IAClB,QAAQ,EAAE,UAAU;IACpB,UAAU,EAAE,SAAS;CACE,CAAC;AAE1B,uBAAuB;AACV,QAAA,kBAAkB,GAAG;IAChC,CAAC,wBAAW,CAAC,OAAO,CAAC,EAAE,SAAS;IAChC,CAAC,wBAAW,CAAC,SAAS,CAAC,EAAE,WAAW;IACpC,CAAC,wBAAW,CAAC,OAAO,CAAC,EAAE,SAAS;IAChC,CAAC,wBAAW,CAAC,MAAM,CAAC,EAAE,aAAa;IACnC,CAAC,wBAAW,CAAC,IAAI,CAAC,EAAE,WAAW;CACvB,CAAC;AAEX,eAAe;AACF,QAAA,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuH3B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { ComponentType } from 'discord.js';
|
|
2
|
+
export declare function getSelectTypeLabel(type: ComponentType): string;
|
|
3
|
+
/**
|
|
4
|
+
* Gets the grid layout for media galleries based on count
|
|
5
|
+
*/
|
|
6
|
+
export declare function getGalleryLayout(count: number): {
|
|
7
|
+
gridTemplateColumns: string;
|
|
8
|
+
gridTemplateRows: string;
|
|
9
|
+
display: "grid";
|
|
10
|
+
gap: string;
|
|
11
|
+
width: string;
|
|
12
|
+
maxWidth: string;
|
|
13
|
+
borderRadius: string;
|
|
14
|
+
overflow: "hidden";
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Gets the style for an individual image based on its position and total count
|
|
18
|
+
*/
|
|
19
|
+
export declare function getImageStyle(idx: number, count: number): {
|
|
20
|
+
overflow: "hidden";
|
|
21
|
+
position: "relative";
|
|
22
|
+
background: string;
|
|
23
|
+
} | {
|
|
24
|
+
gridRow: string;
|
|
25
|
+
gridColumn: string;
|
|
26
|
+
aspectRatio: string;
|
|
27
|
+
overflow: "hidden";
|
|
28
|
+
position: "relative";
|
|
29
|
+
background: string;
|
|
30
|
+
} | {
|
|
31
|
+
gridRow: string;
|
|
32
|
+
gridColumn: string;
|
|
33
|
+
overflow: "hidden";
|
|
34
|
+
position: "relative";
|
|
35
|
+
background: string;
|
|
36
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getSelectTypeLabel = getSelectTypeLabel;
|
|
4
|
+
exports.getGalleryLayout = getGalleryLayout;
|
|
5
|
+
exports.getImageStyle = getImageStyle;
|
|
6
|
+
const discord_js_1 = require("discord.js");
|
|
7
|
+
const styles_1 = require("./styles");
|
|
8
|
+
/**
|
|
9
|
+
* Gets the appropriate label for different select menu types
|
|
10
|
+
*/
|
|
11
|
+
const SELECT_LABEL_MAP = {
|
|
12
|
+
[discord_js_1.ComponentType.UserSelect]: 'Select User',
|
|
13
|
+
[discord_js_1.ComponentType.RoleSelect]: 'Select Role',
|
|
14
|
+
[discord_js_1.ComponentType.MentionableSelect]: 'Select Mentionable',
|
|
15
|
+
[discord_js_1.ComponentType.ChannelSelect]: 'Select Channel',
|
|
16
|
+
[discord_js_1.ComponentType.StringSelect]: 'Make a Selection',
|
|
17
|
+
};
|
|
18
|
+
function getSelectTypeLabel(type) {
|
|
19
|
+
var _a;
|
|
20
|
+
return (_a = SELECT_LABEL_MAP[type]) !== null && _a !== void 0 ? _a : 'Select Option';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Gets the grid layout for media galleries based on count
|
|
24
|
+
*/
|
|
25
|
+
function getGalleryLayout(count) {
|
|
26
|
+
switch (count) {
|
|
27
|
+
case 1:
|
|
28
|
+
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr', gridTemplateRows: 'auto' });
|
|
29
|
+
case 2:
|
|
30
|
+
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr', gridTemplateRows: 'auto' });
|
|
31
|
+
case 3:
|
|
32
|
+
case 4:
|
|
33
|
+
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr', gridTemplateRows: '1fr 1fr' });
|
|
34
|
+
case 5:
|
|
35
|
+
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr 1fr', gridTemplateRows: 'auto auto' });
|
|
36
|
+
default:
|
|
37
|
+
if (count >= 7) {
|
|
38
|
+
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr 1fr', gridTemplateRows: 'auto auto auto auto' });
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
return Object.assign(Object.assign({}, styles_1.containerStyle), { gridTemplateColumns: '1fr 1fr 1fr', gridTemplateRows: 'auto' });
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Gets the style for an individual image based on its position and total count
|
|
47
|
+
*/
|
|
48
|
+
function getImageStyle(idx, count) {
|
|
49
|
+
switch (count) {
|
|
50
|
+
case 3:
|
|
51
|
+
if (idx === 0) {
|
|
52
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1 / span 2', gridColumn: '1', aspectRatio: '1/2' });
|
|
53
|
+
}
|
|
54
|
+
break;
|
|
55
|
+
case 5:
|
|
56
|
+
if (idx < 2) {
|
|
57
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: idx === 0 ? '1 / span 2' : '3' });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 2 + 1}` });
|
|
61
|
+
}
|
|
62
|
+
case 7:
|
|
63
|
+
if (idx === 0) {
|
|
64
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: '1 / span 3' });
|
|
65
|
+
}
|
|
66
|
+
else if (idx <= 3) {
|
|
67
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 0}` });
|
|
68
|
+
}
|
|
69
|
+
else {
|
|
70
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '3', gridColumn: `${idx - 3}` });
|
|
71
|
+
}
|
|
72
|
+
case 8:
|
|
73
|
+
if (idx < 2) {
|
|
74
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: idx === 0 ? '1 / span 2' : '3' });
|
|
75
|
+
}
|
|
76
|
+
else if (idx < 5) {
|
|
77
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 2 + 1}` });
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '3', gridColumn: `${idx - 5 + 1}` });
|
|
81
|
+
}
|
|
82
|
+
case 10:
|
|
83
|
+
if (idx === 0) {
|
|
84
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '1', gridColumn: '1 / span 3' });
|
|
85
|
+
}
|
|
86
|
+
else if (idx <= 3) {
|
|
87
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '2', gridColumn: `${idx - 0}` });
|
|
88
|
+
}
|
|
89
|
+
else if (idx <= 6) {
|
|
90
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '3', gridColumn: `${idx - 3}` });
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
return Object.assign(Object.assign({}, styles_1.baseImageStyle), { gridRow: '4', gridColumn: `${idx - 6}` });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return styles_1.baseImageStyle;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/generator/renderers/components/utils.ts"],"names":[],"mappings":";;AAcA,gDAEC;AAKD,4CA0CC;AAKD,sCAmGC;AAvKD,2CAA2C;AAC3C,qCAA0D;AAE1D;;GAEG;AACH,MAAM,gBAAgB,GAAG;IACvB,CAAC,0BAAa,CAAC,UAAU,CAAC,EAAE,aAAa;IACzC,CAAC,0BAAa,CAAC,UAAU,CAAC,EAAE,aAAa;IACzC,CAAC,0BAAa,CAAC,iBAAiB,CAAC,EAAE,oBAAoB;IACvD,CAAC,0BAAa,CAAC,aAAa,CAAC,EAAE,gBAAgB;IAC/C,CAAC,0BAAa,CAAC,YAAY,CAAC,EAAE,kBAAkB;CACxC,CAAC;AAEX,SAAgB,kBAAkB,CAAC,IA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AO,EAAE,GAAG,EACZ,UAAU,EAAE,YAAY,IACxB;YACJ,CAAC;iBAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;gBACpB,uCACK,uBAAc,KACjB,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,EAAE,IACxB;YACJ,CAAC;iBAAM,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;gBACpB,uCACK,uBAAc,KACjB,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,EAAE,IACxB;YACJ,CAAC;iBAAM,CAAC;gBACN,uCACK,uBAAc,KACjB,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,EAAE,IACxB;YACJ,CAAC;IACL,CAAC;IAED,OAAO,uBAAc,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type ThumbnailComponent, type MessageActionRowComponent, type TopLevelComponent } from 'discord.js';
|
|
2
|
+
import type { RenderMessageContext } from '..';
|
|
3
|
+
export default function ComponentRow({ component, id, context, }: {
|
|
4
|
+
component: TopLevelComponent;
|
|
5
|
+
id: number;
|
|
6
|
+
context: RenderMessageContext;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
8
|
+
export declare function Component({ component, id, }: {
|
|
9
|
+
component: MessageActionRowComponent | ThumbnailComponent;
|
|
10
|
+
id: number;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element | undefined;
|
|
@@ -0,0 +1,65 @@
|
|
|
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 = ComponentRow;
|
|
7
|
+
exports.Component = Component;
|
|
8
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
+
const discord_js_1 = require("discord.js");
|
|
10
|
+
const utils_1 = require("../../utils/utils");
|
|
11
|
+
const Select_Menu_1 = __importDefault(require("./components/Select Menu"));
|
|
12
|
+
const Container_1 = __importDefault(require("./components/Container"));
|
|
13
|
+
const Section_1 = __importDefault(require("./components/section/Section"));
|
|
14
|
+
const Media_Gallery_1 = __importDefault(require("./components/Media Gallery"));
|
|
15
|
+
const Spacing_1 = __importDefault(require("./components/Spacing"));
|
|
16
|
+
const Button_1 = __importDefault(require("./components/Button"));
|
|
17
|
+
const Thumbnail_1 = __importDefault(require("./components/Thumbnail"));
|
|
18
|
+
const content_1 = __importDefault(require("./content"));
|
|
19
|
+
const content_2 = require("./content");
|
|
20
|
+
const styles_1 = require("./components/styles");
|
|
21
|
+
function ComponentRow({ component, id, context, }) {
|
|
22
|
+
switch (component.type) {
|
|
23
|
+
case discord_js_1.ComponentType.ActionRow:
|
|
24
|
+
return ((0, jsx_runtime_1.jsx)("discord-action-row", { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: component.components.map((nestedComponent, id) => ((0, jsx_runtime_1.jsx)(Component, { component: nestedComponent, id: id }, id))) }) }, id));
|
|
25
|
+
case discord_js_1.ComponentType.Container:
|
|
26
|
+
return ((0, jsx_runtime_1.jsx)(Container_1.default, { children: (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: component.components.map((nestedComponent, id) => ((0, jsx_runtime_1.jsx)(ComponentRow, { component: nestedComponent, id: id, context: context }, id))) }) }, id));
|
|
27
|
+
case discord_js_1.ComponentType.File: {
|
|
28
|
+
const attachmentComponent = (0, jsx_runtime_1.jsx)("discord-file-attachment", { href: component.file.url });
|
|
29
|
+
if (component.spoiler) {
|
|
30
|
+
return ((0, jsx_runtime_1.jsx)("discord-spoiler", { slot: "attachment", children: attachmentComponent }, component.id));
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
return attachmentComponent;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
case discord_js_1.ComponentType.MediaGallery:
|
|
37
|
+
return (0, jsx_runtime_1.jsx)(Media_Gallery_1.default, { component: component }, id);
|
|
38
|
+
case discord_js_1.ComponentType.Section:
|
|
39
|
+
return ((0, jsx_runtime_1.jsx)(Section_1.default, { accessory: component.accessory, id: id, children: component.components.map((nestedComponent, id) => ((0, jsx_runtime_1.jsx)(ComponentRow, { component: nestedComponent, id: id, context: context }, id))) }, id));
|
|
40
|
+
case discord_js_1.ComponentType.Separator:
|
|
41
|
+
return (0, jsx_runtime_1.jsx)(Spacing_1.default, { spacing: component.spacing, divider: component.divider }, id);
|
|
42
|
+
case discord_js_1.ComponentType.TextDisplay:
|
|
43
|
+
return (0, jsx_runtime_1.jsx)(content_1.default, { content: component.content, context: Object.assign(Object.assign({}, context), { type: content_2.RenderType.NORMAL }) }, id);
|
|
44
|
+
default:
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function Component({ component, id, }) {
|
|
49
|
+
var _a;
|
|
50
|
+
switch (component.type) {
|
|
51
|
+
case discord_js_1.ComponentType.Button:
|
|
52
|
+
return ((0, jsx_runtime_1.jsx)(Button_1.default, { type: styles_1.ButtonStyleMapping[component.style], url: (_a = component.url) !== null && _a !== void 0 ? _a : undefined, emoji: component.emoji ? (0, utils_1.parseDiscordEmoji)(component.emoji) : undefined, children: component.label }, id));
|
|
53
|
+
case discord_js_1.ComponentType.StringSelect:
|
|
54
|
+
case discord_js_1.ComponentType.UserSelect:
|
|
55
|
+
case discord_js_1.ComponentType.RoleSelect:
|
|
56
|
+
case discord_js_1.ComponentType.MentionableSelect:
|
|
57
|
+
case discord_js_1.ComponentType.ChannelSelect:
|
|
58
|
+
return (0, jsx_runtime_1.jsx)(Select_Menu_1.default, { component: component }, id);
|
|
59
|
+
case discord_js_1.ComponentType.Thumbnail:
|
|
60
|
+
return (0, jsx_runtime_1.jsx)(Thumbnail_1.default, { url: component.media.url }, id);
|
|
61
|
+
default:
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=components.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../../src/generator/renderers/components.tsx"],"names":[],"mappings":";;;;;AAmBA,+BAmEC;AAED,8BAiCC;;AAzHD,2CAKoB;AACpB,6CAAsD;AACtD,2EAAyD;AACzD,uEAAsD;AACtD,2EAA0D;AAC1D,+EAA6D;AAC7D,mEAAoD;AACpD,iEAAgD;AAChD,uEAAsD;AACtD,wDAAuC;AACvC,uCAAuC;AAEvC,gDAAyD;AAEzD,SAAwB,YAAY,CAAC,EACnC,SAAS,EACT,EAAE,EACF,OAAO,GAKR;IACC,QAAQ,SAAS,CAAC,IAAI,EAAE,CAAC;QACvB,KAAK,0BAAa,CAAC,SAAS;YAC1B,OAAO,CACL,yDACE,2DACG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE,CAAC,CACjD,uBAAC,SAAS,IAAC,SAAS,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,IAAO,EAAE,CAAI,CAC3D,CAAC,GACD,IALoB,EAAE,CAMN,CACtB,CAAC;QAEJ,KAAK,0BAAa,CAAC,SAAS;YAC1B,OAAO,CACL,uBAAC,mBAAgB,cACf,2DACG,SAAS,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,eAAe,EAAE,EAAE,EAAE,EAAE,CAAC,CACjD,uBAAC,YAAY,IAAC,SAAS,EAAE,eAAe,EAAE,EAAE,EAAE,EAAE,EAAW,OAAO,EAAE,OAAO,IAApB,EAAE,CAAsB,CAChF,CAAC,GACD,IALkB,EAAE,CAMN,CACpB,CAAC;QAEJ,KAAK,0BAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YACxB,MAAM,mBAAmB,GAAG,oDAAyB,IAAI,EAAE,SAAS,CAAC,IAAI,CAAC,GAAG,GAAI,CAAC;YAElF,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,gBAAa,IAEZ,IAAI,EAAE,2BAAkB,CAAC,SAAS,CAAC,KAAwC,CAAC,EAC5E,GAAG,EAAE,MAAA,SAAS,CAAC,GAAG,mCAAI,SAAS,EAC/B,KAAK,EAAE,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,IAAA,yBAAiB,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,YAEtE,SAAS,CAAC,KAAK,IALX,EAAE,CAMO,CACjB,CAAC;QAEJ,KAAK,0BAAa,CAAC,YAAY,CAAC;QAChC,KAAK,0BAAa,CAAC,UAAU,CAAC;QAC9B,KAAK,0BAAa,CAAC,UAAU,CAAC;QAC9B,KAAK,0BAAa,CAAC,iBAAiB,CAAC;QACrC,KAAK,0BAAa,CAAC,aAAa;YAC9B,OAAO,uBAAC,qBAAiB,IAAU,SAAS,EAAE,SAAS,IAAxB,EAAE,CAA0B,CAAC;QAE9D,KAAK,0BAAa,CAAC,SAAS;YAC1B,OAAO,uBAAC,mBAAgB,IAAU,GAAG,EAAE,SAAS,CAAC,KAAK,CAAC,GAAG,IAA5B,EAAE,CAA8B,CAAC;QAEjE;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ChannelType } from 'discord.js';
|
|
2
|
+
import type { SingleASTNode } from 'simple-markdown';
|
|
3
|
+
import type { RenderMessageContext } from '../';
|
|
4
|
+
export declare enum RenderType {
|
|
5
|
+
EMBED = 0,
|
|
6
|
+
REPLY = 1,
|
|
7
|
+
NORMAL = 2,
|
|
8
|
+
WEBHOOK = 3
|
|
9
|
+
}
|
|
10
|
+
type RenderContentContext = RenderMessageContext & {
|
|
11
|
+
type: RenderType;
|
|
12
|
+
_internal?: {
|
|
13
|
+
largeEmojis?: boolean;
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
/**
|
|
17
|
+
* Renders discord markdown content
|
|
18
|
+
* @param content - The content to render
|
|
19
|
+
* @param context - The context to render the content in
|
|
20
|
+
* @returns
|
|
21
|
+
*/
|
|
22
|
+
export default function MessageContent({ content, context }: {
|
|
23
|
+
content: string;
|
|
24
|
+
context: RenderContentContext;
|
|
25
|
+
}): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
26
|
+
export declare function MessageSingleASTNode({ node, context }: {
|
|
27
|
+
node: SingleASTNode;
|
|
28
|
+
context: RenderContentContext;
|
|
29
|
+
}): Promise<any>;
|
|
30
|
+
export declare function getChannelType(channelType: ChannelType): 'channel' | 'voice' | 'thread' | 'forum';
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,152 @@
|
|
|
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.RenderType = void 0;
|
|
7
|
+
exports.default = MessageContent;
|
|
8
|
+
exports.MessageSingleASTNode = MessageSingleASTNode;
|
|
9
|
+
exports.getChannelType = getChannelType;
|
|
10
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
11
|
+
const discord_markdown_parser_1 = __importDefault(require("discord-markdown-parser"));
|
|
12
|
+
const discord_js_1 = require("discord.js");
|
|
13
|
+
const utils_1 = require("../../utils/utils");
|
|
14
|
+
const DiscordHighlightedCode_1 = require("./components/DiscordHighlightedCode");
|
|
15
|
+
var RenderType;
|
|
16
|
+
(function (RenderType) {
|
|
17
|
+
RenderType[RenderType["EMBED"] = 0] = "EMBED";
|
|
18
|
+
RenderType[RenderType["REPLY"] = 1] = "REPLY";
|
|
19
|
+
RenderType[RenderType["NORMAL"] = 2] = "NORMAL";
|
|
20
|
+
RenderType[RenderType["WEBHOOK"] = 3] = "WEBHOOK";
|
|
21
|
+
})(RenderType || (exports.RenderType = RenderType = {}));
|
|
22
|
+
/**
|
|
23
|
+
* Renders discord markdown content
|
|
24
|
+
* @param content - The content to render
|
|
25
|
+
* @param context - The context to render the content in
|
|
26
|
+
* @returns
|
|
27
|
+
*/
|
|
28
|
+
async function MessageContent({ content, context }) {
|
|
29
|
+
if (context.type === RenderType.REPLY && content.length > 180)
|
|
30
|
+
content = content.slice(0, 180) + '...';
|
|
31
|
+
// parse the markdown
|
|
32
|
+
const parsed = (0, discord_markdown_parser_1.default)(content, context.type === RenderType.EMBED || context.type === RenderType.WEBHOOK ? 'extended' : 'normal');
|
|
33
|
+
// check if the parsed content is only emojis
|
|
34
|
+
const isOnlyEmojis = parsed.every((node) => ['emoji', 'twemoji'].includes(node.type) || (node.type === 'text' && node.content.trim().length === 0));
|
|
35
|
+
if (isOnlyEmojis) {
|
|
36
|
+
// now check if there are less than or equal to 25 emojis
|
|
37
|
+
const emojis = parsed.filter((node) => ['emoji', 'twemoji'].includes(node.type));
|
|
38
|
+
if (emojis.length <= 25) {
|
|
39
|
+
context._internal = {
|
|
40
|
+
largeEmojis: true,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: parsed, context: context });
|
|
45
|
+
}
|
|
46
|
+
// This function can probably be combined into the MessageSingleASTNode function
|
|
47
|
+
async function MessageASTNodes({ nodes, context, }) {
|
|
48
|
+
if (Array.isArray(nodes)) {
|
|
49
|
+
return ((0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, { children: nodes.map((node, i) => ((0, jsx_runtime_1.jsx)(MessageSingleASTNode, { node: node, context: context }, i))) }));
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return (0, jsx_runtime_1.jsx)(MessageSingleASTNode, { node: nodes, context: context });
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function MessageSingleASTNode({ node, context }) {
|
|
56
|
+
var _a, _b;
|
|
57
|
+
if (!node)
|
|
58
|
+
return null;
|
|
59
|
+
const type = node.type;
|
|
60
|
+
switch (type) {
|
|
61
|
+
case 'text':
|
|
62
|
+
return node.content;
|
|
63
|
+
case 'link':
|
|
64
|
+
return ((0, jsx_runtime_1.jsx)("discord-link", { href: node.target, children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
65
|
+
case 'url':
|
|
66
|
+
case 'autolink':
|
|
67
|
+
return ((0, jsx_runtime_1.jsx)("discord-link", { href: node.target, target: "_blank", rel: "noreferrer", children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
68
|
+
case 'blockQuote':
|
|
69
|
+
if (context.type === RenderType.REPLY) {
|
|
70
|
+
return (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context });
|
|
71
|
+
}
|
|
72
|
+
return ((0, jsx_runtime_1.jsx)("discord-quote", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
73
|
+
case 'br':
|
|
74
|
+
case 'newline':
|
|
75
|
+
if (context.type === RenderType.REPLY)
|
|
76
|
+
return ' ';
|
|
77
|
+
return (0, jsx_runtime_1.jsx)("br", {});
|
|
78
|
+
case 'channel': {
|
|
79
|
+
const id = node.id;
|
|
80
|
+
const channel = await context.callbacks.resolveChannel(id);
|
|
81
|
+
return ((0, jsx_runtime_1.jsx)("discord-mention", { type: channel ? (channel.isDMBased() ? 'channel' : getChannelType(channel.type)) : 'channel', children: channel ? (channel.isDMBased() ? 'DM Channel' : channel.name) : `<#${id}>` }));
|
|
82
|
+
}
|
|
83
|
+
case 'role': {
|
|
84
|
+
const id = node.id;
|
|
85
|
+
const role = await context.callbacks.resolveRole(id);
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)("discord-mention", { type: "role", color: context.type === RenderType.REPLY ? undefined : role === null || role === void 0 ? void 0 : role.hexColor, children: role ? role.name : `<@&${id}>` }));
|
|
87
|
+
}
|
|
88
|
+
case 'user': {
|
|
89
|
+
const id = node.id;
|
|
90
|
+
const user = await context.callbacks.resolveUser(id);
|
|
91
|
+
return (0, jsx_runtime_1.jsx)("discord-mention", { type: "user", children: user ? ((_a = user.displayName) !== null && _a !== void 0 ? _a : user.username) : `<@${id}>` });
|
|
92
|
+
}
|
|
93
|
+
case 'here':
|
|
94
|
+
case 'everyone':
|
|
95
|
+
return ((0, jsx_runtime_1.jsx)("discord-mention", { type: 'role', highlight: true, children: `@${type}` }));
|
|
96
|
+
case 'codeBlock':
|
|
97
|
+
if (context.type !== RenderType.REPLY) {
|
|
98
|
+
return (0, jsx_runtime_1.jsx)(DiscordHighlightedCode_1.DiscordHighlightedCode, { language: node.lang, content: node.content });
|
|
99
|
+
}
|
|
100
|
+
return (0, jsx_runtime_1.jsx)("discord-code", { children: node.content });
|
|
101
|
+
case 'inlineCode':
|
|
102
|
+
return (0, jsx_runtime_1.jsx)("discord-code", { children: node.content });
|
|
103
|
+
case 'em':
|
|
104
|
+
return ((0, jsx_runtime_1.jsx)("discord-italic", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
105
|
+
case 'strong':
|
|
106
|
+
return ((0, jsx_runtime_1.jsx)("discord-bold", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
107
|
+
case 'underline':
|
|
108
|
+
return ((0, jsx_runtime_1.jsx)("discord-underlined", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
109
|
+
case 'strikethrough':
|
|
110
|
+
return ((0, jsx_runtime_1.jsx)("s", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
111
|
+
case 'emoticon':
|
|
112
|
+
return typeof node.content === 'string' ? (node.content) : ((0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }));
|
|
113
|
+
case 'spoiler':
|
|
114
|
+
return ((0, jsx_runtime_1.jsx)("discord-spoiler", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
|
|
115
|
+
case 'emoji':
|
|
116
|
+
case 'twemoji':
|
|
117
|
+
return ((0, jsx_runtime_1.jsx)("discord-custom-emoji", { name: node.name, url: (0, utils_1.parseDiscordEmoji)(node), embedEmoji: context.type === RenderType.EMBED, jumbo: (_b = context._internal) === null || _b === void 0 ? void 0 : _b.largeEmojis }));
|
|
118
|
+
case 'timestamp':
|
|
119
|
+
// TODO: Make this reactive
|
|
120
|
+
// https://github.com/ItzDerock/discord-components/blob/main/packages/core/src/components/discord-time/discord-time.tsx
|
|
121
|
+
return (0, jsx_runtime_1.jsx)("discord-time", { children: new Date(node.timestamp).toISOString() });
|
|
122
|
+
// return <DiscordTime timestamp={parseInt(node.timestamp) * 1000} format={node.format} />;
|
|
123
|
+
default: {
|
|
124
|
+
// console.log(`[discord-html-transcripts] Unknown node type: ${type}`, node);
|
|
125
|
+
return typeof node.content === 'string' ? (node.content) : ((0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }));
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
function getChannelType(channelType) {
|
|
130
|
+
switch (channelType) {
|
|
131
|
+
case discord_js_1.ChannelType.GuildCategory:
|
|
132
|
+
case discord_js_1.ChannelType.GuildAnnouncement:
|
|
133
|
+
case discord_js_1.ChannelType.GuildText:
|
|
134
|
+
case discord_js_1.ChannelType.DM:
|
|
135
|
+
case discord_js_1.ChannelType.GroupDM:
|
|
136
|
+
case discord_js_1.ChannelType.GuildDirectory:
|
|
137
|
+
case discord_js_1.ChannelType.GuildMedia:
|
|
138
|
+
return 'channel';
|
|
139
|
+
case discord_js_1.ChannelType.GuildVoice:
|
|
140
|
+
case discord_js_1.ChannelType.GuildStageVoice:
|
|
141
|
+
return 'voice';
|
|
142
|
+
case discord_js_1.ChannelType.PublicThread:
|
|
143
|
+
case discord_js_1.ChannelType.PrivateThread:
|
|
144
|
+
case discord_js_1.ChannelType.AnnouncementThread:
|
|
145
|
+
return 'thread';
|
|
146
|
+
case discord_js_1.ChannelType.GuildForum:
|
|
147
|
+
return 'forum';
|
|
148
|
+
default:
|
|
149
|
+
return 'channel';
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=content.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/generator/renderers/content.tsx"],"names":[],"mappings":";;;;;;AA+BA,iCAwBC;AAuBD,oDA0JC;AAED,wCAsBC;;AAhQD,sFAAwE;AACxE,2CAAwE;AAMxE,6CAAsD;AACtD,gFAA6E;AAE7E,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,6CAAK,CAAA;IACL,6CAAK,CAAA;IACL,+CAAM,CAAA;IACN,iDAAO,CAAA;AACT,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAUD;;;;;GAKG;AACY,KAAK,UAAU,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAsD;IACnH,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC;IAEvG,qBAAqB;IACrB,MAAM,MAAM,GAAG,IAAA,iCAAK,EAClB,OAAO,EACP,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,QAAQ,CACjG,CAAC;IAEF,6CAA6C;IAC7C,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAC/B,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,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YAAY,CAAC;QAC9B,KAAK,wBAAW,CAAC,aAAa,CAAC;QAC/B,KAAK,wBAAW,CAAC,kBAAkB;YACjC,OAAO,QAAQ,CAAC;QAClB,KAAK,wBAAW,CAAC,UAAU;YACzB,OAAO,OAAO,CAAC;QACjB;YACE,OAAO,SAAS,CAAC;IACrB,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Embed, Message } from 'discord.js';
|
|
2
|
+
import type { RenderMessageContext } from '..';
|
|
3
|
+
type RenderEmbedContext = RenderMessageContext & {
|
|
4
|
+
index: number;
|
|
5
|
+
message: Message;
|
|
6
|
+
};
|
|
7
|
+
export declare function DiscordEmbed({ embed, context }: {
|
|
8
|
+
embed: Embed;
|
|
9
|
+
context: RenderEmbedContext;
|
|
10
|
+
}): Promise<import("react/jsx-runtime").JSX.Element>;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.DiscordEmbed = DiscordEmbed;
|
|
37
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
|
+
const embeds_1 = require("../../utils/embeds");
|
|
39
|
+
const content_1 = __importStar(require("./content"));
|
|
40
|
+
async function DiscordEmbed({ embed, context }) {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r;
|
|
42
|
+
return ((0, jsx_runtime_1.jsxs)("discord-embed", { "embed-title": (_a = embed.title) !== null && _a !== void 0 ? _a : undefined, slot: "embeds", "author-image": (_c = (_b = embed.author) === null || _b === void 0 ? void 0 : _b.proxyIconURL) !== null && _c !== void 0 ? _c : (_d = embed.author) === null || _d === void 0 ? void 0 : _d.iconURL, "author-name": (_e = embed.author) === null || _e === void 0 ? void 0 : _e.name, "author-url": (_f = embed.author) === null || _f === void 0 ? void 0 : _f.url, color: (_g = embed.hexColor) !== null && _g !== void 0 ? _g : undefined, image: (_j = (_h = embed.image) === null || _h === void 0 ? void 0 : _h.proxyURL) !== null && _j !== void 0 ? _j : (_k = embed.image) === null || _k === void 0 ? void 0 : _k.url, thumbnail: (_m = (_l = embed.thumbnail) === null || _l === void 0 ? void 0 : _l.proxyURL) !== null && _m !== void 0 ? _m : (_o = embed.thumbnail) === null || _o === void 0 ? void 0 : _o.url, url: (_p = embed.url) !== null && _p !== void 0 ? _p : undefined, children: [embed.description && ((0, jsx_runtime_1.jsx)("discord-embed-description", { slot: "description", children: (0, jsx_runtime_1.jsx)(content_1.default, { content: embed.description, context: Object.assign(Object.assign({}, context), { type: content_1.RenderType.EMBED }) }) })), embed.fields.length > 0 && ((0, jsx_runtime_1.jsx)("discord-embed-fields", { slot: "fields", children: embed.fields.map(async (field, id) => ((0, jsx_runtime_1.jsx)("discord-embed-field", { "field-title": field.name, inline: !!field.inline, "inline-index": field.inline ? (0, embeds_1.calculateInlineIndex)(embed.fields, id) : undefined, children: (0, jsx_runtime_1.jsx)(content_1.default, { content: field.value, context: Object.assign(Object.assign({}, context), { type: content_1.RenderType.EMBED }) }) }, `${context.message.id}-e-${context.index}-f-${id}`))) })), embed.footer && ((0, jsx_runtime_1.jsx)("discord-embed-footer", { slot: "footer", footerImage: (_q = embed.footer.proxyIconURL) !== null && _q !== void 0 ? _q : embed.footer.iconURL, timestamp: (_r = embed.timestamp) !== null && _r !== void 0 ? _r : undefined, children: embed.footer.text }))] }, `${context.message.id}-e-${context.index}`));
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=embed.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"embed.js","sourceRoot":"","sources":["../../../src/generator/renderers/embed.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,oCAiDC;;AAzDD,+CAA0D;AAC1D,qDAAuD;AAOhD,KAAK,UAAU,YAAY,CAAC,EAAE,KAAK,EAAE,OAAO,EAAiD;;IAClG,OAAO,CACL,0DACe,MAAA,KAAK,CAAC,KAAK,mCAAI,SAAS,EACrC,IAAI,EAAC,QAAQ,kBAEC,MAAA,MAAA,KAAK,CAAC,MAAM,0CAAE,YAAY,mCAAI,MAAA,KAAK,CAAC,MAAM,0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