From 3b5275122cf097d3fd455d34d7a455ab03a44fd6 Mon Sep 17 00:00:00 2001 From: nin0 Date: Thu, 15 May 2025 17:42:27 -0400 Subject: [PATCH 1/4] unbrk the inspect --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e2f967..ceec6a5 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "tsx": "^4.19.3" }, "scripts": { - "dev": "tsx --watch --inspect-brk --env-file-if-exists=.env src/index.ts", + "dev": "tsx --watch --inspect --env-file-if-exists=.env src/index.ts", "build": "node build.mjs", "start": "node build.mjs && node dist/index.js" } From 6858283ecc893814b48953c5ea74f63242d23f9b Mon Sep 17 00:00:00 2001 From: nin0 Date: Thu, 15 May 2025 17:42:38 -0400 Subject: [PATCH 2/4] // @ts-pmo --- tsconfig.json | 127 +++++++------------------------------------------- 1 file changed, 17 insertions(+), 110 deletions(-) diff --git a/tsconfig.json b/tsconfig.json index a037e24..f98be7c 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,121 +1,28 @@ { "compilerOptions": { - /* 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. */, + "allowSyntheticDefaultImports": true, + "esModuleInterop": true, + "lib": [ + "esnext", + "esnext.array", + "esnext.asynciterable", + "esnext.symbol" + ], + "module": "commonjs", + "moduleResolution": "node", + "strict": true, + "noImplicitAny": false, + "target": "ESNEXT", "baseUrl": ".", "paths": { + "~/*": ["src/*"], "~/components": ["components-jsx/index.ts"] }, + "skipLibCheck": true, "resolveJsonModule": true, "jsx": "preserve", "allowJs": true, "outDir": "whofuckingcaresdude" - } + }, + "include": ["src/**/*", "components-jsx/**/*"] } From dcd22a9d8ce5edfd37ab7cc719376b66cdb01b10 Mon Sep 17 00:00:00 2001 From: nin0 Date: Fri, 16 May 2025 06:16:52 -0400 Subject: [PATCH 3/4] migrate to cv2 jsx --- components-jsx/ActionRow.tsx | 6 +- components-jsx/Button.tsx | 2 +- components-jsx/ComponentMessage.tsx | 2 +- components-jsx/Container.tsx | 2 +- components-jsx/Divider.tsx | 5 ++ components-jsx/JSX.d.ts | 5 ++ components-jsx/MediaGallery.tsx | 6 +- components-jsx/Section.tsx | 6 +- components-jsx/StringSelect.tsx | 6 +- components-jsx/TextDisplay.tsx | 4 +- components-jsx/Thumbnail.tsx | 6 +- components-jsx/br.tsx | 9 +++ components-jsx/index.ts | 2 + components-jsx/runtime.ts | 4 +- components-jsx/utils.ts | 2 +- src/components/User.tsx | 24 +++++++ src/cv2.ts | 68 ------------------- ...questHandler.ts => joinRequestHandler.tsx} | 64 ++++++++--------- 18 files changed, 101 insertions(+), 122 deletions(-) create mode 100644 components-jsx/Divider.tsx create mode 100644 components-jsx/JSX.d.ts create mode 100644 components-jsx/br.tsx create mode 100644 src/components/User.tsx delete mode 100644 src/cv2.ts rename src/{joinRequestHandler.ts => joinRequestHandler.tsx} (65%) diff --git a/components-jsx/ActionRow.tsx b/components-jsx/ActionRow.tsx index 2b1f2d5..b7907a1 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(props: ActionRowProps): MessageActionRow { +export function ActionRow({ children, ...props }: ActionRowProps): MessageActionRow { return { type: ComponentTypes.ACTION_ROW, - components: childrenToArray(props.children), + components: childrenToArray(children), ...props }; } diff --git a/components-jsx/Button.tsx b/components-jsx/Button.tsx index db3c083..b16cfaf 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?: any; }; +export type ButtonProps = Button & { children?: string; }; export function Button({ children, ...props }: ButtonProps): ButtonComponent { return { diff --git a/components-jsx/ComponentMessage.tsx b/components-jsx/ComponentMessage.tsx index c1b4380..f9a7dd0 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 1a80d58..913757d 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 new file mode 100644 index 0000000..320a248 --- /dev/null +++ b/components-jsx/Divider.tsx @@ -0,0 +1,5 @@ +import { Separator } from "./Separator"; + +export function Divider() { + return ; +} diff --git a/components-jsx/JSX.d.ts b/components-jsx/JSX.d.ts new file mode 100644 index 0000000..91bb0f6 --- /dev/null +++ b/components-jsx/JSX.d.ts @@ -0,0 +1,5 @@ +declare namespace JSX { + interface ElementChildrenAttribute { + children: {}; + } +} diff --git a/components-jsx/MediaGallery.tsx b/components-jsx/MediaGallery.tsx index 4082ee6..4104e5a 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(props: MediaGalleryProps): MediaGalleryComponent { +export function MediaGallery({ children, ...props }: MediaGalleryProps): MediaGalleryComponent { return { type: ComponentTypes.MEDIA_GALLERY, - items: childrenToArray(props.children), + items: childrenToArray(children), ...props }; } diff --git a/components-jsx/Section.tsx b/components-jsx/Section.tsx index 3c511fd..c746c7e 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(props: SectionProps): SectionComponent { +export function Section({ children, ...props }: SectionProps): SectionComponent { return { type: ComponentTypes.SECTION, - components: childrenToArray(props.children), + components: childrenToArray(children), ...props }; } diff --git a/components-jsx/StringSelect.tsx b/components-jsx/StringSelect.tsx index abfb08d..f07dc5c 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(props: StringSelectProps): StringSelectMenu { +export function StringSelect({ children, ...props }: StringSelectProps): StringSelectMenu { return { type: ComponentTypes.STRING_SELECT, - options: childrenToArray(props.children), + options: childrenToArray(children), ...props }; } diff --git a/components-jsx/TextDisplay.tsx b/components-jsx/TextDisplay.tsx index 27a6a25..029be66 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 cecc7e1..eb40075 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(props: ThumbnailProps): ThumbnailComponent { +export function Thumbnail({ children, ...props }: ThumbnailProps): ThumbnailComponent { return { type: ComponentTypes.THUMBNAIL, - media: props.children, + media: children, ...props }; } diff --git a/components-jsx/br.tsx b/components-jsx/br.tsx new file mode 100644 index 0000000..2ae4f7c --- /dev/null +++ b/components-jsx/br.tsx @@ -0,0 +1,9 @@ +import { TextDisplay } from "./TextDisplay"; + +export function br() { + return ( + <> + {"\n"} + + ); +} diff --git a/components-jsx/index.ts b/components-jsx/index.ts index 5d3941e..0a72757 100644 --- a/components-jsx/index.ts +++ b/components-jsx/index.ts @@ -1,7 +1,9 @@ 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 ba1246f..5b998b5 100644 --- a/components-jsx/runtime.ts +++ b/components-jsx/runtime.ts @@ -1,6 +1,8 @@ export const Fragment = Symbol("ComponentsJsx.Fragment"); -export function createElement(type: typeof Fragment | ((props: any) => any), props: any, ...children: any[]) { +type FunctionComponent = (props: any) => any; + +export function createElement(type: typeof Fragment | FunctionComponent, props: any, ...children: any[]) { if (type === Fragment) { return children; } diff --git a/components-jsx/utils.ts b/components-jsx/utils.ts index cb203af..0df7aca 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("\n"); + return filterChildren(children).join(""); } if (typeof children === "string") { return children; diff --git a/src/components/User.tsx b/src/components/User.tsx new file mode 100644 index 0000000..5fbbe04 --- /dev/null +++ b/src/components/User.tsx @@ -0,0 +1,24 @@ +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 deleted file mode 100644 index 5fe62c9..0000000 --- a/src/cv2.ts +++ /dev/null @@ -1,68 +0,0 @@ -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/joinRequestHandler.ts b/src/joinRequestHandler.tsx similarity index 65% rename from src/joinRequestHandler.ts rename to src/joinRequestHandler.tsx index caa6c8f..91bb1a4 100644 --- a/src/joinRequestHandler.ts +++ b/src/joinRequestHandler.tsx @@ -1,9 +1,19 @@ 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) => { @@ -18,9 +28,9 @@ export async function setupJoinRequestHandler(shard: Shard) { const pendingMsg = await client.rest.channels.createMessage( Constants.PENDING_CHANNEL_ID, - { - content: "Placeholder" - } + + Placeholder + ); await db.run( "INSERT INTO applications (id, user_id, status, message_id, channel_id) VALUES (?, ?, 0, ?, ?)", @@ -52,34 +62,24 @@ export async function setupJoinRequestHandler(shard: Shard) { } await client.rest.channels.createMessage( Constants.REJECTION_CHANNEL_ID, - { - 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" - } - ] - } - ] - } + + + + ## Join request withdrawn + + + + + ### Application + {application ? ( + User has applied + ) : ( + + User hasn't applied + + )} + + ); break; } From fbd561b8e7ec756a5ac0a909fa5f56c447fb8052 Mon Sep 17 00:00:00 2001 From: nin0 Date: Fri, 16 May 2025 06:20:36 -0400 Subject: [PATCH 4/4] use esbuild for watch --- build.mjs | 14 +- package.json | 8 +- pnpm-lock.yaml | 366 ------------------------------------------------- src/index.ts | 10 +- tsconfig.json | 2 + 5 files changed, 24 insertions(+), 376 deletions(-) diff --git a/build.mjs b/build.mjs index 00be16c..a200bf2 100644 --- a/build.mjs +++ b/build.mjs @@ -1,4 +1,5 @@ import { build } from "esbuild"; +import { spawn } from "child_process"; /** * @type {esbuild.Plugin} @@ -6,7 +7,7 @@ import { build } from "esbuild"; const makeAllPackagesExternalPlugin = { name: "make-all-packages-external", setup(build) { - const filter = /^[^./|~]|^\.[^./]|^\.\.[^/]/; // Must not start with "/" or "./" or "../" + const filter = /(oceanic\.js|sqlite3)/; // Whitelist of dumb packages build.onResolve({ filter }, (args) => ({ path: args.path, external: true @@ -22,10 +23,19 @@ await build({ target: "esnext", logLevel: "info", outfile: "dist/index.js", - minify: true, + minify: false, 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/package.json b/package.json index ceec6a5..26284a2 100644 --- a/package.json +++ b/package.json @@ -3,19 +3,17 @@ "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", - "tsx": "^4.19.3" + "@types/node": "^22.15.2" }, "scripts": { - "dev": "tsx --watch --inspect --env-file-if-exists=.env src/index.ts", + "dev": "pnpm exec tsx --watch-path=src --watch build.mjs start", "build": "node build.mjs", - "start": "node build.mjs && node dist/index.js" + "start": "node build.mjs && node --env-file=.env dist/index.js" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8a82ddd..69b00dd 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,9 +11,6 @@ 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 @@ -30,9 +27,6 @@ importers: '@types/node': specifier: ^22.15.2 version: 22.15.17 - tsx: - specifier: ^4.19.3 - version: 4.19.4 packages: @@ -190,24 +184,6 @@ 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==} @@ -232,9 +208,6 @@ 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'} @@ -247,17 +220,6 @@ 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'} @@ -270,13 +232,6 @@ 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==} @@ -320,10 +275,6 @@ 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'} @@ -344,10 +295,6 @@ 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'} @@ -380,38 +327,9 @@ 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==} @@ -422,19 +340,11 @@ 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==} @@ -494,10 +404,6 @@ 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'} @@ -511,15 +417,6 @@ 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'} @@ -614,10 +511,6 @@ 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==} @@ -629,16 +522,6 @@ 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'} @@ -661,12 +544,6 @@ 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: @@ -682,9 +559,6 @@ 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 @@ -693,32 +567,10 @@ 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 @@ -727,19 +579,9 @@ 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'} @@ -748,9 +590,6 @@ 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==} @@ -772,13 +611,6 @@ 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==} @@ -818,21 +650,9 @@ 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==} @@ -972,29 +792,6 @@ 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 @@ -1025,8 +822,6 @@ snapshots: abbrev@1.1.1: optional: true - abstract-logging@2.0.1: {} - agent-base@6.0.2: dependencies: debug: 4.4.0 @@ -1045,17 +840,6 @@ 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 @@ -1068,13 +852,6 @@ 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 @@ -1141,8 +918,6 @@ snapshots: console-control-strings@1.1.0: optional: true - cookie@1.0.2: {} - debug@4.4.0: dependencies: ms: 2.1.3 @@ -1157,8 +932,6 @@ snapshots: delegates@1.0.0: optional: true - dequal@2.0.3: {} - detect-libc@2.0.4: {} discord-api-types@0.37.120: @@ -1212,57 +985,8 @@ 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: @@ -1272,9 +996,6 @@ snapshots: fs.realpath@1.0.0: optional: true - fsevents@2.3.3: - optional: true - gauge@4.0.4: dependencies: aproba: 2.0.0 @@ -1287,10 +1008,6 @@ 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: @@ -1366,8 +1083,6 @@ snapshots: sprintf-js: 1.1.3 optional: true - ipaddr.js@2.2.0: {} - is-fullwidth-code-point@3.0.0: optional: true @@ -1380,18 +1095,6 @@ 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 @@ -1531,8 +1234,6 @@ snapshots: - opusscript - utf-8-validate - on-exit-leak-free@2.1.2: {} - once@1.4.0: dependencies: wrappy: 1.0.2 @@ -1545,26 +1246,6 @@ 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 @@ -1583,10 +1264,6 @@ 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 @@ -1601,8 +1278,6 @@ 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 @@ -1616,21 +1291,9 @@ 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 @@ -1638,24 +1301,14 @@ 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 @@ -1685,12 +1338,6 @@ 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 @@ -1755,21 +1402,8 @@ 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/index.ts b/src/index.ts index 63ae32d..415891f 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 = await selfappReq("/users/@me", "GET"); + const selfappInfo: any = await selfappReq("/users/@me", "GET"); if (!selfappInfo.username) console.error("Can't use selfapp"); else console.log("Can use selfapp"); @@ -27,5 +27,9 @@ process.on("uncaughtException", (e) => { console.error(e); }); -openDb(); -client.connect(); +export function start() { + openDb(); + client.connect(); +} + +start(); diff --git a/tsconfig.json b/tsconfig.json index f98be7c..75e416f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -21,6 +21,8 @@ "skipLibCheck": true, "resolveJsonModule": true, "jsx": "preserve", + "jsxFactory": "createElement", + "jsxFragmentFactory": "Fragment", "allowJs": true, "outDir": "whofuckingcaresdude" },