From 477d57d74cb760bfa925bfcb81939b3730da71e1 Mon Sep 17 00:00:00 2001 From: ZomoXYZ Date: Tue, 29 Mar 2022 23:26:01 -0500 Subject: [PATCH] test --- discord/lib/{discord/src => }/index.d.ts | 0 discord/lib/{discord/src => }/index.js | 0 discord/lib/src/types.d.ts | 87 ------------------------ discord/lib/src/types.js | 2 - discord/lib/src/util.d.ts | 22 ------ discord/lib/src/util.js | 74 -------------------- discord/lib/{discord/src => }/types.d.ts | 0 discord/lib/{discord/src => }/types.js | 0 discord/lib/{discord/src => }/util.d.ts | 0 discord/lib/{discord/src => }/util.js | 0 10 files changed, 185 deletions(-) rename discord/lib/{discord/src => }/index.d.ts (100%) rename discord/lib/{discord/src => }/index.js (100%) delete mode 100644 discord/lib/src/types.d.ts delete mode 100644 discord/lib/src/types.js delete mode 100644 discord/lib/src/util.d.ts delete mode 100644 discord/lib/src/util.js rename discord/lib/{discord/src => }/types.d.ts (100%) rename discord/lib/{discord/src => }/types.js (100%) rename discord/lib/{discord/src => }/util.d.ts (100%) rename discord/lib/{discord/src => }/util.js (100%) diff --git a/discord/lib/discord/src/index.d.ts b/discord/lib/index.d.ts similarity index 100% rename from discord/lib/discord/src/index.d.ts rename to discord/lib/index.d.ts diff --git a/discord/lib/discord/src/index.js b/discord/lib/index.js similarity index 100% rename from discord/lib/discord/src/index.js rename to discord/lib/index.js diff --git a/discord/lib/src/types.d.ts b/discord/lib/src/types.d.ts deleted file mode 100644 index e63e379..0000000 --- a/discord/lib/src/types.d.ts +++ /dev/null @@ -1,87 +0,0 @@ -/** - * any indexable object - */ -export declare type basicObject = { - [keys: string]: any; -}; -/** - * any indexable object with string values - */ -export declare type basicObjectStringable = { - [keys: string]: string | number | boolean | null; -}; -export declare type basicObjectString = { - [keys: string]: string; -}; -/** - * an abstract version of strings - */ -export declare type bigStringType = string | string[]; -/** - * a representation of an author in the LANG object - * - * `LANG > Language > Embed > Field` - */ -export interface embedField { - name: string; - value: bigStringType; - inline?: boolean; -} -/** - * a representation of an author in the LANG object - * - * `LANG > Language > Embed > Author` - */ -export interface authorData { - name: string; - url?: string; - iconURL?: string; -} -/** - * a representation of a footer in the LANG object - * - * `LANG > Language > Embed > Footer` - */ -export interface footerData { - text: string; - iconURL?: string; -} -/** - * a representation of an embed in the LANG object - * - * `LANG > Language > Embed` - */ -export interface embedObject { - embed: true; - content?: string; - title?: string; - description?: bigStringType; - /** - * URL - */ - url?: string; - /** - * #FFFFFF - */ - color?: string; - footer?: string | footerData; - thumbnail?: string; - /** - * URL - */ - image?: string; - /** - * URL - */ - author?: string | authorData; - fields?: embedField[]; - timestamp?: boolean | string | number; -} -/** - * a specific language in the LANG object - * - * `LANG > Language` - */ -export declare type LangObj = { - [keys: string]: LangObj | embedObject | string; -}; diff --git a/discord/lib/src/types.js b/discord/lib/src/types.js deleted file mode 100644 index c8ad2e5..0000000 --- a/discord/lib/src/types.js +++ /dev/null @@ -1,2 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); diff --git a/discord/lib/src/util.d.ts b/discord/lib/src/util.d.ts deleted file mode 100644 index afa0e99..0000000 --- a/discord/lib/src/util.d.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { basicObject, basicObjectString, basicObjectStringable, bigStringType, embedObject } from './types'; -/** - * - * @param str - * @param args - * @returns - */ -export declare function template(str: string, args: basicObject): string; -/** - * converts bigString to string - */ -export declare function bigString(bigStr: bigStringType): string; -/** - * converts Hex Color string to an RGB array - */ -export declare function resolveColor(color: string): [number, number, number]; -/** - * converts embedObj to a string if applicable - * @param fallback the string to use if no valid strings can be found - */ -export declare function embedObjStr(embedObj: embedObject, args?: basicObjectString, fallback?: string): string; -export declare function convertBasicObject(obj: basicObjectStringable): basicObjectString; diff --git a/discord/lib/src/util.js b/discord/lib/src/util.js deleted file mode 100644 index 276e74e..0000000 --- a/discord/lib/src/util.js +++ /dev/null @@ -1,74 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.convertBasicObject = exports.embedObjStr = exports.resolveColor = exports.bigString = exports.template = void 0; -/** - * - * @param str - * @param args - * @returns - */ -function template(str, args) { - return str.replace(/{\w+}/g, str => { - const key = str.substring(1, str.length - 1); - if (key in args) - return args[key]; - return key; - }); -} -exports.template = template; -/** - * converts bigString to string - */ -function bigString(bigStr) { - if (Array.isArray(bigStr)) - return bigStr.join('\n'); - return bigStr; -} -exports.bigString = bigString; -/** - * converts Hex Color string to an RGB array - */ -function resolveColor(color) { - color = color.replace(/[^0-9a-f]/gi, ''); - const colorNum = [0, 0, 0]; - if (color.length === 3 || color.length === 6) { - const colorSplRaw = /([0-9a-f]{1,2})([0-9a-f]{1,2})([0-9a-f]{1,2})/.exec(color); - if (!colorSplRaw) - return colorNum; - const colorSpl = colorSplRaw.slice(1, 4); - if (color.length === 3) - colorSpl.map(c => c + c); - for (let i = 0; i < colorSpl.length && i < colorNum.length; i++) - colorNum[i] = parseInt(colorSpl[i], 16); - } - return colorNum; -} -exports.resolveColor = resolveColor; -/** - * converts embedObj to a string if applicable - * @param fallback the string to use if no valid strings can be found - */ -function embedObjStr(embedObj, args = {}, fallback = '') { - if (embedObj.content !== undefined) - return template(bigString(embedObj.content), args); - if (embedObj.description !== undefined) - return template(bigString(embedObj.description), args); - return fallback; -} -exports.embedObjStr = embedObjStr; -function convertBasicObject(obj) { - let ret = {}; - for (const key in obj) { - const val = obj[key]; - if (typeof val === 'string') - ret[key] = val; - else if (typeof val === 'boolean') - ret[key] = val.toString(); - else if (typeof val === 'number') - ret[key] = val.toString(); - else - ret[key] = ''; - } - return ret; -} -exports.convertBasicObject = convertBasicObject; diff --git a/discord/lib/discord/src/types.d.ts b/discord/lib/types.d.ts similarity index 100% rename from discord/lib/discord/src/types.d.ts rename to discord/lib/types.d.ts diff --git a/discord/lib/discord/src/types.js b/discord/lib/types.js similarity index 100% rename from discord/lib/discord/src/types.js rename to discord/lib/types.js diff --git a/discord/lib/discord/src/util.d.ts b/discord/lib/util.d.ts similarity index 100% rename from discord/lib/discord/src/util.d.ts rename to discord/lib/util.d.ts diff --git a/discord/lib/discord/src/util.js b/discord/lib/util.js similarity index 100% rename from discord/lib/discord/src/util.js rename to discord/lib/util.js