diff --git a/build.mjs b/build.mjs index a200bf2..00be16c 100644 --- a/build.mjs +++ b/build.mjs @@ -1,5 +1,4 @@ import { build } from "esbuild"; -import { spawn } from "child_process"; /** * @type {esbuild.Plugin} @@ -7,7 +6,7 @@ import { spawn } from "child_process"; const makeAllPackagesExternalPlugin = { name: "make-all-packages-external", setup(build) { - const filter = /(oceanic\.js|sqlite3)/; // Whitelist of dumb packages + const filter = /^[^./|~]|^\.[^./]|^\.\.[^/]/; // Must not start with "/" or "./" or "../" build.onResolve({ filter }, (args) => ({ path: args.path, external: true @@ -23,19 +22,10 @@ await build({ target: "esnext", logLevel: "info", outfile: "dist/index.js", - minify: false, + minify: true, treeShaking: true, // shake it off shake it offff jsx: "transform", inject: ["components-jsx/runtime.ts"], jsxFactory: "createElement", jsxFragment: "Fragment" }); - -setInterval(() => {}, 100); - -if (process.argv.includes("start")) { - const proc = spawn("node", ["--env-file=.env", "dist/index.js"], { - stdio: "inherit" - }); - proc.on("close", (code) => process.exit(code)); -} diff --git a/components-jsx/ActionRow.tsx b/components-jsx/ActionRow.tsx index b7907a1..2b1f2d5 100644 --- a/components-jsx/ActionRow.tsx +++ b/components-jsx/ActionRow.tsx @@ -2,12 +2,12 @@ import { ComponentTypes, MessageActionRow, MessageActionRowComponent } from "oce import { childrenToArray } from "./utils"; -export type ActionRowProps = Omit & { children: MessageActionRowComponent | MessageActionRowComponent[]; }; +export type ActionRowProps = Omit & { children?: MessageActionRowComponent | MessageActionRowComponent[] }; -export function ActionRow({ children, ...props }: ActionRowProps): MessageActionRow { +export function ActionRow(props: ActionRowProps): MessageActionRow { return { type: ComponentTypes.ACTION_ROW, - components: childrenToArray(children), + components: childrenToArray(props.children), ...props }; } diff --git a/components-jsx/Button.tsx b/components-jsx/Button.tsx index b16cfaf..db3c083 100644 --- a/components-jsx/Button.tsx +++ b/components-jsx/Button.tsx @@ -5,7 +5,7 @@ import { childrenToString } from "./utils"; export { ButtonStyles } from "oceanic.js"; type Button = Omit | Omit; -export type ButtonProps = Button & { children?: string; }; +export type ButtonProps = Button & { children?: any; }; export function Button({ children, ...props }: ButtonProps): ButtonComponent { return { diff --git a/components-jsx/ComponentMessage.tsx b/components-jsx/ComponentMessage.tsx index f9a7dd0..c1b4380 100644 --- a/components-jsx/ComponentMessage.tsx +++ b/components-jsx/ComponentMessage.tsx @@ -3,7 +3,7 @@ import { CreateMessageOptions, EditMessageOptions, MessageComponent, MessageFlag import { childrenToArray } from "./utils"; type MessageOptions = CreateMessageOptions | EditMessageOptions; -export type ComponentMessageProps = MessageOptions & { children: MessageComponent[]; }; +export type ComponentMessageProps = MessageOptions & { children?: MessageComponent[]; }; export function ComponentMessage({ children, flags, ...props }: ComponentMessageProps): MessageOptions { return { diff --git a/components-jsx/Container.tsx b/components-jsx/Container.tsx index 913757d..1a80d58 100644 --- a/components-jsx/Container.tsx +++ b/components-jsx/Container.tsx @@ -2,7 +2,7 @@ import { ComponentTypes, ContainerComponent } from "oceanic.js"; import { childrenToArray } from "./utils"; -export type ContainerProps = Omit & { children: ContainerComponent["components"]; }; +export type ContainerProps = Omit & { children?: ContainerComponent["components"] }; export function Container({ children, ...props }: ContainerProps): ContainerComponent { return { diff --git a/components-jsx/Divider.tsx b/components-jsx/Divider.tsx deleted file mode 100644 index 320a248..0000000 --- a/components-jsx/Divider.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { Separator } from "./Separator"; - -export function Divider() { - return ; -} diff --git a/components-jsx/JSX.d.ts b/components-jsx/JSX.d.ts deleted file mode 100644 index 91bb0f6..0000000 --- a/components-jsx/JSX.d.ts +++ /dev/null @@ -1,5 +0,0 @@ -declare namespace JSX { - interface ElementChildrenAttribute { - children: {}; - } -} diff --git a/components-jsx/MediaGallery.tsx b/components-jsx/MediaGallery.tsx index 4104e5a..4082ee6 100644 --- a/components-jsx/MediaGallery.tsx +++ b/components-jsx/MediaGallery.tsx @@ -2,12 +2,12 @@ import { ComponentTypes, MediaGalleryComponent } from "oceanic.js"; import { childrenToArray } from "./utils"; -export type MediaGalleryProps = Omit & { children: MediaGalleryComponent["items"]; }; +export type MediaGalleryProps = Omit & { children: MediaGalleryComponent["items"] }; -export function MediaGallery({ children, ...props }: MediaGalleryProps): MediaGalleryComponent { +export function MediaGallery(props: MediaGalleryProps): MediaGalleryComponent { return { type: ComponentTypes.MEDIA_GALLERY, - items: childrenToArray(children), + items: childrenToArray(props.children), ...props }; } diff --git a/components-jsx/Section.tsx b/components-jsx/Section.tsx index c746c7e..3c511fd 100644 --- a/components-jsx/Section.tsx +++ b/components-jsx/Section.tsx @@ -3,14 +3,14 @@ import { ButtonComponent, ComponentTypes, SectionComponent, TextDisplayComponent import { childrenToArray } from "./utils"; export interface SectionProps { - children: TextDisplayComponent[]; + children: TextDisplayComponent[] accessory: ThumbnailComponent | ButtonComponent; } -export function Section({ children, ...props }: SectionProps): SectionComponent { +export function Section(props: SectionProps): SectionComponent { return { type: ComponentTypes.SECTION, - components: childrenToArray(children), + components: childrenToArray(props.children), ...props }; } diff --git a/components-jsx/StringSelect.tsx b/components-jsx/StringSelect.tsx index f07dc5c..abfb08d 100644 --- a/components-jsx/StringSelect.tsx +++ b/components-jsx/StringSelect.tsx @@ -2,12 +2,12 @@ import { ComponentTypes, StringSelectMenu } from "oceanic.js"; import { childrenToArray } from "./utils"; -export type StringSelectProps = Omit & { children: StringSelectMenu["options"]; }; +export type StringSelectProps = Omit & { children: StringSelectMenu["options"] }; -export function StringSelect({ children, ...props }: StringSelectProps): StringSelectMenu { +export function StringSelect(props: StringSelectProps): StringSelectMenu { return { type: ComponentTypes.STRING_SELECT, - options: childrenToArray(children), + options: childrenToArray(props.children), ...props }; } diff --git a/components-jsx/TextDisplay.tsx b/components-jsx/TextDisplay.tsx index 029be66..27a6a25 100644 --- a/components-jsx/TextDisplay.tsx +++ b/components-jsx/TextDisplay.tsx @@ -3,12 +3,12 @@ import { ComponentTypes, TextDisplayComponent } from "oceanic.js"; import { childrenToString } from "./utils"; export interface TextDisplayProps { - children: any; + children?: any; id?: number; } export function TextDisplay({ children, id }: TextDisplayProps): TextDisplayComponent { - children = childrenToString("TextDisplay", children)!; + children = childrenToString("TextDisplay", children); if (!children) { throw new Error("TextDisplay requires at least one child"); } diff --git a/components-jsx/Thumbnail.tsx b/components-jsx/Thumbnail.tsx index eb40075..cecc7e1 100644 --- a/components-jsx/Thumbnail.tsx +++ b/components-jsx/Thumbnail.tsx @@ -1,11 +1,11 @@ import { ComponentTypes, ThumbnailComponent } from "oceanic.js"; -export type ThumbnailProps = Omit & { children: ThumbnailComponent["media"]; }; +export type ThumbnailProps = Omit & { children: ThumbnailComponent["media"] }; -export function Thumbnail({ children, ...props }: ThumbnailProps): ThumbnailComponent { +export function Thumbnail(props: ThumbnailProps): ThumbnailComponent { return { type: ComponentTypes.THUMBNAIL, - media: children, + media: props.children, ...props }; } diff --git a/components-jsx/br.tsx b/components-jsx/br.tsx deleted file mode 100644 index 2ae4f7c..0000000 --- a/components-jsx/br.tsx +++ /dev/null @@ -1,9 +0,0 @@ -import { TextDisplay } from "./TextDisplay"; - -export function br() { - return ( - <> - {"\n"} - - ); -} diff --git a/components-jsx/index.ts b/components-jsx/index.ts index 0a72757..5d3941e 100644 --- a/components-jsx/index.ts +++ b/components-jsx/index.ts @@ -1,9 +1,7 @@ export * from "./ActionRow"; -export * from "./br"; export * from "./Button"; export * from "./ComponentMessage"; export * from "./Container"; -export * from "./Divider"; export * from "./File"; export * from "./MediaGallery"; export * from "./MediaGalleryItem"; diff --git a/components-jsx/runtime.ts b/components-jsx/runtime.ts index 5b998b5..ba1246f 100644 --- a/components-jsx/runtime.ts +++ b/components-jsx/runtime.ts @@ -1,8 +1,6 @@ export const Fragment = Symbol("ComponentsJsx.Fragment"); -type FunctionComponent = (props: any) => any; - -export function createElement(type: typeof Fragment | FunctionComponent, props: any, ...children: any[]) { +export function createElement(type: typeof Fragment | ((props: any) => any), props: any, ...children: any[]) { if (type === Fragment) { return children; } diff --git a/components-jsx/utils.ts b/components-jsx/utils.ts index 0df7aca..cb203af 100644 --- a/components-jsx/utils.ts +++ b/components-jsx/utils.ts @@ -7,7 +7,7 @@ export function filterChildren(children: any[]) { export function childrenToString(name: string, children: any) { if (Array.isArray(children)) { - return filterChildren(children).join(""); + return filterChildren(children).join("\n"); } if (typeof children === "string") { return children; diff --git a/package.json b/package.json index 26284a2..5e2f967 100644 --- a/package.json +++ b/package.json @@ -3,17 +3,19 @@ "packageManager": "pnpm@10.8.1", "dependencies": { "esbuild": "^0.25.3", + "fastify": "^5.3.2", "oceanic.js": "^1.12.0", "sqlite": "^5.1.1", "sqlite3": "^5.1.7", "typescript": "^5.8.3" }, "devDependencies": { - "@types/node": "^22.15.2" + "@types/node": "^22.15.2", + "tsx": "^4.19.3" }, "scripts": { - "dev": "pnpm exec tsx --watch-path=src --watch build.mjs start", + "dev": "tsx --watch --inspect-brk --env-file-if-exists=.env src/index.ts", "build": "node build.mjs", - "start": "node build.mjs && node --env-file=.env dist/index.js" + "start": "node build.mjs && node dist/index.js" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 69b00dd..8a82ddd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ importers: esbuild: specifier: ^0.25.3 version: 0.25.4 + fastify: + specifier: ^5.3.2 + version: 5.3.2 oceanic.js: specifier: ^1.12.0 version: 1.12.0 @@ -27,6 +30,9 @@ importers: '@types/node': specifier: ^22.15.2 version: 22.15.17 + tsx: + specifier: ^4.19.3 + version: 4.19.4 packages: @@ -184,6 +190,24 @@ packages: cpu: [x64] os: [win32] + '@fastify/ajv-compiler@4.0.2': + resolution: {integrity: sha512-Rkiu/8wIjpsf46Rr+Fitd3HRP+VsxUFDDeag0hs9L0ksfnwx2g7SPQQTFL0E8Qv+rfXzQOxBJnjUB9ITUDjfWQ==} + + '@fastify/error@4.1.0': + resolution: {integrity: sha512-KeFcciOr1eo/YvIXHP65S94jfEEqn1RxTRBT1aJaHxY5FK0/GDXYozsQMMWlZoHgi8i0s+YtrLsgj/JkUUjSkQ==} + + '@fastify/fast-json-stringify-compiler@5.0.3': + resolution: {integrity: sha512-uik7yYHkLr6fxd8hJSZ8c+xF4WafPK+XzneQDPU+D10r5X19GW8lJcom2YijX2+qtFF1ENJlHXKFM9ouXNJYgQ==} + + '@fastify/forwarded@3.0.0': + resolution: {integrity: sha512-kJExsp4JCms7ipzg7SJ3y8DwmePaELHxKYtg+tZow+k0znUTf3cb+npgyqm8+ATZOdmfgfydIebPDWM172wfyA==} + + '@fastify/merge-json-schemas@0.2.1': + resolution: {integrity: sha512-OA3KGBCy6KtIvLf8DINC5880o5iBlDX4SxzLQS8HorJAbqluzLRn80UXU0bxZn7UOFhFgpRJDasfwn9nG4FG4A==} + + '@fastify/proxy-addr@5.0.0': + resolution: {integrity: sha512-37qVVA1qZ5sgH7KpHkkC4z9SK6StIsIcOmpjvMPXNb3vx2GQxhZocogVYbr2PbbeLCQxYIPDok307xEvRZOzGA==} + '@gar/promisify@1.1.3': resolution: {integrity: sha512-k2Ty1JcVojjJFwrg/ThKi2ujJ7XNLYaFGNB/bWT9wGR+oSMJHMa5w+CUq6p/pVrKeNNgA7pCqEcjSnHVoqJQFw==} @@ -208,6 +232,9 @@ packages: abbrev@1.1.1: resolution: {integrity: sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q==} + abstract-logging@2.0.1: + resolution: {integrity: sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA==} + agent-base@6.0.2: resolution: {integrity: sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==} engines: {node: '>= 6.0.0'} @@ -220,6 +247,17 @@ packages: resolution: {integrity: sha512-4I7Td01quW/RpocfNayFdFVk1qSuoh0E7JrbRJ16nH01HhKFQ88INq9Sd+nd72zqRySlr9BmDA8xlEJ6vJMrYA==} engines: {node: '>=8'} + ajv-formats@3.0.1: + resolution: {integrity: sha512-8iUql50EUR+uUcdRQ3HDqa6EVyo3docL8g5WJ3FNcWmu62IbkGUue/pEyLBW8VGKKucTPgqeks4fIU1DA4yowQ==} + peerDependencies: + ajv: ^8.0.0 + peerDependenciesMeta: + ajv: + optional: true + + ajv@8.17.1: + resolution: {integrity: sha512-B/gBuNg5SiMTrPkC+A2+cW0RszwxYmn6VYxB/inlBStS5nx6xHIt/ehKRhIMhqusl7a8LjQoZnjCs5vhwxOQ1g==} + ansi-regex@5.0.1: resolution: {integrity: sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==} engines: {node: '>=8'} @@ -232,6 +270,13 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} deprecated: This package is no longer supported. + atomic-sleep@1.0.0: + resolution: {integrity: sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ==} + engines: {node: '>=8.0.0'} + + avvio@9.1.0: + resolution: {integrity: sha512-fYASnYi600CsH/j9EQov7lECAniYiBFiiAtBNuZYLA2leLe9qOvZzqYHFjtIj6gD2VMoMLP14834LFWvr4IfDw==} + balanced-match@1.0.2: resolution: {integrity: sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==} @@ -275,6 +320,10 @@ packages: console-control-strings@1.1.0: resolution: {integrity: sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==} + cookie@1.0.2: + resolution: {integrity: sha512-9Kr/j4O16ISv8zBBhJoi4bXOYNTkFLOqSL3UDB0njXxCXNezjeyVrJyGOWtgfs/q2km1gwBcfH8q1yEGoMYunA==} + engines: {node: '>=18'} + debug@4.4.0: resolution: {integrity: sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==} engines: {node: '>=6.0'} @@ -295,6 +344,10 @@ packages: delegates@1.0.0: resolution: {integrity: sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==} + dequal@2.0.3: + resolution: {integrity: sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==} + engines: {node: '>=6'} + detect-libc@2.0.4: resolution: {integrity: sha512-3UDv+G9CsCKO1WKMGw9fwq/SWJYbI0c5Y7LU1AXYoDdbhE2AHQ6N6Nb34sG8Fj7T5APy8qXDCKuuIHd1BR0tVA==} engines: {node: '>=8'} @@ -327,9 +380,38 @@ packages: resolution: {integrity: sha512-XYfuKMvj4O35f/pOXLObndIRvyQ+/+6AhODh+OKWj9S9498pHHn/IMszH+gt0fBCRWMNfk1ZSp5x3AifmnI2vg==} engines: {node: '>=6'} + fast-decode-uri-component@1.0.1: + resolution: {integrity: sha512-WKgKWg5eUxvRZGwW8FvfbaH7AXSh2cL+3j5fMGzUMCxWBJ3dV3a7Wz8y2f/uQ0e3B6WmodD3oS54jTQ9HVTIIg==} + + fast-deep-equal@3.1.3: + resolution: {integrity: sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==} + + fast-json-stringify@6.0.1: + resolution: {integrity: sha512-s7SJE83QKBZwg54dIbD5rCtzOBVD43V1ReWXXYqBgwCwHLYAAT0RQc/FmrQglXqWPpz6omtryJQOau5jI4Nrvg==} + + fast-querystring@1.1.2: + resolution: {integrity: sha512-g6KuKWmFXc0fID8WWH0jit4g0AGBoJhCkJMb1RmbsSEUNvQ+ZC8D6CUZ+GtF8nMzSPXnhiePyyqqipzNNEnHjg==} + + fast-redact@3.5.0: + resolution: {integrity: sha512-dwsoQlS7h9hMeYUq1W++23NDcBLV4KqONnITDV9DjfS3q1SgDGVrBdvvTLUotWtPSD7asWDV9/CmsZPy8Hf70A==} + engines: {node: '>=6'} + + fast-uri@3.0.6: + resolution: {integrity: sha512-Atfo14OibSv5wAp4VWNsFYE1AchQRTv9cBGWET4pZWHzYshFSS9NQI6I57rdKn9croWVMbYFbLhJ+yJvmZIIHw==} + + fastify@5.3.2: + resolution: {integrity: sha512-AIPqBgtqBAwkOkrnwesEE+dOyU30dQ4kh7udxeGVR05CRGwubZx+p2H8P0C4cRnQT0+EPK4VGea2DTL2RtWttg==} + + fastq@1.19.1: + resolution: {integrity: sha512-GwLTyxkCXjXbxqIhTsMI2Nui8huMPtnxg7krajPJAjnEG/iiOS7i+zCtWGZR9G0NBKbXKh6X9m9UIsYX/N6vvQ==} + file-uri-to-path@1.0.0: resolution: {integrity: sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==} + find-my-way@9.3.0: + resolution: {integrity: sha512-eRoFWQw+Yv2tuYlK2pjFS2jGXSxSppAs3hSQjfxVKxM5amECzIgYYc1FEI8ZmhSh/Ig+FrKEz43NLRKJjYCZVg==} + engines: {node: '>=20'} + fs-constants@1.0.0: resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} @@ -340,11 +422,19 @@ packages: fs.realpath@1.0.0: resolution: {integrity: sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==} + fsevents@2.3.3: + resolution: {integrity: sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==} + engines: {node: ^8.16.0 || ^10.6.0 || >=11.0.0} + os: [darwin] + gauge@4.0.4: resolution: {integrity: sha512-f9m+BEN5jkg6a0fZjleidjN51VE1X+mPFQ2DJ0uv1V39oCLCbsGe6yjbBnp7eK7z/+GAon99a3nHuqbuuthyPg==} engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} deprecated: This package is no longer supported. + get-tsconfig@4.10.0: + resolution: {integrity: sha512-kGzZ3LWWQcGIAmg6iWvXn0ei6WDtV26wzHRMwDSzmAbcXrTEXxHy6IehI6/4eT6VRKyMP1eF1VqwrVUmE/LR7A==} + github-from-package@0.0.0: resolution: {integrity: sha512-SyHy3T1v2NUXn29OsWdxmK6RwHD+vkj3v8en8AOBZ1wBQ/hCAQ5bAQTD02kW4W9tUp/3Qh6J8r9EvntiyCmOOw==} @@ -404,6 +494,10 @@ packages: resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==} engines: {node: '>= 12'} + ipaddr.js@2.2.0: + resolution: {integrity: sha512-Ag3wB2o37wslZS19hZqorUnrnzSkpOVy+IiiDEiTqNubEYpYuHWIf6K4psgN2ZWKExS4xhVCrRVfb/wfW8fWJA==} + engines: {node: '>= 10'} + is-fullwidth-code-point@3.0.0: resolution: {integrity: sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==} engines: {node: '>=8'} @@ -417,6 +511,15 @@ packages: jsbn@1.1.0: resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==} + json-schema-ref-resolver@2.0.1: + resolution: {integrity: sha512-HG0SIB9X4J8bwbxCbnd5FfPEbcXAJYTi1pBJeP/QPON+w8ovSME8iRG+ElHNxZNX2Qh6eYn1GdzJFS4cDFfx0Q==} + + json-schema-traverse@1.0.0: + resolution: {integrity: sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug==} + + light-my-request@6.6.0: + resolution: {integrity: sha512-CHYbu8RtboSIoVsHZ6Ye4cj4Aw/yg2oAFimlF7mNvfDV192LR7nDiKtSIfCuLT7KokPSTn/9kfVLm5OGN0A28A==} + lru-cache@6.0.0: resolution: {integrity: sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==} engines: {node: '>=10'} @@ -511,6 +614,10 @@ packages: resolution: {integrity: sha512-e3h5ptwBfbX4/gDz13UFiIfAFsaZrXDwJbfTdV7YEKdQG6d0A6of2KGzkBbqXrVC5wmM/7TWAYeh2fe9zuxGYA==} engines: {node: '>=18.13.0'} + on-exit-leak-free@2.1.2: + resolution: {integrity: sha512-0eJJY6hXLGf1udHwfNftBqH+g73EU4B504nZeKpz1sYRKafAghwxEJunB2O7rDZkL4PGfsMVnTXZ2EjibbqcsA==} + engines: {node: '>=14.0.0'} + once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} @@ -522,6 +629,16 @@ packages: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} + pino-abstract-transport@2.0.0: + resolution: {integrity: sha512-F63x5tizV6WCh4R6RHyi2Ml+M70DNRXt/+HANowMflpgGFMAym/VKm6G7ZOQRjqN7XbGxK1Lg9t6ZrtzOaivMw==} + + pino-std-serializers@7.0.0: + resolution: {integrity: sha512-e906FRY0+tV27iq4juKzSYPbUj2do2X2JX4EzSca1631EB2QJQUqGbDuERal7LCtOpxl6x3+nvo9NPZcmjkiFA==} + + pino@9.6.0: + resolution: {integrity: sha512-i85pKRCt4qMjZ1+L7sy2Ag4t1atFcdbEt76+7iRJn1g2BvsnRMGu9p8pivl9fs63M2kF/A0OacFZhTub+m/qMg==} + hasBin: true + prebuild-install@7.1.3: resolution: {integrity: sha512-8Mf2cbV7x1cXPUILADGI3wuhfqWvtiLA1iclTDbFRZkgRQS0NqsPZphna9V+HyTEadheuPmjaJMsbzKQFOzLug==} engines: {node: '>=10'} @@ -544,6 +661,12 @@ packages: opusscript: optional: true + process-warning@4.0.1: + resolution: {integrity: sha512-3c2LzQ3rY9d0hc1emcsHhfT9Jwz0cChib/QN89oME2R451w5fy3f0afAhERFZAwrbDU43wk12d0ORBpDVME50Q==} + + process-warning@5.0.0: + resolution: {integrity: sha512-a39t9ApHNx2L4+HBnQKqxxHNs1r7KF+Intd8Q/g1bUh6q0WIp9voPXJ/x0j+ZL45KF1pJd9+q2jLIRMfvEshkA==} + promise-inflight@1.0.1: resolution: {integrity: sha512-6zWPyEOFaQBJYcGMHBKTKJ3u6TBsnMFOIZSa6ce1e/ZrrsOlnHRHbabMjLiBYKp+n44X9eUI6VUPaukCXHuG4g==} peerDependencies: @@ -559,6 +682,9 @@ packages: pump@3.0.2: resolution: {integrity: sha512-tUPXtzlGM8FE3P0ZL6DVs/3P58k9nk8/jZeQCurTJylQA8qFYzHFfhBJkuqyE0FifOsQ0uKWekiZ5g8wtr28cw==} + quick-format-unescaped@4.0.4: + resolution: {integrity: sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg==} + rc@1.2.8: resolution: {integrity: sha512-y3bGgqKj3QBdxLbLkomlohkvsA8gdAiUQlSBJnBhfn+BPxg4bc62d8TcBW15wavDfgexCgccckhcZvywyQYPOw==} hasBin: true @@ -567,10 +693,32 @@ packages: resolution: {integrity: sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==} engines: {node: '>= 6'} + real-require@0.2.0: + resolution: {integrity: sha512-57frrGM/OCTLqLOAh0mhVA9VBMHd+9U7Zb2THMGdBUoZVOtGbJzjxsYGDJ3A9AYYCP4hn6y1TVbaOfzWtm5GFg==} + engines: {node: '>= 12.13.0'} + + require-from-string@2.0.2: + resolution: {integrity: sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw==} + engines: {node: '>=0.10.0'} + + resolve-pkg-maps@1.0.0: + resolution: {integrity: sha512-seS2Tj26TBVOC2NIc2rOe2y2ZO7efxITtLZcGSOnHHNOQ7CkiUBfw0Iw2ck6xkIhPwLhKNLS8BO+hEpngQlqzw==} + + ret@0.5.0: + resolution: {integrity: sha512-I1XxrZSQ+oErkRR4jYbAyEEu2I0avBvvMM5JN+6EBprOGRCs63ENqZ3vjavq8fBw2+62G5LF5XelKwuJpcvcxw==} + engines: {node: '>=10'} + retry@0.12.0: resolution: {integrity: sha512-9LkiTwjUh6rT555DtE9rTX+BKByPfrMzEAtnlEtdEwr3Nkffwiihqe2bWADg+OQRjt9gl6ICdmB/ZFDCGAtSow==} engines: {node: '>= 4'} + reusify@1.1.0: + resolution: {integrity: sha512-g6QUff04oZpHs0eG5p83rFLhHeV00ug/Yf9nZM6fLeUrPguBTkTQOdpAWWspMh55TZfVQDPaN3NQJfbVRAxdIw==} + engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + + rfdc@1.4.1: + resolution: {integrity: sha512-q1b3N5QkRUWUl7iyylaaj3kOpIT0N2i9MqIEQXP73GVsN9cw3fdx8X63cEmWhJGi2PPCF23Ijp7ktmd39rawIA==} + rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} deprecated: Rimraf versions prior to v4 are no longer supported @@ -579,9 +727,19 @@ packages: safe-buffer@5.2.1: resolution: {integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==} + safe-regex2@5.0.0: + resolution: {integrity: sha512-YwJwe5a51WlK7KbOJREPdjNrpViQBI3p4T50lfwPuDhZnE3XGVTlGvi+aolc5+RvxDD6bnUmjVsU9n1eboLUYw==} + + safe-stable-stringify@2.5.0: + resolution: {integrity: sha512-b3rppTKm9T+PsVCBEOUR46GWI7fdOs00VKZ1+9c1EWDaDMvjQc6tUwuFyIprgGgTcWoVHSKrU8H31ZHA2e0RHA==} + engines: {node: '>=10'} + safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} + secure-json-parse@4.0.0: + resolution: {integrity: sha512-dxtLJO6sc35jWidmLxo7ij+Eg48PM/kleBsxpC8QJE0qJICe+KawkDQmvCMZUr9u7WKVHgMW6vy3fQ7zMiFZMA==} + semver@7.7.1: resolution: {integrity: sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==} engines: {node: '>=10'} @@ -590,6 +748,9 @@ packages: set-blocking@2.0.0: resolution: {integrity: sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==} + set-cookie-parser@2.7.1: + resolution: {integrity: sha512-IOc8uWeOZgnb3ptbCURJWNjWUPcO3ZnTTdzsurqERrP6nPyv+paC55vJM0LpOlT2ne+Ix+9+CRG1MNLlyZ4GjQ==} + signal-exit@3.0.7: resolution: {integrity: sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==} @@ -611,6 +772,13 @@ packages: resolution: {integrity: sha512-D3YaD0aRxR3mEcqnidIs7ReYJFVzWdd6fXJYUM8ixcQcJRGTka/b3saV0KflYhyVJXKhb947GndU35SxYNResQ==} engines: {node: '>= 10.0.0', npm: '>= 3.0.0'} + sonic-boom@4.2.0: + resolution: {integrity: sha512-INb7TM37/mAcsGmc9hyyI6+QR3rR1zVRu36B0NeGXKnOOLiZOfER5SA+N7X7k3yUYRzLWafduTDvJAfDswwEww==} + + split2@4.2.0: + resolution: {integrity: sha512-UcjcJOWknrNkF6PLX83qcHM6KHgVKNkV62Y8a5uYDVv9ydGQVwAHMKqHdJje1VTWpljG0WYpCDhrCdAOYH4TWg==} + engines: {node: '>= 10.x'} + sprintf-js@1.1.3: resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==} @@ -650,9 +818,21 @@ packages: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} + thread-stream@3.1.0: + resolution: {integrity: sha512-OqyPZ9u96VohAyMfJykzmivOrY2wfMSf3C5TtFJVgN+Hm6aj+voFhlK+kZEIv2FBh1X6Xp3DlnCOfEQ3B2J86A==} + + toad-cache@3.7.0: + resolution: {integrity: sha512-/m8M+2BJUpoJdgAHoG+baCwBT+tf2VraSfkBgl0Y00qIWt41DJ8R5B8nsEw0I58YwF5IZH6z24/2TobDKnqSWw==} + engines: {node: '>=12'} + tslib@2.8.1: resolution: {integrity: sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==} + tsx@4.19.4: + resolution: {integrity: sha512-gK5GVzDkJK1SI1zwHf32Mqxf2tSJkNx+eYcNly5+nHvWqXUJYUkWBQtKauoESz3ymezAI++ZwT855x5p5eop+Q==} + engines: {node: '>=18.0.0'} + hasBin: true + tunnel-agent@0.6.0: resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} @@ -792,6 +972,29 @@ snapshots: '@esbuild/win32-x64@0.25.4': optional: true + '@fastify/ajv-compiler@4.0.2': + dependencies: + ajv: 8.17.1 + ajv-formats: 3.0.1(ajv@8.17.1) + fast-uri: 3.0.6 + + '@fastify/error@4.1.0': {} + + '@fastify/fast-json-stringify-compiler@5.0.3': + dependencies: + fast-json-stringify: 6.0.1 + + '@fastify/forwarded@3.0.0': {} + + '@fastify/merge-json-schemas@0.2.1': + dependencies: + dequal: 2.0.3 + + '@fastify/proxy-addr@5.0.0': + dependencies: + '@fastify/forwarded': 3.0.0 + ipaddr.js: 2.2.0 + '@gar/promisify@1.1.3': optional: true @@ -822,6 +1025,8 @@ snapshots: abbrev@1.1.1: optional: true + abstract-logging@2.0.1: {} + agent-base@6.0.2: dependencies: debug: 4.4.0 @@ -840,6 +1045,17 @@ snapshots: indent-string: 4.0.0 optional: true + ajv-formats@3.0.1(ajv@8.17.1): + optionalDependencies: + ajv: 8.17.1 + + ajv@8.17.1: + dependencies: + fast-deep-equal: 3.1.3 + fast-uri: 3.0.6 + json-schema-traverse: 1.0.0 + require-from-string: 2.0.2 + ansi-regex@5.0.1: optional: true @@ -852,6 +1068,13 @@ snapshots: readable-stream: 3.6.2 optional: true + atomic-sleep@1.0.0: {} + + avvio@9.1.0: + dependencies: + '@fastify/error': 4.1.0 + fastq: 1.19.1 + balanced-match@1.0.2: optional: true @@ -918,6 +1141,8 @@ snapshots: console-control-strings@1.1.0: optional: true + cookie@1.0.2: {} + debug@4.4.0: dependencies: ms: 2.1.3 @@ -932,6 +1157,8 @@ snapshots: delegates@1.0.0: optional: true + dequal@2.0.3: {} + detect-libc@2.0.4: {} discord-api-types@0.37.120: @@ -985,8 +1212,57 @@ snapshots: expand-template@2.0.3: {} + fast-decode-uri-component@1.0.1: {} + + fast-deep-equal@3.1.3: {} + + fast-json-stringify@6.0.1: + dependencies: + '@fastify/merge-json-schemas': 0.2.1 + ajv: 8.17.1 + ajv-formats: 3.0.1(ajv@8.17.1) + fast-uri: 3.0.6 + json-schema-ref-resolver: 2.0.1 + rfdc: 1.4.1 + + fast-querystring@1.1.2: + dependencies: + fast-decode-uri-component: 1.0.1 + + fast-redact@3.5.0: {} + + fast-uri@3.0.6: {} + + fastify@5.3.2: + dependencies: + '@fastify/ajv-compiler': 4.0.2 + '@fastify/error': 4.1.0 + '@fastify/fast-json-stringify-compiler': 5.0.3 + '@fastify/proxy-addr': 5.0.0 + abstract-logging: 2.0.1 + avvio: 9.1.0 + fast-json-stringify: 6.0.1 + find-my-way: 9.3.0 + light-my-request: 6.6.0 + pino: 9.6.0 + process-warning: 5.0.0 + rfdc: 1.4.1 + secure-json-parse: 4.0.0 + semver: 7.7.1 + toad-cache: 3.7.0 + + fastq@1.19.1: + dependencies: + reusify: 1.1.0 + file-uri-to-path@1.0.0: {} + find-my-way@9.3.0: + dependencies: + fast-deep-equal: 3.1.3 + fast-querystring: 1.1.2 + safe-regex2: 5.0.0 + fs-constants@1.0.0: {} fs-minipass@2.1.0: @@ -996,6 +1272,9 @@ snapshots: fs.realpath@1.0.0: optional: true + fsevents@2.3.3: + optional: true + gauge@4.0.4: dependencies: aproba: 2.0.0 @@ -1008,6 +1287,10 @@ snapshots: wide-align: 1.1.5 optional: true + get-tsconfig@4.10.0: + dependencies: + resolve-pkg-maps: 1.0.0 + github-from-package@0.0.0: {} glob@7.2.3: @@ -1083,6 +1366,8 @@ snapshots: sprintf-js: 1.1.3 optional: true + ipaddr.js@2.2.0: {} + is-fullwidth-code-point@3.0.0: optional: true @@ -1095,6 +1380,18 @@ snapshots: jsbn@1.1.0: optional: true + json-schema-ref-resolver@2.0.1: + dependencies: + dequal: 2.0.3 + + json-schema-traverse@1.0.0: {} + + light-my-request@6.6.0: + dependencies: + cookie: 1.0.2 + process-warning: 4.0.1 + set-cookie-parser: 2.7.1 + lru-cache@6.0.0: dependencies: yallist: 4.0.0 @@ -1234,6 +1531,8 @@ snapshots: - opusscript - utf-8-validate + on-exit-leak-free@2.1.2: {} + once@1.4.0: dependencies: wrappy: 1.0.2 @@ -1246,6 +1545,26 @@ snapshots: path-is-absolute@1.0.1: optional: true + pino-abstract-transport@2.0.0: + dependencies: + split2: 4.2.0 + + pino-std-serializers@7.0.0: {} + + pino@9.6.0: + dependencies: + atomic-sleep: 1.0.0 + fast-redact: 3.5.0 + on-exit-leak-free: 2.1.2 + pino-abstract-transport: 2.0.0 + pino-std-serializers: 7.0.0 + process-warning: 4.0.1 + quick-format-unescaped: 4.0.4 + real-require: 0.2.0 + safe-stable-stringify: 2.5.0 + sonic-boom: 4.2.0 + thread-stream: 3.1.0 + prebuild-install@7.1.3: dependencies: detect-libc: 2.0.4 @@ -1264,6 +1583,10 @@ snapshots: prism-media@1.3.5: optional: true + process-warning@4.0.1: {} + + process-warning@5.0.0: {} + promise-inflight@1.0.1: optional: true @@ -1278,6 +1601,8 @@ snapshots: end-of-stream: 1.4.4 once: 1.4.0 + quick-format-unescaped@4.0.4: {} + rc@1.2.8: dependencies: deep-extend: 0.6.0 @@ -1291,9 +1616,21 @@ snapshots: string_decoder: 1.3.0 util-deprecate: 1.0.2 + real-require@0.2.0: {} + + require-from-string@2.0.2: {} + + resolve-pkg-maps@1.0.0: {} + + ret@0.5.0: {} + retry@0.12.0: optional: true + reusify@1.1.0: {} + + rfdc@1.4.1: {} + rimraf@3.0.2: dependencies: glob: 7.2.3 @@ -1301,14 +1638,24 @@ snapshots: safe-buffer@5.2.1: {} + safe-regex2@5.0.0: + dependencies: + ret: 0.5.0 + + safe-stable-stringify@2.5.0: {} + safer-buffer@2.1.2: optional: true + secure-json-parse@4.0.0: {} + semver@7.7.1: {} set-blocking@2.0.0: optional: true + set-cookie-parser@2.7.1: {} + signal-exit@3.0.7: optional: true @@ -1338,6 +1685,12 @@ snapshots: smart-buffer: 4.2.0 optional: true + sonic-boom@4.2.0: + dependencies: + atomic-sleep: 1.0.0 + + split2@4.2.0: {} + sprintf-js@1.1.3: optional: true @@ -1402,8 +1755,21 @@ snapshots: mkdirp: 1.0.4 yallist: 4.0.0 + thread-stream@3.1.0: + dependencies: + real-require: 0.2.0 + + toad-cache@3.7.0: {} + tslib@2.8.1: {} + tsx@4.19.4: + dependencies: + esbuild: 0.25.4 + get-tsconfig: 4.10.0 + optionalDependencies: + fsevents: 2.3.3 + tunnel-agent@0.6.0: dependencies: safe-buffer: 5.2.1 diff --git a/src/components/User.tsx b/src/components/User.tsx deleted file mode 100644 index 5fbbe04..0000000 --- a/src/components/User.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { Section } from "components-jsx/Section"; -import { client } from ".."; -import { Thumbnail } from "components-jsx/Thumbnail"; -import { TextDisplay } from "components-jsx/TextDisplay"; -import { br } from "components-jsx/br"; - -export async function User(props: { id: string }) { - const user = await client.rest.users.get(props.id); - - return ( -
- } - > - ### User - - {user.globalName || user.username} -
- -# @{user.username} -
-
- ); -} diff --git a/src/cv2.ts b/src/cv2.ts new file mode 100644 index 0000000..5fe62c9 --- /dev/null +++ b/src/cv2.ts @@ -0,0 +1,68 @@ +import { + AnyMessageComponent, + Component, + ComponentTypes, + FileComponent, + MediaGalleryComponent, + MessageActionRow, + SectionComponent, + SeparatorComponent, + TextDisplayComponent +} from "oceanic.js"; +import { client } from "."; + +export const Divider: SeparatorComponent = { + type: ComponentTypes.SEPARATOR, + divider: true +}; +export const Header = ( + title: string, + level: 1 | 2 | 3 +): TextDisplayComponent => { + return { + type: ComponentTypes.TEXT_DISPLAY, + content: `${"#".repeat(level)} ${title}` + }; +}; + +export async function generateUserComponent( + id: string +): Promise { + const user = await client.rest.users.get(id); + return { + type: ComponentTypes.SECTION, + components: [ + Header("User", 3), + { + type: ComponentTypes.TEXT_DISPLAY, + content: `${user.globalName || user.username}\n-# @${ + user.username + }` + } + ], + accessory: { + type: ComponentTypes.THUMBNAIL, + media: { + url: user.avatarURL("png", 128) + } + } + }; +} +export function generateList( + elements: { + [key: string]: string; + }, + title?: string +): TextDisplayComponent[] { + let working: TextDisplayComponent[] = []; + + if (title) working.push(Header(title, 3)); + for (const key of Object.keys(elements)) { + working.push({ + type: ComponentTypes.TEXT_DISPLAY, + content: `**${key}**\n-# ${elements[key].replaceAll("\n", "\n-# ")}` + }); + } + + return working; +} diff --git a/src/index.ts b/src/index.ts index 415891f..63ae32d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,7 +16,7 @@ export const client = new Client({ client.on("ready", async () => { console.log(`Logged in as ${client.user.tag}`); console.log("Checking user token"); - const selfappInfo: any = await selfappReq("/users/@me", "GET"); + const selfappInfo = await selfappReq("/users/@me", "GET"); if (!selfappInfo.username) console.error("Can't use selfapp"); else console.log("Can use selfapp"); @@ -27,9 +27,5 @@ process.on("uncaughtException", (e) => { console.error(e); }); -export function start() { - openDb(); - client.connect(); -} - -start(); +openDb(); +client.connect(); diff --git a/src/joinRequestHandler.tsx b/src/joinRequestHandler.ts similarity index 65% rename from src/joinRequestHandler.tsx rename to src/joinRequestHandler.ts index 91bb1a4..caa6c8f 100644 --- a/src/joinRequestHandler.tsx +++ b/src/joinRequestHandler.ts @@ -1,19 +1,9 @@ import { ComponentTypes, MessageFlags, Shard } from "oceanic.js"; import { client } from "."; import { Constants } from "./Constants"; +import { Header, Divider, generateUserComponent } from "./cv2"; import { db } from "./database"; -import { - ActionRow, - Button, - ComponentMessage, - Container, - Divider, - Section, - Separator, - TextDisplay -} from "~/components"; import { selfappReq } from "./selfappReq"; -import { User } from "./components/User"; export async function setupJoinRequestHandler(shard: Shard) { shard.ws?.on("message", async (d) => { @@ -28,9 +18,9 @@ export async function setupJoinRequestHandler(shard: Shard) { const pendingMsg = await client.rest.channels.createMessage( Constants.PENDING_CHANNEL_ID, - - Placeholder - + { + content: "Placeholder" + } ); await db.run( "INSERT INTO applications (id, user_id, status, message_id, channel_id) VALUES (?, ?, 0, ?, ?)", @@ -62,24 +52,34 @@ export async function setupJoinRequestHandler(shard: Shard) { } await client.rest.channels.createMessage( Constants.REJECTION_CHANNEL_ID, - - - - ## Join request withdrawn - - - - - ### Application - {application ? ( - User has applied - ) : ( - - User hasn't applied - - )} - - + { + flags: MessageFlags.IS_COMPONENTS_V2, + components: [ + { + type: ComponentTypes.CONTAINER, + accentColor: 0xffaaaa, + components: [ + Header("Join request withdrawn", 2), + Divider, + await generateUserComponent( + applicationData.user_id + ), + Divider, + Header("Application", 3), + application + ? { + type: ComponentTypes.TEXT_DISPLAY, + content: "User has applied" + } + : { + type: ComponentTypes.TEXT_DISPLAY, + content: + "User has never applied" + } + ] + } + ] + } ); break; } diff --git a/tsconfig.json b/tsconfig.json index 75e416f..a037e24 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,30 +1,121 @@ { "compilerOptions": { - "allowSyntheticDefaultImports": true, - "esModuleInterop": true, - "lib": [ - "esnext", - "esnext.array", - "esnext.asynciterable", - "esnext.symbol" - ], - "module": "commonjs", - "moduleResolution": "node", - "strict": true, - "noImplicitAny": false, - "target": "ESNEXT", + /* Visit https://aka.ms/tsconfig to read more about this file */ + + /* Projects */ + // "incremental": true, /* Save .tsbuildinfo files to allow for incremental compilation of projects. */ + // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ + // "tsBuildInfoFile": "./.tsbuildinfo", /* Specify the path to .tsbuildinfo incremental compilation file. */ + // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects. */ + // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ + // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ + + /* Language and Environment */ + "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, + // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ + // "jsx": "preserve", /* Specify what JSX code is generated. */ + // "libReplacement": true, /* Enable lib replacement. */ + // "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */ + // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ + // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */ + // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ + // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */ + // "reactNamespace": "", /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */ + // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ + // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ + // "moduleDetection": "auto", /* Control what method is used to detect module-format JS files. */ + + /* Modules */ + "module": "commonjs" /* Specify what module code is generated. */, + // "rootDir": "./", /* Specify the root folder within your source files. */ + // "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */ + // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ + // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ + // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ + // "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */ + // "types": [], /* Specify type package names to be included without being referenced in a source file. */ + // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ + // "moduleSuffixes": [], /* List of file name suffixes to search when resolving a module. */ + // "allowImportingTsExtensions": true, /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */ + // "rewriteRelativeImportExtensions": true, /* Rewrite '.ts', '.tsx', '.mts', and '.cts' file extensions in relative import paths to their JavaScript equivalent in output files. */ + // "resolvePackageJsonExports": true, /* Use the package.json 'exports' field when resolving package imports. */ + // "resolvePackageJsonImports": true, /* Use the package.json 'imports' field when resolving imports. */ + // "customConditions": [], /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */ + // "noUncheckedSideEffectImports": true, /* Check side effect imports. */ + // "resolveJsonModule": true, /* Enable importing .json files. */ + // "allowArbitraryExtensions": true, /* Enable importing files with any extension, provided a declaration file is present. */ + // "noResolve": true, /* Disallow 'import's, 'require's or ''s from expanding the number of files TypeScript should add to a project. */ + + /* JavaScript Support */ + // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */ + // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ + // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */ + + /* Emit */ + // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ + // "declarationMap": true, /* Create sourcemaps for d.ts files. */ + // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ + // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ + // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ + // "noEmit": true, /* Disable emitting files from a compilation. */ + // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ + // "removeComments": true, /* Disable emitting comments. */ + // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ + // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ + // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ + // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ + // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ + // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ + // "newLine": "crlf", /* Set the newline character for emitting files. */ + // "stripInternal": true, /* Disable emitting declarations that have '@internal' in their JSDoc comments. */ + // "noEmitHelpers": true, /* Disable generating custom helper functions like '__extends' in compiled output. */ + // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ + // "preserveConstEnums": true, /* Disable erasing 'const enum' declarations in generated code. */ + // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ + + /* Interop Constraints */ + // "isolatedModules": true, /* Ensure that each file can be safely transpiled without relying on other imports. */ + // "verbatimModuleSyntax": true, /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */ + // "isolatedDeclarations": true, /* Require sufficient annotation on exports so other tools can trivially generate declaration files. */ + // "erasableSyntaxOnly": true, /* Do not allow runtime constructs that are not part of ECMAScript. */ + // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ + "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, + // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */ + "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, + + /* Type Checking */ + "strict": true /* Enable all strict type-checking options. */, + // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied 'any' type. */ + // "strictNullChecks": true, /* When type checking, take into account 'null' and 'undefined'. */ + // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ + // "strictBindCallApply": true, /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */ + // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ + // "strictBuiltinIteratorReturn": true, /* Built-in iterators are instantiated with a 'TReturn' type of 'undefined' instead of 'any'. */ + // "noImplicitThis": true, /* Enable error reporting when 'this' is given the type 'any'. */ + // "useUnknownInCatchVariables": true, /* Default catch clause variables as 'unknown' instead of 'any'. */ + // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ + // "noUnusedLocals": true, /* Enable error reporting when local variables aren't read. */ + // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read. */ + // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ + // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ + // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ + // "noUncheckedIndexedAccess": true, /* Add 'undefined' to a type when accessed using an index. */ + // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ + // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type. */ + // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ + // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ + + /* Completeness */ + // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ + "skipLibCheck": true /* Skip type checking all .d.ts files. */, "baseUrl": ".", "paths": { - "~/*": ["src/*"], "~/components": ["components-jsx/index.ts"] }, - "skipLibCheck": true, "resolveJsonModule": true, "jsx": "preserve", - "jsxFactory": "createElement", - "jsxFragmentFactory": "Fragment", "allowJs": true, "outDir": "whofuckingcaresdude" - }, - "include": ["src/**/*", "components-jsx/**/*"] + } }