@libstermynal/transcript-v2 3.3.2

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.
Files changed (96) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +134 -0
  3. package/dist/downloader/images.d.ts +36 -0
  4. package/dist/downloader/images.js +114 -0
  5. package/dist/downloader/images.js.map +1 -0
  6. package/dist/generator/index.d.ts +18 -0
  7. package/dist/generator/index.js +71 -0
  8. package/dist/generator/index.js.map +1 -0
  9. package/dist/generator/renderers/attachment.d.ts +21 -0
  10. package/dist/generator/renderers/attachment.js +67 -0
  11. package/dist/generator/renderers/attachment.js.map +1 -0
  12. package/dist/generator/renderers/components/Button.d.ts +9 -0
  13. package/dist/generator/renderers/components/Button.js +9 -0
  14. package/dist/generator/renderers/components/Button.js.map +1 -0
  15. package/dist/generator/renderers/components/Container.d.ts +5 -0
  16. package/dist/generator/renderers/components/Container.js +19 -0
  17. package/dist/generator/renderers/components/Container.js.map +1 -0
  18. package/dist/generator/renderers/components/DiscordHighlightedCode.d.ts +6 -0
  19. package/dist/generator/renderers/components/DiscordHighlightedCode.js +199 -0
  20. package/dist/generator/renderers/components/DiscordHighlightedCode.js.map +1 -0
  21. package/dist/generator/renderers/components/DiscordImage.d.ts +6 -0
  22. package/dist/generator/renderers/components/DiscordImage.js +21 -0
  23. package/dist/generator/renderers/components/DiscordImage.js.map +1 -0
  24. package/dist/generator/renderers/components/Media Gallery.d.ts +5 -0
  25. package/dist/generator/renderers/components/Media Gallery.js +32 -0
  26. package/dist/generator/renderers/components/Media Gallery.js.map +1 -0
  27. package/dist/generator/renderers/components/Select Menu.d.ts +7 -0
  28. package/dist/generator/renderers/components/Select Menu.js +31 -0
  29. package/dist/generator/renderers/components/Select Menu.js.map +1 -0
  30. package/dist/generator/renderers/components/Spacing.d.ts +6 -0
  31. package/dist/generator/renderers/components/Spacing.js +14 -0
  32. package/dist/generator/renderers/components/Spacing.js.map +1 -0
  33. package/dist/generator/renderers/components/Thumbnail.d.ts +4 -0
  34. package/dist/generator/renderers/components/Thumbnail.js +13 -0
  35. package/dist/generator/renderers/components/Thumbnail.js.map +1 -0
  36. package/dist/generator/renderers/components/TranscriptHeader.d.ts +8 -0
  37. package/dist/generator/renderers/components/TranscriptHeader.js +13 -0
  38. package/dist/generator/renderers/components/TranscriptHeader.js.map +1 -0
  39. package/dist/generator/renderers/components/section/Section.d.ts +9 -0
  40. package/dist/generator/renderers/components/section/Section.js +19 -0
  41. package/dist/generator/renderers/components/section/Section.js.map +1 -0
  42. package/dist/generator/renderers/components/section/SectionAccessory.d.ts +6 -0
  43. package/dist/generator/renderers/components/section/SectionAccessory.js +16 -0
  44. package/dist/generator/renderers/components/section/SectionAccessory.js.map +1 -0
  45. package/dist/generator/renderers/components/section/SectionContent.d.ts +6 -0
  46. package/dist/generator/renderers/components/section/SectionContent.js +12 -0
  47. package/dist/generator/renderers/components/section/SectionContent.js.map +1 -0
  48. package/dist/generator/renderers/components/styles.d.ts +21 -0
  49. package/dist/generator/renderers/components/styles.js +147 -0
  50. package/dist/generator/renderers/components/styles.js.map +1 -0
  51. package/dist/generator/renderers/components/utils.d.ts +36 -0
  52. package/dist/generator/renderers/components/utils.js +98 -0
  53. package/dist/generator/renderers/components/utils.js.map +1 -0
  54. package/dist/generator/renderers/components.d.ts +11 -0
  55. package/dist/generator/renderers/components.js +65 -0
  56. package/dist/generator/renderers/components.js.map +1 -0
  57. package/dist/generator/renderers/content.d.ts +31 -0
  58. package/dist/generator/renderers/content.js +163 -0
  59. package/dist/generator/renderers/content.js.map +1 -0
  60. package/dist/generator/renderers/embed.d.ts +11 -0
  61. package/dist/generator/renderers/embed.js +44 -0
  62. package/dist/generator/renderers/embed.js.map +1 -0
  63. package/dist/generator/renderers/message.d.ts +6 -0
  64. package/dist/generator/renderers/message.js +59 -0
  65. package/dist/generator/renderers/message.js.map +1 -0
  66. package/dist/generator/renderers/reply.d.ts +6 -0
  67. package/dist/generator/renderers/reply.js +53 -0
  68. package/dist/generator/renderers/reply.js.map +1 -0
  69. package/dist/generator/renderers/systemMessage.d.ts +13 -0
  70. package/dist/generator/renderers/systemMessage.js +115 -0
  71. package/dist/generator/renderers/systemMessage.js.map +1 -0
  72. package/dist/generator/transcript.d.ts +9 -0
  73. package/dist/generator/transcript.js +76 -0
  74. package/dist/generator/transcript.js.map +1 -0
  75. package/dist/index.d.ts +25 -0
  76. package/dist/index.js +138 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/static/client.d.ts +3 -0
  79. package/dist/static/client.js +31 -0
  80. package/dist/static/client.js.map +1 -0
  81. package/dist/types.d.ts +68 -0
  82. package/dist/types.js +17 -0
  83. package/dist/types.js.map +1 -0
  84. package/dist/utils/buildProfiles.d.ts +11 -0
  85. package/dist/utils/buildProfiles.js +42 -0
  86. package/dist/utils/buildProfiles.js.map +1 -0
  87. package/dist/utils/embeds.d.ts +2 -0
  88. package/dist/utils/embeds.js +17 -0
  89. package/dist/utils/embeds.js.map +1 -0
  90. package/dist/utils/extend.d.ts +8 -0
  91. package/dist/utils/extend.js +8 -0
  92. package/dist/utils/extend.js.map +1 -0
  93. package/dist/utils/utils.d.ts +15 -0
  94. package/dist/utils/utils.js +50 -0
  95. package/dist/utils/utils.js.map +1 -0
  96. package/package.json +70 -0
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const jsx_runtime_1 = require("react/jsx-runtime");
4
+ function SectionContent({ children }) {
5
+ return ((0, jsx_runtime_1.jsx)("div", { style: {
6
+ display: 'flex',
7
+ flexDirection: 'column',
8
+ width: '100%',
9
+ }, children: children }));
10
+ }
11
+ exports.default = SectionContent;
12
+ //# sourceMappingURL=SectionContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SectionContent.js","sourceRoot":"","sources":["../../../../../src/generator/renderers/components/section/SectionContent.tsx"],"names":[],"mappings":";;;AAMA,SAAS,cAAc,CAAC,EAAE,QAAQ,EAAuB;IACvD,OAAO,CACL,gCACE,KAAK,EAAE;YACL,OAAO,EAAE,MAAM;YACf,aAAa,EAAE,QAAQ;YACvB,KAAK,EAAE,MAAM;SACd,YAEA,QAAQ,GACL,CACP,CAAC;AACJ,CAAC;AAED,kBAAe,cAAc,CAAC"}
@@ -0,0 +1,21 @@
1
+ export declare const containerStyle: {
2
+ display: "grid";
3
+ gap: string;
4
+ width: string;
5
+ maxWidth: string;
6
+ borderRadius: string;
7
+ overflow: "hidden";
8
+ };
9
+ export declare const baseImageStyle: {
10
+ overflow: "hidden";
11
+ position: "relative";
12
+ background: string;
13
+ };
14
+ export declare const ButtonStyleMapping: {
15
+ readonly 1: "primary";
16
+ readonly 2: "secondary";
17
+ readonly 3: "success";
18
+ readonly 4: "destructive";
19
+ readonly 5: "secondary";
20
+ };
21
+ export declare const globalStyles = "\n .discord-container {\n display: grid;\n gap: 4px;\n width: 100%;\n max-width: 500px;\n border-radius: 8px;\n overflow: hidden;\n }\n\n .discord-base-image {\n overflow: hidden;\n position: relative;\n background: #2b2d31;\n }\n\n .discord-button {\n color: #ffffff !important;\n padding: 2px 16px;\n border-radius: 8px;\n text-decoration: none !important;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n font-size: 14px;\n font-weight: 500;\n height: 32px;\n min-height: 32px;\n min-width: 60px;\n cursor: pointer;\n text-align: center;\n box-sizing: border-box;\n border: none;\n outline: none;\n transition: background-color 0.2s ease;\n }\n\n .discord-button-primary {\n background-color: hsl(234.935 calc(1*85.556%) 64.706% /1);\n }\n\n .discord-button-secondary {\n background-color: hsl(240 calc(1*4%) 60.784% /0.12156862745098039);\n }\n\n .discord-button-success {\n background-color: hsl(145.97 calc(1*100%) 26.275% /1);\n }\n\n .discord-button-destructive {\n background-color: hsl(355.636 calc(1*64.706%) 50% /1);\n }\n\n .discord-select-menu {\n margin-top: 2px;\n margin-bottom: 2px;\n position: relative;\n width: 100%;\n max-width: 500px;\n height: 40px;\n background-color: #2b2d31;\n border-radius: 4px;\n color: #b5bac1;\n cursor: pointer;\n font-size: 14px;\n display: flex;\n align-items: center;\n padding: 0 8px;\n justify-content: space-between;\n box-sizing: border-box;\n border: 1px solid #1e1f22;\n }\n\n .discord-header {\n \tdisplay: flex;\n \tflex-direction: row;\n \tmax-height: 5rem;\n \tpadding: 0.5rem;\n \tgap: 0.5rem;\n \tborder-bottom: 1px solid rgba(79, 84, 92, 0.48);\n }\n\n .discord-header-icon {\n \tfloat: left;\n \twidth: 5rem;\n }\n\n .discord-header-icon > div {\n \tbackground-color: rgb(79, 84, 92);\n \tborder-radius: 50%;\n \twidth: 5rem;\n \theight: 5rem;\n \ttext-align: center;\n \talign-items: center;\n \tjustify-content: center;\n \tdisplay: flex;\n \tfont-size: xx-large;\n }\n\n .discord-header-icon > img {\n \tborder-radius: 50%;\n \twidth: auto;\n \theight: 100%;\n }\n\n .discord-header-text {\n flex-grow: 1;\n }\n\n .discord-header-text-guild {\n \tfont-size: 1.5rem;\n \tfont-weight: bold;\n }\n\n .reply-inline {\n white-space: collapse;\n }\n";
@@ -0,0 +1,147 @@
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
+ text-align: center;
60
+ box-sizing: border-box;
61
+ border: none;
62
+ outline: none;
63
+ transition: background-color 0.2s ease;
64
+ }
65
+
66
+ .discord-button-primary {
67
+ background-color: hsl(234.935 calc(1*85.556%) 64.706% /1);
68
+ }
69
+
70
+ .discord-button-secondary {
71
+ background-color: hsl(240 calc(1*4%) 60.784% /0.12156862745098039);
72
+ }
73
+
74
+ .discord-button-success {
75
+ background-color: hsl(145.97 calc(1*100%) 26.275% /1);
76
+ }
77
+
78
+ .discord-button-destructive {
79
+ background-color: hsl(355.636 calc(1*64.706%) 50% /1);
80
+ }
81
+
82
+ .discord-select-menu {
83
+ margin-top: 2px;
84
+ margin-bottom: 2px;
85
+ position: relative;
86
+ width: 100%;
87
+ max-width: 500px;
88
+ height: 40px;
89
+ background-color: #2b2d31;
90
+ border-radius: 4px;
91
+ color: #b5bac1;
92
+ cursor: pointer;
93
+ font-size: 14px;
94
+ display: flex;
95
+ align-items: center;
96
+ padding: 0 8px;
97
+ justify-content: space-between;
98
+ box-sizing: border-box;
99
+ border: 1px solid #1e1f22;
100
+ }
101
+
102
+ .discord-header {
103
+ display: flex;
104
+ flex-direction: row;
105
+ max-height: 5rem;
106
+ padding: 0.5rem;
107
+ gap: 0.5rem;
108
+ border-bottom: 1px solid rgba(79, 84, 92, 0.48);
109
+ }
110
+
111
+ .discord-header-icon {
112
+ float: left;
113
+ width: 5rem;
114
+ }
115
+
116
+ .discord-header-icon > div {
117
+ background-color: rgb(79, 84, 92);
118
+ border-radius: 50%;
119
+ width: 5rem;
120
+ height: 5rem;
121
+ text-align: center;
122
+ align-items: center;
123
+ justify-content: center;
124
+ display: flex;
125
+ font-size: xx-large;
126
+ }
127
+
128
+ .discord-header-icon > img {
129
+ border-radius: 50%;
130
+ width: auto;
131
+ height: 100%;
132
+ }
133
+
134
+ .discord-header-text {
135
+ flex-grow: 1;
136
+ }
137
+
138
+ .discord-header-text-guild {
139
+ font-size: 1.5rem;
140
+ font-weight: bold;
141
+ }
142
+
143
+ .reply-inline {
144
+ white-space: collapse;
145
+ }
146
+ `;
147
+ //# 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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqH3B,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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AE,CAAC;gBACnB,uCACK,uBAAc,KACjB,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,IAC5B;YACJ,CAAC;iBAAM,CAAC;gBACN,uCACK,uBAAc,KACjB,OAAO,EAAE,GAAG,EACZ,UAAU,EAAE,GAAG,GAAG,GAAG,CAAC,GAAG,CAAC,EAAE,IAC5B;YACJ,CAAC;QAEH,KAAK,EAAE;YACL,IAAI,GAAG,KAAK,CAAC,EAAE,CAAC;gBACd,uCACK,uBAAc,KACjB,OAAO,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,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C,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,163 @@
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
+ const DATE_TYPE_FORMATS = {
16
+ t: { timeStyle: 'short' },
17
+ T: { timeStyle: 'medium' },
18
+ d: { dateStyle: 'short' },
19
+ D: { dateStyle: 'long' },
20
+ f: { dateStyle: 'long', timeStyle: 'short' },
21
+ F: { dateStyle: 'full', timeStyle: 'short' },
22
+ R: { style: 'long', numeric: 'auto' }
23
+ };
24
+ var RenderType;
25
+ (function (RenderType) {
26
+ RenderType[RenderType["EMBED"] = 0] = "EMBED";
27
+ RenderType[RenderType["REPLY"] = 1] = "REPLY";
28
+ RenderType[RenderType["NORMAL"] = 2] = "NORMAL";
29
+ RenderType[RenderType["WEBHOOK"] = 3] = "WEBHOOK";
30
+ })(RenderType || (exports.RenderType = RenderType = {}));
31
+ ;
32
+ /**
33
+ * Renders discord markdown content
34
+ * @param content - The content to render
35
+ * @param context - The context to render the content in
36
+ * @returns
37
+ */
38
+ async function MessageContent({ content, context }) {
39
+ if (context.type === RenderType.REPLY && content.length > 180)
40
+ content = content.slice(0, 180) + '...';
41
+ // parse the markdown
42
+ const parsed = (0, discord_markdown_parser_1.default)(content, context.type === RenderType.EMBED || context.type === RenderType.WEBHOOK ? 'extended' : 'normal');
43
+ // check if the parsed content is only emojis
44
+ const isOnlyEmojis = parsed.every((node) => ['emoji', 'twemoji'].includes(node.type) || (node.type === 'text' && node.content.trim().length === 0));
45
+ if (isOnlyEmojis) {
46
+ // now check if there are less than or equal to 25 emojis
47
+ const emojis = parsed.filter((node) => ['emoji', 'twemoji'].includes(node.type));
48
+ if (emojis.length <= 25) {
49
+ context._internal = {
50
+ largeEmojis: true,
51
+ };
52
+ }
53
+ }
54
+ return (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: parsed, context: context });
55
+ }
56
+ // This function can probably be combined into the MessageSingleASTNode function
57
+ async function MessageASTNodes({ nodes, context, }) {
58
+ if (Array.isArray(nodes)) {
59
+ 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))) }));
60
+ }
61
+ else {
62
+ return (0, jsx_runtime_1.jsx)(MessageSingleASTNode, { node: nodes, context: context });
63
+ }
64
+ }
65
+ async function MessageSingleASTNode({ node, context }) {
66
+ var _a, _b;
67
+ if (!node)
68
+ return null;
69
+ const type = node.type;
70
+ switch (type) {
71
+ case 'text':
72
+ return node.content;
73
+ case 'link':
74
+ return ((0, jsx_runtime_1.jsx)("discord-link", { href: node.target, children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
75
+ case 'url':
76
+ case 'autolink':
77
+ 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 }) }));
78
+ case 'blockQuote':
79
+ if (context.type === RenderType.REPLY) {
80
+ return (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context });
81
+ }
82
+ return ((0, jsx_runtime_1.jsx)("discord-quote", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
83
+ case 'br':
84
+ case 'newline':
85
+ if (context.type === RenderType.REPLY)
86
+ return ' ';
87
+ return (0, jsx_runtime_1.jsx)("br", {});
88
+ case 'channel': {
89
+ const id = node.id;
90
+ const channel = await context.callbacks.resolveChannel(id);
91
+ 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}>` }));
92
+ }
93
+ case 'role': {
94
+ const id = node.id;
95
+ const role = await context.callbacks.resolveRole(id);
96
+ 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}>` }));
97
+ }
98
+ case 'user': {
99
+ const id = node.id;
100
+ const user = await context.callbacks.resolveUser(id);
101
+ return (0, jsx_runtime_1.jsx)("discord-mention", { type: "user", children: user ? ((_a = user.displayName) !== null && _a !== void 0 ? _a : user.username) : `<@${id}>` });
102
+ }
103
+ case 'here':
104
+ case 'everyone':
105
+ return ((0, jsx_runtime_1.jsx)("discord-mention", { type: 'role', highlight: true, children: `@${type}` }));
106
+ case 'codeBlock':
107
+ if (context.type !== RenderType.REPLY) {
108
+ return (0, jsx_runtime_1.jsx)(DiscordHighlightedCode_1.DiscordHighlightedCode, { language: node.lang, content: node.content });
109
+ }
110
+ return (0, jsx_runtime_1.jsx)("discord-code", { children: node.content });
111
+ case 'inlineCode':
112
+ return (0, jsx_runtime_1.jsx)("discord-code", { children: node.content });
113
+ case 'em':
114
+ return ((0, jsx_runtime_1.jsx)("discord-italic", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
115
+ case 'strong':
116
+ return ((0, jsx_runtime_1.jsx)("discord-bold", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
117
+ case 'heading':
118
+ return ((0, jsx_runtime_1.jsx)("discord-header", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
119
+ case 'subtext':
120
+ return ((0, jsx_runtime_1.jsx)("discord-subscript", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
121
+ case 'underline':
122
+ return ((0, jsx_runtime_1.jsx)("discord-underlined", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
123
+ case 'strikethrough':
124
+ return ((0, jsx_runtime_1.jsx)("s", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
125
+ case 'emoticon':
126
+ return typeof node.content === 'string' ? (node.content) : ((0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }));
127
+ case 'spoiler':
128
+ return ((0, jsx_runtime_1.jsx)("discord-spoiler", { children: (0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }) }));
129
+ case 'emoji':
130
+ case 'twemoji':
131
+ 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 }));
132
+ case 'timestamp':
133
+ return (0, jsx_runtime_1.jsx)("discord-time", { children: new Date(node.timestamp * 1000).toLocaleString(undefined, typeof node.format === "string" ? DATE_TYPE_FORMATS[node.format] : undefined) });
134
+ default: {
135
+ console.log(`[discord-html-transcripts] Unknown node type: ${type}`, node);
136
+ return typeof node.content === 'string' ? (node.content) : ((0, jsx_runtime_1.jsx)(MessageASTNodes, { nodes: node.content, context: context }));
137
+ }
138
+ }
139
+ }
140
+ function getChannelType(channelType) {
141
+ switch (channelType) {
142
+ case discord_js_1.ChannelType.GuildCategory:
143
+ case discord_js_1.ChannelType.GuildAnnouncement:
144
+ case discord_js_1.ChannelType.GuildText:
145
+ case discord_js_1.ChannelType.DM:
146
+ case discord_js_1.ChannelType.GroupDM:
147
+ case discord_js_1.ChannelType.GuildDirectory:
148
+ case discord_js_1.ChannelType.GuildMedia:
149
+ return 'channel';
150
+ case discord_js_1.ChannelType.GuildVoice:
151
+ case discord_js_1.ChannelType.GuildStageVoice:
152
+ return 'voice';
153
+ case discord_js_1.ChannelType.PublicThread:
154
+ case discord_js_1.ChannelType.PrivateThread:
155
+ case discord_js_1.ChannelType.AnnouncementThread:
156
+ return 'thread';
157
+ case discord_js_1.ChannelType.GuildForum:
158
+ return 'forum';
159
+ default:
160
+ return 'channel';
161
+ }
162
+ }
163
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../../src/generator/renderers/content.tsx"],"names":[],"mappings":";;;;;;AAyCA,iCAwBC;AAuBD,oDAqKC;AAED,wCAsBC;;AArRD,sFAAwE;AACxE,2CAAwE;AAMxE,6CAAsD;AACtD,gFAA6E;AAE7E,MAAM,iBAAiB,GAAwB;IAC9C,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE;IACzB,CAAC,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE;IAC1B,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,EAAE;IACzB,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE;IACxB,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE;IAC5C,CAAC,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE;IAC5C,CAAC,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE;CACrC,CAAC;AAEF,IAAY,UAKX;AALD,WAAY,UAAU;IACrB,6CAAK,CAAA;IACL,6CAAK,CAAA;IACL,+CAAM,CAAA;IACN,iDAAO,CAAA;AACR,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAAA,CAAC;AAUF;;;;;GAKG;AACY,KAAK,UAAU,cAAc,CAAC,EAAE,OAAO,EAAE,OAAO,EAAsD;IACpH,IAAI,OAAO,CAAC,IAAI,KAAK,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,G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,SAAS,CAAC,GAAgB,CAAC;QAE/K,OAAO,CAAC,CAAC,CAAC;YACT,OAAO,CAAC,GAAG,CAAC,iDAAiD,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;YAC3E,OAAO,OAAO,IAAI,CAAC,OAAO,KAAK,QAAQ,CAAC,CAAC,CAAC,CACzC,IAAI,CAAC,OAAO,CACZ,CAAC,CAAC,CAAC,CACH,uBAAC,eAAe,IAAC,KAAK,EAAE,IAAI,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,GAAI,CAC1D,CAAC;QACH,CAAC;IACF,CAAC;AACF,CAAC;AAED,SAAgB,cAAc,CAAC,WAAwB;IACtD,QAAQ,WAAW,EAAE,CAAC;QACrB,KAAK,wBAAW,CAAC,aAAa,CAAC;QAC/B,KAAK,wBAAW,CAAC,iBAAiB,CAAC;QACnC,KAAK,wBAAW,CAAC,SAAS,CAAC;QAC3B,KAAK,wBAAW,CAAC,EAAE,CAAC;QACpB,KAAK,wBAAW,CAAC,OAAO,CAAC;QACzB,KAAK,wBAAW,CAAC,cAAc,CAAC;QAChC,KAAK,wBAAW,CAAC,UAAU;YAC1B,OAAO,SAAS,CAAC;QAClB,KAAK,wBAAW,CAAC,UAAU,CAAC;QAC5B,KAAK,wBAAW,CAAC,eAAe;YAC/B,OAAO,OAAO,CAAC;QAChB,KAAK,wBAAW,CAAC,YAAY,CAAC;QAC9B,KAAK,wBAAW,CAAC,aAAa,CAAC;QAC/B,KAAK,wBAAW,CAAC,kBAAkB;YAClC,OAAO,QAAQ,CAAC;QACjB,KAAK,wBAAW,CAAC,UAAU;YAC1B,OAAO,OAAO,CAAC;QAChB;YACC,OAAO,SAAS,CAAC;IACnB,CAAC;AACF,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 {};