From 988d7fa6d2f07fadd05d1fc5a42c26d4767b0b44 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:37:40 +0300 Subject: [PATCH 001/128] style: Formatted 17 files & changes messageHelper util --- .prettierrc | 2 +- package-lock.json | 69 +- package.json | 4 +- src/handler/events/interactionCreate.ts | 9 +- src/handler/events/messageEvent.ts | 68 +- src/handler/events/observableHandling.ts | 80 +- src/handler/events/readyEvent.ts | 91 +- src/handler/logger.ts | 54 +- src/handler/sern.ts | 50 +- src/handler/structures/context.ts | 207 ++- src/handler/structures/errors.ts | 10 +- .../structures/modules/commands/module.ts | 62 +- .../modules/commands/moduleHandler.ts | 37 +- src/handler/structures/modules/module.ts | 16 +- src/handler/structures/structxports.ts | 9 +- src/handler/structures/wrapper.ts | 21 +- src/handler/utilities/markup.ts | 1472 +++++++++-------- src/handler/utilities/messageHelpers.ts | 34 +- src/handler/utilities/readFile.ts | 16 +- tests/functions.test.ts | 22 +- 20 files changed, 1220 insertions(+), 1113 deletions(-) diff --git a/.prettierrc b/.prettierrc index 2f316681..0c670739 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,5 @@ "trailingComma": "all", "singleQuote": true, "printWidth": 120, - "tabWidth": 4 + "tabWidth": 2 } diff --git a/package-lock.json b/package-lock.json index 4c10a54c..fe6d367b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "cz-conventional-changelog": "^3.0.1", "jest": "^27.5.1", "standard-version": "^9.3.2", - "typedoc": "^0.22.11", + "typedoc": "^0.22.14", "typescript": "^4.5.5" } }, @@ -8494,16 +8494,16 @@ } }, "node_modules/typedoc": { - "version": "0.22.11", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", - "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", + "version": "0.22.14", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", + "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", "dev": true, "dependencies": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.10", - "minimatch": "^3.0.4", - "shiki": "^0.10.0" + "marked": "^4.0.12", + "minimatch": "^5.0.1", + "shiki": "^0.10.1" }, "bin": { "typedoc": "bin/typedoc" @@ -8512,7 +8512,28 @@ "node": ">= 12.10.0" }, "peerDependencies": { - "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x" + "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x" + } + }, + "node_modules/typedoc/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typedoc/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" } }, "node_modules/typescript": { @@ -15296,16 +15317,36 @@ } }, "typedoc": { - "version": "0.22.11", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", - "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", + "version": "0.22.14", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", + "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", "dev": true, "requires": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.10", - "minimatch": "^3.0.4", - "shiki": "^0.10.0" + "marked": "^4.0.12", + "minimatch": "^5.0.1", + "shiki": "^0.10.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "typescript": { diff --git a/package.json b/package.json index ba3c0028..fb2f5b0e 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "description": "", "main": "dist/index.js", - "scripts": { + "scripts": { "compile": "tsc", "watch": "tsc -w", "lint": "eslint src/**/*.ts", @@ -34,7 +34,7 @@ "cz-conventional-changelog": "^3.0.1", "jest": "^27.5.1", "standard-version": "^9.3.2", - "typedoc": "^0.22.11", + "typedoc": "^0.22.14", "typescript": "^4.5.5" }, "config": { diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index e44152cc..e463ce79 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,10 +1,11 @@ - import type { Interaction } from 'discord.js'; -import { fromEvent, Observable, of, concatMap } from 'rxjs'; -import { CommandType } from '../sern'; -import Context from '../structures/context'; import type Wrapper from '../structures/wrapper'; + import * as Files from '../utilities/readFile'; +import Context from '../structures/context'; + +import { fromEvent, Observable, of, concatMap } from 'rxjs'; +import { CommandType } from '../sern'; import { filterTap } from './observableHandling'; import { filter } from 'rxjs'; diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index d2ee6b6c..925b3f44 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -1,39 +1,43 @@ -import type { ChatInputCommandInteraction, Message } from 'discord.js'; -import { fromEvent, Observable, of, concatMap } from 'rxjs'; -import { CommandType } from '../sern'; -import Context from '../structures/context'; +import type { Message } from 'discord.js'; import type Wrapper from '../structures/wrapper'; -import { fmt } from '../utilities/messageHelpers'; + +import { fromEvent, Observable, of, concatMap } from 'rxjs'; + +import Context from '../structures/context'; import * as Files from '../utilities/readFile'; + +import { fmt } from '../utilities/messageHelpers'; +import { CommandType } from '../sern'; import { filterTap, ignoreNonBot } from './observableHandling'; -export const onMessageCreate = (wrapper : Wrapper) => { - const { client, defaultPrefix } = wrapper; - (> fromEvent( client, 'messageCreate')) - .pipe ( - ignoreNonBot(defaultPrefix), - concatMap ( m => { - const [ prefix, ...data ] = fmt(m, defaultPrefix); +export const onMessageCreate = (wrapper: Wrapper) => { + const { client, defaultPrefix } = wrapper; + + (>fromEvent(client, 'messageCreate')) + .pipe( + ignoreNonBot(defaultPrefix), + concatMap(m => { + const [prefix, ...data] = fmt({ msg: m, prefix: defaultPrefix }); const posMod = Files.Commands.get(prefix) ?? Files.Alias.get(prefix); - return of( posMod ) - .pipe ( - filterTap(CommandType.TEXT, mod => { - const ctx = Context.wrap(m); - mod.execute(ctx, ['text', data]); - }) - ); - }) - ).subscribe ({ - error(e) { - //log things - throw e; - }, - next(command) { - //log on each command emitted - console.log(command); - }, - }); - - + return of(posMod) + .pipe( + filterTap(CommandType.TEXT, mod => { + const ctx = Context.wrap(m); + mod.execute(ctx, ['text', data]); + }) + ); + }) + ).subscribe({ + error(e) { + // Log the errors + + throw e; + }, + next(command) { + // Log on each command emitted + + console.log(command); + }, + }); }; diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index d5892b8d..93d33811 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -1,63 +1,65 @@ import type { Awaitable, Message } from 'discord.js'; + import type { CommandType } from '../sern'; import type { Module } from '../structures/structxports'; -import { Observable, throwError } from 'rxjs'; import type { ModuleDefs } from '../structures/modules/commands/moduleHandler'; + +import { Observable, throwError } from 'rxjs'; import { SernError } from '../structures/errors'; -import { isNotFromBot, isNotFromDM } from '../utilities/messageHelpers'; +import { isFromBot, isFromDM } from '../utilities/messageHelpers'; -export function match(mod: Module | undefined, type : CommandType) : boolean { +export function match(mod: Module | undefined, type: CommandType): boolean { return mod !== undefined && (mod.type & type) != 0; } export function filterTap( - cmdType : T, - tap: (mod : ModuleDefs[T]) => Awaitable + cmdType: T, + tap: (mod: ModuleDefs[T]) => Awaitable ) { - return (src : Observable) => - new Observable( subscriber => { - return src.subscribe({ + return (src: Observable) => + new Observable(subscriber => { + return src.subscribe({ next(modul) { - if(match(modul, cmdType)) { - const asModT = modul; - tap(asModT); - subscriber.next(asModT); + if (match(modul, cmdType)) { + const asModT = modul; + tap(asModT); + subscriber.next(asModT); } else { - if (modul === undefined) { - return throwError(() => SernError.UNDEFINED_MODULE); - } - return throwError(() => SernError.MISMATCH_MODULE_TYPE); + if (modul === undefined) { + return throwError(() => SernError.UNDEFINED_MODULE); + } + return throwError(() => SernError.MISMATCH_MODULE_TYPE); } }, - error: (e) => subscriber.error(e), + error: (e) => subscriber.error(e), complete: () => subscriber.complete() }); }); - } +} -export function ignoreNonBot(prefix : string) { - return (src : Observable) => +export function ignoreNonBot(prefix: string) { + return (src: Observable) => new Observable(subscriber => { - return src.subscribe({ - next(m) { - const passAll = [ - isNotFromDM, - isNotFromBot, - (m : Message) => - m.content - .slice(0,prefix.length) - .localeCompare(prefix, - undefined, { sensitivity : 'accent' } - ) === 0 - ].every( fn => fn(m)); + return src.subscribe({ + next(m) { + const passAll = [ + !isFromDM, + !isFromBot, + (m: Message) => + m.content + .slice(0, prefix.length) + .localeCompare(prefix, + undefined, { sensitivity: 'accent' } + ) === 0 + ].every(fn => fn(m)); - if (passAll) { - subscriber.next(m); - } - }, - error: (e) => subscriber.error(e), - complete: () => subscriber.complete() + if (passAll) { + subscriber.next(m); + } + }, + error: (e) => subscriber.error(e), + complete: () => subscriber.complete() }); - }); + }); } diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index b389f944..2593cbec 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -1,61 +1,62 @@ -import { first, from, fromEvent } from 'rxjs'; -import { basename } from 'path'; -import * as Files from '../utilities/readFile'; import type Wrapper from '../structures/wrapper'; import type { Module } from '../structures/structxports'; import type { HandlerCallback, ModuleHandlers, ModuleStates, ModuleType } from '../structures/modules/commands/moduleHandler'; + +import * as Files from '../utilities/readFile'; +import { first, from, fromEvent } from 'rxjs'; +import { basename } from 'path'; import { CommandType } from '../sern'; -export const onReady = ( wrapper : Wrapper ) => { +export const onReady = (wrapper: Wrapper) => { const { client, init, commands } = wrapper; fromEvent(client, 'ready') - .pipe(first()) - .subscribe(() => { - init?.( wrapper ); - Files.buildData( commands ) - .then( createCommandCache ); - }) + .pipe(first()) + .subscribe(() => { + init?.(wrapper); + Files.buildData(commands) + .then(createCommandCache); + }) }; // Refactor : ? Possibly repetitive and verbose. -const handler = ( name : string ) => - ({ - [CommandType.TEXT] : mod => { - mod.alias.forEach ( a => Files.Alias.set(a,mod)); - Files.Commands.set( name, mod ); - }, - [CommandType.SLASH]: mod => { - Files.Commands.set( name , mod); - }, - [CommandType.BOTH] : mod => { - Files.Commands.set ( name, mod); - mod.alias.forEach (a => Files.Alias.set(a, mod)); - }, - [CommandType.MENU_USER] : mod => { - Files.ContextMenuUser.set ( name, mod ); - }, - [CommandType.MENU_MSG] : mod => { - Files.ContextMenuMsg.set (name, mod ); - }, - [CommandType.BUTTON] : mod => { - Files.Buttons.set(name, mod); - }, - [CommandType.MENU_SELECT] : mod => { - Files.SelectMenus.set(name, mod); - } +const handler = (name: string) => +({ + [CommandType.TEXT]: mod => { + mod.alias.forEach(a => Files.Alias.set(a, mod)); + Files.Commands.set(name, mod); + }, + [CommandType.SLASH]: mod => { + Files.Commands.set(name, mod); + }, + [CommandType.BOTH]: mod => { + Files.Commands.set(name, mod); + mod.alias.forEach(a => Files.Alias.set(a, mod)); + }, + [CommandType.MENU_USER]: mod => { + Files.ContextMenuUser.set(name, mod); + }, + [CommandType.MENU_MSG]: mod => { + Files.ContextMenuMsg.set(name, mod); + }, + [CommandType.BUTTON]: mod => { + Files.Buttons.set(name, mod); + }, + [CommandType.MENU_SELECT]: mod => { + Files.SelectMenus.set(name, mod); + } - } as ModuleHandlers); +} as ModuleHandlers); -const registerModules = (name : string, mod : ModuleStates[T]) => - (> handler(name)[mod.type])(mod); +const registerModules = (name: string, mod: ModuleStates[T]) => + (>handler(name)[mod.type])(mod); -function setCommands ( { mod, absPath } : { mod : Module, absPath : string } ) { - const name = mod.name ?? Files.fmtFileName(basename(absPath)); - registerModules(name, mod); +function setCommands({ mod, absPath }: { mod: Module, absPath: string }) { + const name = mod.name ?? Files.fmtFileName(basename(absPath)); + registerModules(name, mod); } -function createCommandCache( - arr: {mod: Module, absPath: string}[] - ) { - from(arr).subscribe ( setCommands ); +function createCommandCache( + arr: { mod: Module, absPath: string }[] +) { + from(arr).subscribe(setCommands); } diff --git a/src/handler/logger.ts b/src/handler/logger.ts index aff768d1..25901d71 100644 --- a/src/handler/logger.ts +++ b/src/handler/logger.ts @@ -1,34 +1,34 @@ - export enum sEvent { - GLOBAL_SLASH, - LOCAL_SLASH, - MISUSE_CMD, - DM, - CRASH, - TEXT_CMD, + GLOBAL_SLASH, + LOCAL_SLASH, + MISUSE_CMD, + CRASH, + TEXT_CMD, + DM, } export default class Logger { - public clear() { - console.clear(); - } + public clear() { + console.clear(); + } - public log(e: T, guildId: string, message: string) { - // add colored logging? - console.log(`[${new Date().toISOString()}] [${sEvent[e]}] @ ${guildId} :: ${message}`); - } + public log(e: T, guildId: string, message: string) { + // TODO: Add colored logging + console.log(`[${new Date().toISOString()}] [${sEvent[e]}] @ ${guildId} :: ${message}`); + } - /** - * Utilizes console.table() to print out memory usage of current process. - * Optional at startup. - */ - public tableRam() { - console.table( - Object.entries(process.memoryUsage()) - .map(([k, v]: [string, number]) => { - return { [k]: `${(((Math.round(v) / 1024 / 1024) * 100) / 100).toFixed(2)} MBs` }; - }) - .reduce((r, c) => Object.assign(r, c), {}), - ); - } + /** + * Utilizes console.table() to print out memory usage of current process. + * Optional at startup. + */ + + public tableRam() { + console.table( + Object.entries(process.memoryUsage()) + .map(([k, v]: [string, number]) => { + return { [k]: `${(((Math.round(v) / 1024 / 1024) * 100) / 100).toFixed(2)} MBs` }; + }) + .reduce((r, c) => Object.assign(r, c), {}), + ); + } } diff --git a/src/handler/sern.ts b/src/handler/sern.ts index c9ed8ad7..1d7e560d 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -1,45 +1,41 @@ -import type { - DiscordEvent, -} from '../types/handler'; - -import type { - Client, -} from 'discord.js'; - +import type { DiscordEvent, } from '../types/handler'; +import type { Client } from 'discord.js'; import type Wrapper from './structures/wrapper'; + import { fromEvent } from 'rxjs'; import { SernError } from './structures/errors'; import { onReady } from './events/readyEvent'; import { onMessageCreate } from './events/messageEvent'; import { onInteractionCreate } from './events/interactionCreate'; -export function init( wrapper : Wrapper ) { - const { events, client } = wrapper; - if (events !== undefined) eventObserver(client, events); - onReady( wrapper ); - onMessageCreate( wrapper ); - onInteractionCreate ( wrapper ); +export function init(wrapper: Wrapper) { + const { events, client } = wrapper; + if (events !== undefined) eventObserver(client, events); + + onReady(wrapper); + onMessageCreate(wrapper); + onInteractionCreate(wrapper); } -function eventObserver(client: Client, events: DiscordEvent[] ) { - events.forEach( ( [event, cb] ) => { - if (event === 'ready') throw Error(SernError.RESERVED_EVENT); - fromEvent(client, event, cb).subscribe(); +function eventObserver(client: Client, events: DiscordEvent[]) { + events.forEach(([event, cb]) => { + if (event === 'ready') throw Error(SernError.RESERVED_EVENT); + fromEvent(client, event, cb).subscribe(); }); } - /** * @enum { number }; */ + export enum CommandType { - TEXT = 0b000001, - SLASH = 0b000010, - MENU_USER = 0b000100, - MENU_MSG = 0b001000, - BUTTON = 0b010000, - MENU_SELECT= 0b100000, - BOTH = 0b000011, - ANY = 0b111111 + TEXT = 0b000001, + SLASH = 0b000010, + MENU_USER = 0b000100, + MENU_MSG = 0b001000, + BUTTON = 0b010000, + MENU_SELECT = 0b100000, + BOTH = 0b000011, + ANY = 0b111111, } diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index b95ae3ee..fdbe7057 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -1,121 +1,108 @@ import type { - Awaitable, - ChatInputCommandInteraction, - Guild, - GuildMember, - Message, - Snowflake, - TextBasedChannel, - User + Awaitable, + ChatInputCommandInteraction, + Guild, + GuildMember, + Message, + Snowflake, + TextBasedChannel, + User, } from 'discord.js'; import { None, Option, Some } from 'ts-results'; import type { Nullish } from '../../types/handler'; -function firstSome(...args : Option[]) : Nullish { - for ( const op of args ) { - if (op.some) return op.val; - } - return null; + +function firstSome(...args: Option[]): Nullish { + for (const op of args) { + if (op.some) return op.val; + } + return null; } -export default class Context { - private constructor( - private oMsg: Option = None, - private oInterac: Option = None - ) { - this.oMsg = oMsg; - this.oInterac = oInterac; - } - static wrap( - wrappable: ChatInputCommandInteraction|Message - ) : Context { - if ( 'token' in wrappable ) { - return new Context( None, Some(wrappable)); - } - return new Context(Some(wrappable), None); - } - public isEmpty() { - return this.oMsg.none && this.oInterac.none; - } - public get message() { - return this.oMsg.unwrap(); - } - public get interaction() { - return this.oInterac.unwrap(); +export default class Context { + private constructor( + private oMsg: Option = None, + private oInterac: Option = None, + ) { + this.oMsg = oMsg; + this.oInterac = oInterac; + } + static wrap(wrappable: ChatInputCommandInteraction | Message): Context { + if ('token' in wrappable) { + return new Context(None, Some(wrappable)); } + return new Context(Some(wrappable), None); + } + public isEmpty() { + return this.oMsg.none && this.oInterac.none; + } + public get message() { + return this.oMsg.unwrap(); + } + public get interaction() { + return this.oInterac.unwrap(); + } - public get id() : Snowflake { - return firstSome( - this.oInterac.map( i => i.id), - this.oMsg.map(m => m.id) - )!; - } - public get channel() : Nullish { - return firstSome( - this.oMsg.map(m => m.channel), - this.oInterac.map(i => i.channel) - ); - } - public get user(): User { - return firstSome( - this.oMsg.map(m => m.author), - this.oInterac.map(i => i.user) - )!; - } - public get createdTimestamp() : number { - return firstSome( - this.oMsg.map(m => m.createdTimestamp), - this.oInterac.map(i => i.createdTimestamp) - )!; - } + public get id(): Snowflake { + return firstSome( + this.oInterac.map((i) => i.id), + this.oMsg.map((m) => m.id), + )!; + } + public get channel(): Nullish { + return firstSome( + this.oMsg.map((m) => m.channel), + this.oInterac.map((i) => i.channel), + ); + } + public get user(): User { + return firstSome( + this.oMsg.map((m) => m.author), + this.oInterac.map((i) => i.user), + )!; + } + public get createdTimestamp(): number { + return firstSome( + this.oMsg.map((m) => m.createdTimestamp), + this.oInterac.map((i) => i.createdTimestamp), + )!; + } - public get guild() : Guild { - return firstSome( - this.oMsg.map(m => m.guild!), - this.oInterac.map(i => i.guild) - )!; - } - public get guildId() : Snowflake { - return firstSome( - this.oMsg.map(m => m.guildId), - this.oInterac.map(i => i.guildId) - )!; - } - public get member() : Nullish { - return firstSome( - this.oMsg.andThen(m => Some(m.member!)), - this.oInterac.andThen(i => i.inCachedGuild() ? Some(i.member) : None) - ); - } - /* - * Returns the underlying Context but allows for doing other operations - */ - public onInteraction( - onInteraction : ( interaction : ChatInputCommandInteraction ) => Awaitable, - ): Context { - this.oInterac.map(onInteraction); - return this; - } - public onMessage( - onMessage : ( message : Message ) => Awaitable - ): Context { - this.oMsg.map( onMessage ); - return this; - } - public takeInteractionValue( - extract : (interaction : ChatInputCommandInteraction) => T - ): Nullish { - if(this.oInterac.none) return null; - return extract(this.oInterac.val); - } - public takeMessageValue( - extract : (message: Message) => T - ): Nullish { - if(this.oMsg.none) return null; - return extract(this.oMsg.val); - } - + public get guild(): Guild { + return firstSome( + this.oMsg.map((m) => m.guild!), + this.oInterac.map((i) => i.guild), + )!; + } + public get guildId(): Snowflake { + return firstSome( + this.oMsg.map((m) => m.guildId), + this.oInterac.map((i) => i.guildId), + )!; + } + public get member(): Nullish { + return firstSome( + this.oMsg.andThen((m) => Some(m.member!)), + this.oInterac.andThen((i) => (i.inCachedGuild() ? Some(i.member) : None)), + ); + } + /* + * Returns the underlying Context but allows for doing other operations + */ + public onInteraction(onInteraction: (interaction: ChatInputCommandInteraction) => Awaitable): Context { + this.oInterac.map(onInteraction); + return this; + } + public onMessage(onMessage: (message: Message) => Awaitable): Context { + this.oMsg.map(onMessage); + return this; + } + public takeInteractionValue(extract: (interaction: ChatInputCommandInteraction) => T): Nullish { + if (this.oInterac.none) return null; + return extract(this.oInterac.val); + } + public takeMessageValue(extract: (message: Message) => T): Nullish { + if (this.oMsg.none) return null; + return extract(this.oMsg.val); + } } - - - diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index c29128ea..3a6c2559 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -1,7 +1,7 @@ export enum SernError { - RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.', - NO_ALIAS = 'You cannot provide an array with elements to a slash command.', - NOT_VALID_MOD_TYPE = 'Detected an unknown module type', - UNDEFINED_MODULE = `A module could not be detected at`, - MISMATCH_MODULE_TYPE = `A module type mismatched with event emitted!` + RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.', + NO_ALIAS = 'You cannot provide an array with elements to a slash command.', + NOT_VALID_MOD_TYPE = 'Detected an unknown module type', + UNDEFINED_MODULE = `A module could not be detected at`, + MISMATCH_MODULE_TYPE = `A module type mismatched with event emitted!`, } diff --git a/src/handler/structures/modules/commands/module.ts b/src/handler/structures/modules/commands/module.ts index 33147845..fe68227b 100644 --- a/src/handler/structures/modules/commands/module.ts +++ b/src/handler/structures/modules/commands/module.ts @@ -1,45 +1,51 @@ -import type { ApplicationCommandOptionData, Awaitable, ButtonInteraction, ContextMenuCommandInteraction, MessageContextMenuCommandInteraction, SelectMenuInteraction } from 'discord.js'; +import type { + ApplicationCommandOptionData, + Awaitable, + ButtonInteraction, + MessageContextMenuInteraction, + ContextMenuInteraction, + SelectMenuInteraction, +} from 'discord.js'; + import type { Override } from '../../../../types/handler'; import type { CommandType } from '../../../sern'; import type { BaseModule } from '../module'; -//possible refactoring to interfaces and not types +// Possible refactoring to interfaces and not types export type TextCommand = { - type : CommandType.TEXT; - alias : string[] | [], + type: CommandType.TEXT; + alias: string[] | []; } & BaseModule; export type SlashCommand = { - type : CommandType.SLASH; - options : ApplicationCommandOptionData[] | [], -} & BaseModule; + type: CommandType.SLASH; + options: ApplicationCommandOptionData[] | []; +} & BaseModule; export type BothCommand = { - type : CommandType.BOTH; - alias : string[] | []; - options : ApplicationCommandOptionData[] | [], + type: CommandType.BOTH; + alias: string[] | []; + options: ApplicationCommandOptionData[] | []; } & BaseModule; export type ContextMenuUser = { - type : CommandType.MENU_USER; -} & Override Awaitable }>; + type: CommandType.MENU_USER; +} & Override Awaitable }>; export type ContextMenuMsg = { - type : CommandType.MENU_MSG; -} & Override Awaitable }>; + type: CommandType.MENU_MSG; +} & Override Awaitable }>; export type ButtonCommand = { - type : CommandType.BUTTON; -} & Override Awaitable }>; + type: CommandType.BUTTON; +} & Override Awaitable }>; export type SelectMenuCommand = { - type : CommandType.MENU_SELECT; -} & Override Awaitable }>; - + type: CommandType.MENU_SELECT; +} & Override Awaitable }>; -export type Module = - TextCommand - | SlashCommand - | BothCommand - | ContextMenuUser - | ContextMenuMsg - | ButtonCommand - | SelectMenuCommand; - +export type Module = + | TextCommand + | SlashCommand + | BothCommand + | ContextMenuUser + | ContextMenuMsg + | ButtonCommand + | SelectMenuCommand; diff --git a/src/handler/structures/modules/commands/moduleHandler.ts b/src/handler/structures/modules/commands/moduleHandler.ts index caf1e018..5814d7c5 100644 --- a/src/handler/structures/modules/commands/moduleHandler.ts +++ b/src/handler/structures/modules/commands/moduleHandler.ts @@ -1,24 +1,31 @@ import { CommandType } from '../../../sern'; -import type { TextCommand, BothCommand, ButtonCommand, SlashCommand, ContextMenuMsg, ContextMenuUser, SelectMenuCommand } from './module'; -//https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union +import type { + TextCommand, + BothCommand, + ButtonCommand, + SlashCommand, + ContextMenuMsg, + ContextMenuUser, + SelectMenuCommand, +} from './module'; +// https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union // Explicit Module Definitions for mapping export type ModuleDefs = { - [CommandType.TEXT] : TextCommand, - [CommandType.SLASH] : SlashCommand, - [CommandType.BOTH] : BothCommand, - [CommandType.MENU_MSG] : ContextMenuMsg, - [CommandType.MENU_USER] : ContextMenuUser, - [CommandType.BUTTON] : ButtonCommand, - [CommandType.MENU_SELECT] : SelectMenuCommand -} + [CommandType.TEXT]: TextCommand; + [CommandType.SLASH]: SlashCommand; + [CommandType.BOTH]: BothCommand; + [CommandType.MENU_MSG]: ContextMenuMsg; + [CommandType.MENU_USER]: ContextMenuUser; + [CommandType.BUTTON]: ButtonCommand; + [CommandType.MENU_SELECT]: SelectMenuCommand; +}; //Keys of ModuleDefs export type ModuleType = keyof ModuleDefs; // The keys mapped to a constructed union with its type -export type ModuleStates = { [ K in ModuleType ] : { type : K } & ModuleDefs[K] }; -// A handler callback that is called on each ModuleDef -export type HandlerCallback = ( params : ModuleStates[K] ) => unknown; +export type ModuleStates = { [K in ModuleType]: { type: K } & ModuleDefs[K] }; +// A handler callback that is called on each ModuleDef +export type HandlerCallback = (params: ModuleStates[K]) => unknown; //An object that acts as the mapped object to handler -export type ModuleHandlers = { [K in ModuleType] : HandlerCallback }; - +export type ModuleHandlers = { [K in ModuleType]: HandlerCallback }; diff --git a/src/handler/structures/modules/module.ts b/src/handler/structures/modules/module.ts index 606ef62e..f127114c 100644 --- a/src/handler/structures/modules/module.ts +++ b/src/handler/structures/modules/module.ts @@ -1,13 +1,9 @@ -import type { Awaitable, ChatInputCommandInteraction, Interaction } from "discord.js"; -import type { Args } from "../../.."; -import type Context from "../context"; +import type { Awaitable, ChatInputCommandInteraction, Interaction } from 'discord.js'; +import type { Args } from '../../..'; +import type Context from '../context'; export interface BaseModule { - name? : string; - description : string; - execute: (ctx: Context, args: Args) => Awaitable; + name?: string; + description: string; + execute: (ctx: Context, args: Args) => Awaitable; } - - - - diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index 1ae69979..46a6f3c4 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -2,11 +2,4 @@ import Context from './context'; import type { SlashCommand, TextCommand, BothCommand, Module } from '../structures/modules/commands/module'; import type Wrapper from './wrapper'; -export { - Context, - SlashCommand, - TextCommand, - BothCommand, - Module, - Wrapper -}; +export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper }; diff --git a/src/handler/structures/wrapper.ts b/src/handler/structures/wrapper.ts index 54168d1e..b0ad93bf 100644 --- a/src/handler/structures/wrapper.ts +++ b/src/handler/structures/wrapper.ts @@ -4,18 +4,19 @@ import type { DiscordEvent } from '../../types/handler'; /** * An object to be passed into Sern.Handler constructor. * @typedef {object} Wrapper - * @property {readonly Client} client - * @property {readonly string} defaultPrefix - * @property {readonly string} commands - * @prop {(handler : Handler) => void)} init - * @prop { readonly DiscordEvent[] } events + * @property {readonly Client} Client + * @property {readonly string} The default prefix + * @property {readonly string} Commands + * @prop {(handler: Handler) => void)} init + * @prop { readonly DiscordEvent[] } Events */ + interface Wrapper { - readonly client: Client; - readonly defaultPrefix: string; - readonly commands: string; - init?: (handler: Wrapper) => void; - readonly events? : DiscordEvent[]; + readonly client: Client; + readonly defaultPrefix: string; + readonly commands: string; + init?: (handler: Wrapper) => void; + readonly events?: DiscordEvent[]; } export default Wrapper; diff --git a/src/handler/utilities/markup.ts b/src/handler/utilities/markup.ts index 4dba8275..89ebe2a9 100644 --- a/src/handler/utilities/markup.ts +++ b/src/handler/utilities/markup.ts @@ -1,730 +1,796 @@ - /** - * An enumeration of all the valid Discord timestamp styles. - */ - export enum TimestampStyles { - BOTH_LONG = 'F', - BOTH_SHORT = 'f', - DATE_LONG = 'D', - DATE_SHORT = 'd', - RELATIVE = 'R', - TIME_LONG = 'T', - TIME_SHORT = 't' - } - /** - * Utility to cut messages by bytes and not characters - */ - export function trueSlice(text: string, limit?: number): string { - if (limit) { - return new TextDecoder().decode( - new TextEncoder().encode(text).slice(0, limit) - ); - } - return text; - } - /** - * Object that holds all the Discord Markup identifiers. - */ - export const Strings = { - BOLD: '**', - CODEBLOCK: '```', - CODESTRING: '`', - CODESTRING_DOUBLE: '``', - ESCAPE: '\\', - ITALICS: '_', - SPOILER: '||', - STRIKE: '~~', - UNDERLINE: '__' - }; - /** - * Object that maps all the Discord Markup identifiers to their respective RegExp matchers. - */ - const Regexes = { - [Strings.BOLD]: /\*\*/g, - [Strings.CODEBLOCK]: new RegExp(Strings.CODEBLOCK, 'g'), - [Strings.CODESTRING]: new RegExp(Strings.CODESTRING, 'g'), - [Strings.ESCAPE]: /\\/g, - [Strings.ITALICS]: /(_|\*)/g, - [Strings.SPOILER]: /\|\|/g, - [Strings.STRIKE]: new RegExp(Strings.STRIKE, 'g'), - [Strings.UNDERLINE]: new RegExp(Strings.UNDERLINE, 'g'), - EVERYONE: /@(everyone|here)/g, - LINK: /\]\(/g, - MENTION: /<@([!&]?[0-9]{16,21})>/g, - MENTION_HARDCORE: /@/g, - URL: /\)/g - }; - /** - * Object to replace Discord Markup identifiers with when escaping strings. - */ - const Replacements = { - [Strings.BOLD]: '\\*\\*', - [Strings.CODEBLOCK]: '``\u200b`', - [Strings.CODESTRING]: '\\`', - [Strings.ESCAPE]: '\\\\', - [Strings.ITALICS]: '\\$1', - [Strings.SPOILER]: '\\|\\|', - [Strings.STRIKE]: '\\~\\~', - [Strings.UNDERLINE]: '\\_\\_', - MENTION: '\u200b' - }; - /** - * Utility to escape some Discord Markup Identifier - */ - function EscapeBasic(raw: string, key: keyof typeof Strings) { - return raw.replace(Regexes[key], Replacements[key]); - } - /** - * Object of all the Escape functions used to apply mixed markup - */ - export const Escape: Record< - keyof typeof Strings, - typeof EscapeBasic - > = (Object.keys(Strings) as Array).reduce( - (p, v) => Object.assign(p, { [v]: (raw: string) => EscapeBasic(raw, v) }), - {} as Record - ); - /** - * String formatting for freezing Discord timestamps that have the Relative (R) flag - */ - const FrozenTimestampStyles: Record = { - [TimestampStyles.BOTH_LONG]: - '{day}, {month} {date}, {year} {hour}:{minute} {meridian}', - [TimestampStyles.BOTH_SHORT]: - '{month} {date}, {year} {hour}:{minute} {meridian}', - [TimestampStyles.DATE_LONG]: '{month} {date}, {year}', - [TimestampStyles.DATE_SHORT]: '{month_short}/{date}/{year}', - [TimestampStyles.RELATIVE]: '{relative}', - [TimestampStyles.TIME_LONG]: '{hour}:{minute}:{second} {meridian}', - [TimestampStyles.TIME_SHORT]: '{hour}:{minute} {meridian}' - }; - /** - * Holds metadata and string conversions of a UNIX Timestamp - */ - interface Timestamp { - raw: number; - month: string; - month_short: string; - date: string; - year: string; - second: string; - meridian: 'AM' | 'PM'; - hour: string; - minute: string; - day: string; - relative: string; - } - /** - * Converter for number to Days of the Week - */ - const Days: Record = { - 0: 'Sunday', - 1: 'Monday', - 2: 'Tuesday', - 3: 'Wednesday', - 4: 'Thursday', - 5: 'Friday', - 6: 'Saturday' - }; - /** - * Converter for number to Months of the Year - */ - const Months: Record = { - 0: 'January', - 1: 'February', - 2: 'March', - 3: 'April', - 4: 'May', - 5: 'June', - 6: 'July', - 7: 'August', - 8: 'September', - 9: 'October', - 10: 'November', - 11: 'December' - }; - /** - * Converts a Date object to a Timestamp object - */ - function formatDate(date: Date): Timestamp { - return { - relative: toTimeString(date.getTime(), TimestampUnits), - raw: date.getTime(), - date: date - .getDate() - .toString() - .padStart(2, '0'), - day: Days[date.getDay()], - hour: date - .getHours() - .toString() - .padStart(2, '0'), - meridian: date.getHours() > 12 ? 'PM' : 'AM', - minute: date - .getMinutes() - .toString() - .padStart(2, '0'), - month: Months[date.getMonth()], - month_short: (date.getMonth() + 1).toString().padStart(2, '0'), - second: date - .getSeconds() - .toString() - .padStart(2, '0'), - year: date.getFullYear().toString() - }; - } - /** - * Collectively multiplies bigints together - */ - function multiplyLarge(...nums: Array): bigint { - return nums.map(BigInt).reduce((p, v) => (p *= v), 1n); - } - /** - * Get the absolute value of a bigint - */ - function bigintAbs(int: bigint) { - if (int < 0) return -int; - return int; - } - /** - * Object of Units matched with their string representations. - */ - const TimestampUnits = { - myriad: multiplyLarge(10, 10, 10, 10, 12, 4, 7, 24, 60, 1000), - millenium: multiplyLarge(10, 10, 10, 12, 4, 7, 24, 60, 1000), - century: multiplyLarge(10, 10, 12, 4, 7, 24, 60, 1000), - decade: multiplyLarge(10, 12, 4, 7, 24, 60, 60, 1000), - year: multiplyLarge(12, 4, 7, 24, 60, 60, 1000), - month: multiplyLarge(4, 7, 24, 60, 60, 1000), - week: multiplyLarge(7, 24, 60, 60, 1000), - day: multiplyLarge(24, 60, 60, 1000), - hour: multiplyLarge(60, 60, 1000), - minute: multiplyLarge(60, 1000), - second: multiplyLarge(1000), - millisecond: multiplyLarge(1) +/** + * An enumeration of all the valid Discord timestamp styles. + */ + +export enum TimestampStyles { + BOTH_LONG = 'F', + BOTH_SHORT = 'f', + DATE_LONG = 'D', + DATE_SHORT = 'd', + RELATIVE = 'R', + TIME_LONG = 'T', + TIME_SHORT = 't' +} + +/** + * Utility to cut messages by bytes and not characters + */ + +export function trueSlice(text: string, limit?: number): string { + if (limit) { + return new TextDecoder().decode( + new TextEncoder().encode(text).slice(0, limit) + ); + } + return text; +} + +/** + * Object that holds all the Discord Markup identifiers. + */ + +export const Strings = { + BOLD: '**', + CODEBLOCK: '```', + CODESTRING: '`', + CODESTRING_DOUBLE: '``', + ESCAPE: '\\', + ITALICS: '_', + SPOILER: '||', + STRIKE: '~~', + UNDERLINE: '__' +}; + +/** + * Object that maps all the Discord Markup identifiers to their respective RegExp matchers. + */ + +const Regexes = { + [Strings.BOLD]: /\*\*/g, + [Strings.CODEBLOCK]: new RegExp(Strings.CODEBLOCK, 'g'), + [Strings.CODESTRING]: new RegExp(Strings.CODESTRING, 'g'), + [Strings.ESCAPE]: /\\/g, + [Strings.ITALICS]: /(_|\*)/g, + [Strings.SPOILER]: /\|\|/g, + [Strings.STRIKE]: new RegExp(Strings.STRIKE, 'g'), + [Strings.UNDERLINE]: new RegExp(Strings.UNDERLINE, 'g'), + + EVERYONE: /@(everyone|here)/g, + LINK: /\]\(/g, + MENTION: /<@([!&]?[0-9]{16,21})>/g, + MENTION_HARDCORE: /@/g, + URL: /\)/g +}; + +/** + * Object to replace Discord Markup identifiers with when escaping strings. + */ + +const Replacements = { + [Strings.BOLD]: '\\*\\*', + [Strings.CODEBLOCK]: '``\u200b`', + [Strings.CODESTRING]: '\\`', + [Strings.ESCAPE]: '\\\\', + [Strings.ITALICS]: '\\$1', + [Strings.SPOILER]: '\\|\\|', + [Strings.STRIKE]: '\\~\\~', + [Strings.UNDERLINE]: '\\_\\_', + MENTION: '\u200b' +}; + +/** + * Utility to escape some Discord Markup Identifier + */ + +function EscapeBasic(raw: string, key: keyof typeof Strings) { + return raw.replace(Regexes[key], Replacements[key]); +} + +/** + * Object of all the Escape functions used to apply mixed markup + */ + +export const Escape: Record< + keyof typeof Strings, + typeof EscapeBasic +> = (Object.keys(Strings) as Array).reduce( + (p, v) => Object.assign(p, { [v]: (raw: string) => EscapeBasic(raw, v) }), + {} as Record +); + +/** + * String formatting for freezing Discord timestamps that have the Relative (R) flag + */ + +const FrozenTimestampStyles: Record = { + [TimestampStyles.BOTH_LONG]: + '{day}, {month} {date}, {year} {hour}:{minute} {meridian}', + [TimestampStyles.BOTH_SHORT]: + '{month} {date}, {year} {hour}:{minute} {meridian}', + [TimestampStyles.DATE_LONG]: '{month} {date}, {year}', + [TimestampStyles.DATE_SHORT]: '{month_short}/{date}/{year}', + [TimestampStyles.RELATIVE]: '{relative}', + [TimestampStyles.TIME_LONG]: '{hour}:{minute}:{second} {meridian}', + [TimestampStyles.TIME_SHORT]: '{hour}:{minute} {meridian}' +}; + +/** + * Holds metadata and string conversions of a UNIX Timestamp + */ + +interface Timestamp { + raw: number; + month: string; + month_short: string; + date: string; + year: string; + second: string; + meridian: 'AM' | 'PM'; + hour: string; + minute: string; + day: string; + relative: string; +} + +/** + * Converter for number to Days of the Week + */ + +const Days: Record = { + 0: 'Sunday', + 1: 'Monday', + 2: 'Tuesday', + 3: 'Wednesday', + 4: 'Thursday', + 5: 'Friday', + 6: 'Saturday' +}; + +/** + * Converter for number to Months of the Year + */ + +const Months: Record = { + 0: 'January', + 1: 'February', + 2: 'March', + 3: 'April', + 4: 'May', + 5: 'June', + 6: 'July', + 7: 'August', + 8: 'September', + 9: 'October', + 10: 'November', + 11: 'December' +}; + +/** + * Converts a Date object to a Timestamp object + */ + +function formatDate(date: Date): Timestamp { + return { + relative: toTimeString(date.getTime(), TimestampUnits), + raw: date.getTime(), + date: date + .getDate() + .toString() + .padStart(2, '0'), + day: Days[date.getDay()], + hour: date + .getHours() + .toString() + .padStart(2, '0'), + meridian: date.getHours() > 12 ? 'PM' : 'AM', + minute: date + .getMinutes() + .toString() + .padStart(2, '0'), + month: Months[date.getMonth()], + month_short: (date.getMonth() + 1).toString().padStart(2, '0'), + second: date + .getSeconds() + .toString() + .padStart(2, '0'), + year: date.getFullYear().toString() }; - /** - * Utility type. Used to force Object.entries to allow non-strings. - */ - type ObjectEntries = Array<[K, V]>; - /** - * Converts a UNIX timestamp to a Relative String - */ - function toTimeString( - unix: bigint | number, - units: Record, - isFromNow = false, - limit?: number - ) { - if (typeof unix === 'number') unix = BigInt(unix); +} - if (isFromNow) unix = bigintAbs(unix - BigInt(Date.now())); - if (unix === 0n) return '0 milliseconds'; +/** + * Collectively multiplies bigints together + */ - const formatted: Map = new Map(); - const unitList: ObjectEntries = Object.entries(units) as any; - let run = unix; +function multiplyLarge(...nums: Array): bigint { + return nums.map(BigInt).reduce((p, v) => (p *= v), 1n); +} - for (const [unit, value] of unitList) { - if (run < value) continue; - const runs = run / value + 1n; +/** + * Get the absolute value of a bigint + */ - for (let loop = 0; loop <= runs; loop++) { - if (run < value) break; - const item = formatted.get(unit); +function bigintAbs(int: bigint) { + if (int < 0) return -int; + return int; +} - if (item) formatted.set(unit, item + 1); - else formatted.set(unit, 1); +/** + * Object of Units matched with their string representations. + */ - run -= value; - } - } - let returned: Array = []; - for (const [key, value] of formatted) { - const unit = key + (value === 1 ? '' : 's'); - returned.push(`${value} ${unit}`); - } - if (limit !== undefined) { - returned = returned.slice(0, limit); - } - return returned.join(', '); - } - /** - * Freezes a UNIT timestamp into some time string based on the Timestamp Style - */ - function freezeUnix(unix: number, style: TimestampStyles) { - const date = new Date(unix); - const timestamp = formatDate(date); - let ret = FrozenTimestampStyles[style]; - for (const [key, value] of Object.entries(timestamp)) { - ret = ret.split(`{${key}}`).join(value); - } - return ret; - } - /** - * Instanced Class for formatting strings into their Markup variants - */ - class FormatInner { - public raw: string; - public static: typeof FormatInner = FormatInner; - constructor(raw: string | FormatInner) { - if (raw instanceof FormatInner) { - raw = raw.raw; - } - this.raw = raw; - } - toString() { - return this.raw; - } - valueOf() { - return this.raw; - } - italics() { - return this.build('ITALICS', this.raw); - } - bold() { - return this.build('BOLD', this.raw); - } - codestring() { - const useDouble = this.raw.includes(Strings.CODESTRING); - if (useDouble) { - return this.codestringDouble(); - } - return this.codestringSingle(); - } - codestringDouble() { - return this.build('CODESTRING_DOUBLE', this.raw); - } - codestringSingle() { - return this.build('CODESTRING', this.raw); - } - codeblock(language?: string) { - let full = ''; - if (language) { - full += language + '\n'; - } - full += this.raw; - return this.build('CODEBLOCK', full); - } - spoiler() { - return this.build('SPOILER', this.raw); - } - strike() { - return this.build('STRIKE', this.raw); - } - underline() { - return this.build('UNDERLINE', this.raw); - } +const TimestampUnits = { + myriad: multiplyLarge(10, 10, 10, 10, 12, 4, 7, 24, 60, 1000), + millenium: multiplyLarge(10, 10, 10, 12, 4, 7, 24, 60, 1000), + century: multiplyLarge(10, 10, 12, 4, 7, 24, 60, 1000), + decade: multiplyLarge(10, 12, 4, 7, 24, 60, 60, 1000), + year: multiplyLarge(12, 4, 7, 24, 60, 60, 1000), + month: multiplyLarge(4, 7, 24, 60, 60, 1000), + week: multiplyLarge(7, 24, 60, 60, 1000), + day: multiplyLarge(24, 60, 60, 1000), + hour: multiplyLarge(60, 60, 1000), + minute: multiplyLarge(60, 1000), + second: multiplyLarge(1000), + millisecond: multiplyLarge(1) +}; - build(key: keyof typeof Strings, w: string) { - const escaped = Escape[key](w, key); - const ret = this.static.wrap(escaped, Strings[key]); - return new this.static(ret); - } - static wrap(raw: string, what: string) { - return `${what}${raw}${what}`; +/** + * Utility type. Used to force Object.entries to allow non-strings. + */ + +type ObjectEntries = Array<[K, V]>; + +/** + * Converts a UNIX timestamp to a Relative String + */ + +function toTimeString( + unix: bigint | number, + units: Record, + isFromNow = false, + limit?: number +) { + if (typeof unix === 'number') unix = BigInt(unix); + + if (isFromNow) unix = bigintAbs(unix - BigInt(Date.now())); + if (unix === 0n) return '0 milliseconds'; + + const formatted: Map = new Map(); + const unitList: ObjectEntries = Object.entries(units) as any; + let run = unix; + + for (const [unit, value] of unitList) { + if (run < value) continue; + const runs = run / value + 1n; + + for (let loop = 0; loop <= runs; loop++) { + if (run < value) break; + const item = formatted.get(unit); + + if (item) formatted.set(unit, item + 1); + else formatted.set(unit, 1); + + run -= value; } } - /** - * Formats strings into their Markup Variants - */ - export class Format extends FormatInner { - static bold(text: string) { - return new this(text).bold(); - } - static build(text: string, key: keyof typeof Strings) { - return new this(text).build(key, text); - } - static codeblock(text: string, language?: string) { - return new this(text).codeblock(language); - } - static codestring(text: string) { - return new this(text).codestring(); - } - static codestringSingle(text: string) { - return new this(text).codestringSingle(); - } - static codestringDouble(text: string) { - return new this(text).codestringDouble(); - } - static italics(text: string) { - return new this(text).italics(); - } - static spoiler(text: string) { - return new this(text).spoiler(); - } - static strike(text: string) { - return new this(text).strike(); + let returned: Array = []; + for (const [key, value] of formatted) { + const unit = key + (value === 1 ? '' : 's'); + returned.push(`${value} ${unit}`); + } + if (limit !== undefined) { + returned = returned.slice(0, limit); + } + return returned.join(', '); +} + +/** + * Freezes a UNIT timestamp into some time string based on the Timestamp Style + */ + +function freezeUnix({ unix, style }:{ unix: number; style: TimestampStyles; }): string { + const date = new Date(unix); + const timestamp = formatDate(date); + let ret = FrozenTimestampStyles[style]; + for (const [key, value] of Object.entries(timestamp)) { + ret = ret.split(`{${key}}`).join(value); + } + return ret; +} + +/** + * Instanced Class for formatting strings into their Markup variants + */ + +class FormatInner { + public raw: string; + public static: typeof FormatInner = FormatInner; + constructor(raw: string | FormatInner) { + if (raw instanceof FormatInner) { + raw = raw.raw; } - static underline(text: string) { - return new this(text).underline(); + this.raw = raw; + } + toString() { + return this.raw; + } + valueOf() { + return this.raw; + } + italics() { + return this.build('ITALICS', this.raw); + } + bold() { + return this.build('BOLD', this.raw); + } + codestring() { + const useDouble = this.raw.includes(Strings.CODESTRING); + if (useDouble) { + return this.codestringDouble(); } - static timestamp( - unix: number | Date | string, - format: TimestampStyles = TimestampStyles.BOTH_SHORT, - isSeconds = false - ) { - if (typeof unix === 'string') unix = Number(unix); - if (unix instanceof Date) unix = unix.getTime(); - - if (!isSeconds) { - unix /= 1000; - } - unix = Math.floor(unix); - return new this(``); + return this.codestringSingle(); + } + codestringDouble() { + return this.build('CODESTRING_DOUBLE', this.raw); + } + codestringSingle() { + return this.build('CODESTRING', this.raw); + } + codeblock(language?: string) { + let full = ''; + if (language) { + full += language + '\n'; } - static date( - unix: number | Date | string, - format: TimestampStyles = TimestampStyles.BOTH_SHORT, - isSeconds = false - ) { - if (typeof unix === 'string') unix = Number(unix); - if (unix instanceof Date) unix = unix.getTime(); - - if (isSeconds) { - unix *= 1000; - } - return new this(freezeUnix(unix, format)); + full += this.raw; + return this.build('CODEBLOCK', full); + } + spoiler() { + return this.build('SPOILER', this.raw); + } + strike() { + return this.build('STRIKE', this.raw); + } + underline() { + return this.build('UNDERLINE', this.raw); + } + + build(key: keyof typeof Strings, w: string) { + const escaped = Escape[key](w, key); + const ret = this.static.wrap(escaped, Strings[key]); + return new this.static(ret); + } + static wrap(raw: string, what: string) { + return `${what}${raw}${what}`; + } +} + +/** + * Formats strings into their Markup Variants + */ + +export class Format extends FormatInner { + static bold(text: string) { + return new this(text).bold(); + } + static build(text: string, key: keyof typeof Strings) { + return new this(text).build(key, text); + } + static codeblock(text: string, language?: string) { + return new this(text).codeblock(language); + } + static codestring(text: string) { + return new this(text).codestring(); + } + static codestringSingle(text: string) { + return new this(text).codestringSingle(); + } + static codestringDouble(text: string) { + return new this(text).codestringDouble(); + } + static italics(text: string) { + return new this(text).italics(); + } + static spoiler(text: string) { + return new this(text).spoiler(); + } + static strike(text: string) { + return new this(text).strike(); + } + static underline(text: string) { + return new this(text).underline(); + } + static timestamp( + unix: number | Date | string, + format: TimestampStyles = TimestampStyles.BOTH_SHORT, + isSeconds = false + ) { + if (typeof unix === 'string') unix = Number(unix); + if (unix instanceof Date) unix = unix.getTime(); + + if (!isSeconds) { + unix /= 1000; } - static link(text: string, url: string | URL) { - if (url instanceof URL) url = url.href; - return new this(`[${text}](${url})`); + unix = Math.floor(unix); + return new this(``); + } + static date( + unix: number | Date | string, + format: TimestampStyles = TimestampStyles.BOTH_SHORT, + isSeconds = false + ) { + if (typeof unix === 'string') unix = Number(unix); + if (unix instanceof Date) unix = unix.getTime(); + + if (isSeconds) { + unix *= 1000; } + return new this(freezeUnix({ unix, style: format })); + } + static link(text: string, url: string | URL) { + if (url instanceof URL) url = url.href; + return new this(`[${text}](${url})`); } - /** - * Enumeration of names used in the Matching process - */ - enum DiscordRegexNames { - EMOJI = 'EMOJI', - JUMP_CHANNEL = 'JUMP_CHANNEL', - JUMP_CHANNEL_MESSAGE = 'JUMP_CHANNEL_MESSAGE', - MENTION_CHANNEL = 'MENTION_CHANNEL', - MENTION_ROLE = 'MENTION_ROLE', - MENTION_USER = 'MENTION_USER', - TEXT_BOLD = 'TEXT_BOLD', - TEXT_CODEBLOCK = 'TEXT_CODEBLOCK', - TEXT_CODESTRING = 'TEXT_CODESTRING', - TEXT_ITALICS = 'TEXT_ITALICS', - TEXT_SNOWFLAKE = 'TEXT_SNOWFLAKE', - TEXT_SPOILER = 'TEXT_SPOILER', - TEXT_STRIKE = 'TEXT_STRIKE', - TEXT_UNDERLINE = 'TEXT_UNDERLINE', - TEXT_URL = 'TEXT_URL' - } - /** - * Mapping of Matching Names to their respective Regular Expressions - */ - export const DiscordRegex = { - [DiscordRegexNames.EMOJI]: //g, - [DiscordRegexNames.JUMP_CHANNEL]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)$/g, - [DiscordRegexNames.JUMP_CHANNEL_MESSAGE]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)\/(\d+)$/g, - [DiscordRegexNames.MENTION_CHANNEL]: /<#(\d+)>/g, - [DiscordRegexNames.MENTION_ROLE]: /<@&(\d+)>/g, - [DiscordRegexNames.MENTION_USER]: /<@(!?)(\d+)>/g, - [DiscordRegexNames.TEXT_BOLD]: /\*\*([\s\S]+?)\*\*/g, - [DiscordRegexNames.TEXT_CODEBLOCK]: /```(([a-z0-9-]+?)\n+)?\n*([^]+?)\n*```/gi, - [DiscordRegexNames.TEXT_CODESTRING]: /`([\s\S]+?)`/g, - [DiscordRegexNames.TEXT_ITALICS]: /_([\s\S]+?)_|\*([\s\S]+?)\*/g, - [DiscordRegexNames.TEXT_SNOWFLAKE]: /(\d+)/g, - [DiscordRegexNames.TEXT_SPOILER]: /\|\|([\s\S]+?)\|\|/g, - [DiscordRegexNames.TEXT_STRIKE]: /~~([\s\S]+?)~~(?!_)/g, - [DiscordRegexNames.TEXT_UNDERLINE]: /__([\s\S]+?)__/g, - [DiscordRegexNames.TEXT_URL]: /((?:https?):\/\/[^\s<]+[^<.,:;"'\]\s])/g +} + +/** + * Enumeration of names used in the Matching process + */ + +enum DiscordRegexNames { + EMOJI = 'EMOJI', + JUMP_CHANNEL = 'JUMP_CHANNEL', + JUMP_CHANNEL_MESSAGE = 'JUMP_CHANNEL_MESSAGE', + MENTION_CHANNEL = 'MENTION_CHANNEL', + MENTION_ROLE = 'MENTION_ROLE', + MENTION_USER = 'MENTION_USER', + TEXT_BOLD = 'TEXT_BOLD', + TEXT_CODEBLOCK = 'TEXT_CODEBLOCK', + TEXT_CODESTRING = 'TEXT_CODESTRING', + TEXT_ITALICS = 'TEXT_ITALICS', + TEXT_SNOWFLAKE = 'TEXT_SNOWFLAKE', + TEXT_SPOILER = 'TEXT_SPOILER', + TEXT_STRIKE = 'TEXT_STRIKE', + TEXT_UNDERLINE = 'TEXT_UNDERLINE', + TEXT_URL = 'TEXT_URL' +} + +/** + * Mapping of Matching Names to their respective Regular Expressions + */ + +export const DiscordRegex = { + [DiscordRegexNames.EMOJI]: //g, + [DiscordRegexNames.JUMP_CHANNEL]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)$/g, + [DiscordRegexNames.JUMP_CHANNEL_MESSAGE]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)\/(\d+)$/g, + [DiscordRegexNames.MENTION_CHANNEL]: /<#(\d+)>/g, + [DiscordRegexNames.MENTION_ROLE]: /<@&(\d+)>/g, + [DiscordRegexNames.MENTION_USER]: /<@(!?)(\d+)>/g, + [DiscordRegexNames.TEXT_BOLD]: /\*\*([\s\S]+?)\*\*/g, + [DiscordRegexNames.TEXT_CODEBLOCK]: /```(([a-z0-9-]+?)\n+)?\n*([^]+?)\n*```/gi, + [DiscordRegexNames.TEXT_CODESTRING]: /`([\s\S]+?)`/g, + [DiscordRegexNames.TEXT_ITALICS]: /_([\s\S]+?)_|\*([\s\S]+?)\*/g, + [DiscordRegexNames.TEXT_SNOWFLAKE]: /(\d+)/g, + [DiscordRegexNames.TEXT_SPOILER]: /\|\|([\s\S]+?)\|\|/g, + [DiscordRegexNames.TEXT_STRIKE]: /~~([\s\S]+?)~~(?!_)/g, + [DiscordRegexNames.TEXT_UNDERLINE]: /__([\s\S]+?)__/g, + [DiscordRegexNames.TEXT_URL]: /((?:https?):\/\/[^\s<]+[^<.,:;''\]\s])/g +}; + +/** + * Object containing all the data from some Matching sequence + */ + +export interface DiscordRegexMatch { + animated?: boolean; + channelId?: string; + guildId?: string; + id?: string; + language?: string; + matched: string; + mentionType?: string; + messageId?: string; + name?: string; + text?: string; + species: DiscordRegexNames; +} + +/** + * The result of a matched string. + */ + +export interface DiscordRegexPayload { + match: { + regex: RegExp; + type: string; }; - /** - * Object containing all the data from some Matching sequence - */ - export interface DiscordRegexMatch { - animated?: boolean; - channelId?: string; - guildId?: string; - id?: string; - language?: string; - matched: string; - mentionType?: string; - messageId?: string; - name?: string; - text?: string; - species: DiscordRegexNames; - } - /** - * The result of a matched string. - */ - export interface DiscordRegexPayload { - match: { - regex: RegExp; - type: string; - }; - matches: Array; - } - export interface EmojiMatch extends DiscordRegexMatch { - name: string; - id: string; - animated: boolean; - species: DiscordRegexNames.EMOJI; - } - export interface JumpMatch extends DiscordRegexMatch { - guildId: string; - species: - | DiscordRegexNames.JUMP_CHANNEL - | DiscordRegexNames.JUMP_CHANNEL_MESSAGE; - } - export interface JumpChannelMatch extends JumpMatch { - channelId: string; - species: DiscordRegexNames.JUMP_CHANNEL; - } - export interface JumpChannelMessageMatch extends JumpMatch { - channelId: string; - messageId: string; - species: DiscordRegexNames.JUMP_CHANNEL_MESSAGE; - } - export interface MentionableMatch extends DiscordRegexMatch { - id: string; - species: - | DiscordRegexNames.MENTION_CHANNEL - | DiscordRegexNames.MENTION_ROLE - | DiscordRegexNames.MENTION_USER; - } - export interface MentionChannelMatch extends MentionableMatch { - species: DiscordRegexNames.MENTION_CHANNEL; - } - export interface MentionRoleMatch extends MentionableMatch { - species: DiscordRegexNames.MENTION_ROLE; - } - export interface MentionUserMatch extends MentionableMatch { - mentionType: string; - species: DiscordRegexNames.MENTION_USER; - } - export interface TextMatch extends DiscordRegexMatch { - text: string; - species: - | DiscordRegexNames.TEXT_BOLD - | DiscordRegexNames.TEXT_CODEBLOCK - | DiscordRegexNames.TEXT_CODESTRING - | DiscordRegexNames.TEXT_ITALICS - | DiscordRegexNames.TEXT_SNOWFLAKE - | DiscordRegexNames.TEXT_SPOILER - | DiscordRegexNames.TEXT_STRIKE - | DiscordRegexNames.TEXT_UNDERLINE - | DiscordRegexNames.TEXT_URL; - } - export interface TextCodeblockMatch extends TextMatch { - language: string; - species: DiscordRegexNames.TEXT_CODEBLOCK; - } - export interface TextBoldMatch extends TextMatch { - species: DiscordRegexNames.TEXT_BOLD; - } - export interface TextCodestringMatch extends TextMatch { - species: DiscordRegexNames.TEXT_CODESTRING; - } - export interface TextItalicsMatch extends TextMatch { - species: DiscordRegexNames.TEXT_ITALICS; - } - export interface TextSnowflakeMatch extends TextMatch { - species: DiscordRegexNames.TEXT_SNOWFLAKE; - } - export interface TextSpoilerMatch extends TextMatch { - species: DiscordRegexNames.TEXT_SPOILER; - } - export interface TextStrikeMatch extends TextMatch { - species: DiscordRegexNames.TEXT_STRIKE; - } - export interface TextUnderlineMatch extends TextMatch { - species: DiscordRegexNames.TEXT_UNDERLINE; - } - export interface TextUrlMatch extends TextMatch { - species: DiscordRegexNames.TEXT_URL; - } - - class MatchInner { - public raw: string; - public static: typeof MatchInner = MatchInner; - - constructor(raw: string) { - this.raw = raw; - } + matches: Array; +} - emoji(): DiscordRegexPayload { - return this.match(DiscordRegexNames.EMOJI); - } - jumpChannel(): DiscordRegexPayload { - return this.match(DiscordRegexNames.JUMP_CHANNEL); - } - jumpChannelMessage(): DiscordRegexPayload { - return this.match(DiscordRegexNames.JUMP_CHANNEL_MESSAGE); - } - mentionChannel(): DiscordRegexPayload { - return this.match(DiscordRegexNames.MENTION_CHANNEL); - } - mentionRole(): DiscordRegexPayload { - return this.match(DiscordRegexNames.MENTION_ROLE); - } - mentionUser(): DiscordRegexPayload { - return this.match(DiscordRegexNames.MENTION_USER); - } - codeblock(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_CODEBLOCK); - } - bold(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_BOLD); - } - codestring(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_CODESTRING); - } - italics(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_ITALICS); - } - snowflake(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_SNOWFLAKE); - } - spoiler(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_SPOILER); - } - strike(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_STRIKE); - } - underline(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_UNDERLINE); - } - url(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_URL); - } +export interface EmojiMatch extends DiscordRegexMatch { + name: string; + id: string; + animated: boolean; + species: DiscordRegexNames.EMOJI; +} - match( - type: DiscordRegexNames, - onlyFirst = false - ): DiscordRegexPayload { - const regex = DiscordRegex[type]; - if (regex === undefined) { - throw new global.Error(`Unknown regex type: ${type}`); - } - regex.lastIndex = 0; - - const payload: DiscordRegexPayload = { - match: { regex, type }, - matches: [] - }; - - let match: RegExpExecArray | null = null; - while ((match = regex.exec(this.raw))) { - const result: DiscordRegexMatch = { matched: match[0], species: type }; - switch (type) { - case DiscordRegexNames.EMOJI: - { - result.name = match[1] as string; - result.id = match[2] as string; - result.animated = this.raw.startsWith(' { + return this.match(DiscordRegexNames.EMOJI); + } + jumpChannel(): DiscordRegexPayload { + return this.match(DiscordRegexNames.JUMP_CHANNEL); + } + jumpChannelMessage(): DiscordRegexPayload { + return this.match(DiscordRegexNames.JUMP_CHANNEL_MESSAGE); + } + mentionChannel(): DiscordRegexPayload { + return this.match(DiscordRegexNames.MENTION_CHANNEL); + } + mentionRole(): DiscordRegexPayload { + return this.match(DiscordRegexNames.MENTION_ROLE); + } + mentionUser(): DiscordRegexPayload { + return this.match(DiscordRegexNames.MENTION_USER); + } + codeblock(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_CODEBLOCK); + } + bold(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_BOLD); + } + codestring(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_CODESTRING); + } + italics(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_ITALICS); + } + snowflake(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_SNOWFLAKE); + } + spoiler(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_SPOILER); + } + strike(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_STRIKE); + } + underline(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_UNDERLINE); + } + url(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_URL); + } + + match( + type: DiscordRegexNames, + onlyFirst = false + ): DiscordRegexPayload { + const regex = DiscordRegex[type]; + if (regex === undefined) { + throw new global.Error(`Unknown regex type: ${type}`); + } + regex.lastIndex = 0; - if (onlyFirst) { + const payload: DiscordRegexPayload = { + match: { regex, type }, + matches: [] + }; + + let match: RegExpExecArray | null = null; + while ((match = regex.exec(this.raw))) { + const result: DiscordRegexMatch = { matched: match[0], species: type }; + switch (type) { + case DiscordRegexNames.EMOJI: + { + result.name = match[1] as string; + result.id = match[2] as string; + result.animated = this.raw.startsWith('(); export const ContextMenuMsg = new Map(); export const Commands = new Map(); @@ -11,8 +12,7 @@ export const Alias = new Map(); export const Buttons = new Map(); export const SelectMenus = new Map(); - -// Courtesy @Townsy45 +// Thanks to @Townsy45 function readPath(dir: string, arrayOfFiles: string[] = []): string[] { try { const files = readdirSync(dir); @@ -30,20 +30,20 @@ function readPath(dir: string, arrayOfFiles: string[] = []): string[] { export const fmtFileName = (n: string) => n.substring(0, n.length - 3); /** - * + * * @param {commandsDir} Relative path to commands directory * @returns {Promise<{ mod: Command; absPath: string; }[]>} data from command files */ -export async function buildData(commandDir: string ): Promise< +export async function buildData(commandDir: string): Promise< { mod: Module; absPath: string; }[] > { return Promise.all( - getCommands(commandDir).map( async (absPath) => { - const mod = (await import(absPath)).module; + getCommands(commandDir).map(async (absPath) => { + const mod = (await import(absPath)).module; if (mod === undefined) throw Error(`${SernError.UNDEFINED_MODULE} ${absPath}`); return { mod, absPath }; }), diff --git a/tests/functions.test.ts b/tests/functions.test.ts index e142bd28..5ac007fa 100644 --- a/tests/functions.test.ts +++ b/tests/functions.test.ts @@ -1,13 +1,13 @@ -import { hasPrefix, fmt, isNotFromBot } from '../src/handler/utilities/messageHelpers'; -describe('FUNCTIONS', () => { - test('If hasPrefix is a function', () => { - expect(typeof hasPrefix).toBe('function'); - }); - test('if fmt is a function', () => { - expect(typeof fmt).toBe('function'); - }); - test('if isBot is a function', () => { - expect(typeof isNotFromBot).toBe('function'); - }); +import { hasPrefix, fmt, isFromBot } from '../src/handler/utilities/messageHelpers'; +describe('FUNCTIONS', () => { + test('If hasPrefix is a function', () => { + expect(typeof hasPrefix).toBe('function'); + }); + test('if fmt is a function', () => { + expect(typeof fmt).toBe('function'); + }); + test('if isBot is a function', () => { + expect(typeof isFromBot).toBe('function'); + }); }); From 4f6b5f912618c4bad4f1bd558e084761c78c0b73 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 12 Apr 2022 23:10:18 +0300 Subject: [PATCH 002/128] style: Formatted HTML and CSS files --- docs/assets/highlight.css | 133 ++-- docs/assets/icons.css | 1010 ++++++++++++---------------- docs/classes/Sern.Handler.html | 1021 ++++++++++++++++++++++++++++- docs/enums/Sern.CommandType.html | 205 +++++- docs/index.html | 200 ++++-- docs/interfaces/Sern.Module.html | 567 +++++++++++++++- docs/interfaces/Sern.Wrapper.html | 417 +++++++++++- docs/modules.html | 116 +++- docs/modules/Sern.html | 156 ++++- docs/modules/Types.html | 534 ++++++++++++++- docs/modules/Utils.html | 684 ++++++++++++++++++- 11 files changed, 4298 insertions(+), 745 deletions(-) diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index 26d41f4c..875f2107 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -1,27 +1,28 @@ :root { - --light-hl-0: #000000; - --dark-hl-0: #D4D4D4; - --light-hl-1: #AF00DB; - --dark-hl-1: #C586C0; - --light-hl-2: #001080; - --dark-hl-2: #9CDCFE; - --light-hl-3: #A31515; - --dark-hl-3: #CE9178; - --light-hl-4: #0000FF; - --dark-hl-4: #569CD6; - --light-hl-5: #0070C1; - --dark-hl-5: #4FC1FF; - --light-hl-6: #795E26; - --dark-hl-6: #DCDCAA; - --light-hl-7: #008000; - --dark-hl-7: #6A9955; - --light-hl-8: #CD3131; - --dark-hl-8: #F44747; - --light-code-background: #F5F5F5; - --dark-code-background: #1E1E1E; + --light-hl-0: #000000; + --dark-hl-0: #d4d4d4; + --light-hl-1: #af00db; + --dark-hl-1: #c586c0; + --light-hl-2: #001080; + --dark-hl-2: #9cdcfe; + --light-hl-3: #a31515; + --dark-hl-3: #ce9178; + --light-hl-4: #0000ff; + --dark-hl-4: #569cd6; + --light-hl-5: #0070c1; + --dark-hl-5: #4fc1ff; + --light-hl-6: #795e26; + --dark-hl-6: #dcdcaa; + --light-hl-7: #008000; + --dark-hl-7: #6a9955; + --light-hl-8: #cd3131; + --dark-hl-8: #f44747; + --light-code-background: #f5f5f5; + --dark-code-background: #1e1e1e; } -@media (prefers-color-scheme: light) { :root { +@media (prefers-color-scheme: light) { + :root { --hl-0: var(--light-hl-0); --hl-1: var(--light-hl-1); --hl-2: var(--light-hl-2); @@ -32,9 +33,11 @@ --hl-7: var(--light-hl-7); --hl-8: var(--light-hl-8); --code-background: var(--light-code-background); -} } + } +} -@media (prefers-color-scheme: dark) { :root { +@media (prefers-color-scheme: dark) { + :root { --hl-0: var(--dark-hl-0); --hl-1: var(--dark-hl-1); --hl-2: var(--dark-hl-2); @@ -45,41 +48,63 @@ --hl-7: var(--dark-hl-7); --hl-8: var(--dark-hl-8); --code-background: var(--dark-code-background); -} } + } +} body.light { - --hl-0: var(--light-hl-0); - --hl-1: var(--light-hl-1); - --hl-2: var(--light-hl-2); - --hl-3: var(--light-hl-3); - --hl-4: var(--light-hl-4); - --hl-5: var(--light-hl-5); - --hl-6: var(--light-hl-6); - --hl-7: var(--light-hl-7); - --hl-8: var(--light-hl-8); - --code-background: var(--light-code-background); + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --code-background: var(--light-code-background); } body.dark { - --hl-0: var(--dark-hl-0); - --hl-1: var(--dark-hl-1); - --hl-2: var(--dark-hl-2); - --hl-3: var(--dark-hl-3); - --hl-4: var(--dark-hl-4); - --hl-5: var(--dark-hl-5); - --hl-6: var(--dark-hl-6); - --hl-7: var(--dark-hl-7); - --hl-8: var(--dark-hl-8); - --code-background: var(--dark-code-background); + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --code-background: var(--dark-code-background); } -.hl-0 { color: var(--hl-0); } -.hl-1 { color: var(--hl-1); } -.hl-2 { color: var(--hl-2); } -.hl-3 { color: var(--hl-3); } -.hl-4 { color: var(--hl-4); } -.hl-5 { color: var(--hl-5); } -.hl-6 { color: var(--hl-6); } -.hl-7 { color: var(--hl-7); } -.hl-8 { color: var(--hl-8); } -pre, code { background: var(--code-background); } +.hl-0 { + color: var(--hl-0); +} +.hl-1 { + color: var(--hl-1); +} +.hl-2 { + color: var(--hl-2); +} +.hl-3 { + color: var(--hl-3); +} +.hl-4 { + color: var(--hl-4); +} +.hl-5 { + color: var(--hl-5); +} +.hl-6 { + color: var(--hl-6); +} +.hl-7 { + color: var(--hl-7); +} +.hl-8 { + color: var(--hl-8); +} +pre, +code { + background: var(--code-background); +} diff --git a/docs/assets/icons.css b/docs/assets/icons.css index 776a3562..43784345 100644 --- a/docs/assets/icons.css +++ b/docs/assets/icons.css @@ -1,1043 +1,907 @@ .tsd-kind-icon { - display: block; - position: relative; - padding-left: 20px; - text-indent: -20px; + display: block; + position: relative; + padding-left: 20px; + text-indent: -20px; } .tsd-kind-icon:before { - content: ""; - display: inline-block; - vertical-align: middle; - width: 17px; - height: 17px; - margin: 0 3px 2px 0; - background-image: url(./icons.png); + content: ''; + display: inline-block; + vertical-align: middle; + width: 17px; + height: 17px; + margin: 0 3px 2px 0; + background-image: url(./icons.png); } @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { - .tsd-kind-icon:before { - background-image: url(./icons@2x.png); - background-size: 238px 204px; - } + .tsd-kind-icon:before { + background-image: url(./icons@2x.png); + background-size: 238px 204px; + } } .tsd-signature.tsd-kind-icon:before { - background-position: 0 -153px; + background-position: 0 -153px; } .tsd-kind-object-literal > .tsd-kind-icon:before { - background-position: 0px -17px; + background-position: 0px -17px; } .tsd-kind-object-literal.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -17px; + background-position: -17px -17px; } .tsd-kind-object-literal.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -17px; + background-position: -34px -17px; } .tsd-kind-class > .tsd-kind-icon:before { - background-position: 0px -34px; + background-position: 0px -34px; } .tsd-kind-class.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -34px; + background-position: -17px -34px; } .tsd-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -34px; + background-position: -34px -34px; } .tsd-kind-class.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: 0px -51px; + background-position: 0px -51px; } -.tsd-kind-class.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -17px -51px; +.tsd-kind-class.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -17px -51px; } .tsd-kind-class.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -51px; + background-position: -34px -51px; } .tsd-kind-interface > .tsd-kind-icon:before { - background-position: 0px -68px; + background-position: 0px -68px; } .tsd-kind-interface.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -68px; + background-position: -17px -68px; } .tsd-kind-interface.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -68px; + background-position: -34px -68px; } .tsd-kind-interface.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: 0px -85px; + background-position: 0px -85px; } -.tsd-kind-interface.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -17px -85px; +.tsd-kind-interface.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -17px -85px; } -.tsd-kind-interface.tsd-has-type-parameter.tsd-is-private - > .tsd-kind-icon:before { - background-position: -34px -85px; +.tsd-kind-interface.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { + background-position: -34px -85px; } .tsd-kind-namespace > .tsd-kind-icon:before { - background-position: 0px -102px; + background-position: 0px -102px; } .tsd-kind-namespace.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -102px; + background-position: -17px -102px; } .tsd-kind-namespace.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -102px; + background-position: -34px -102px; } .tsd-kind-module > .tsd-kind-icon:before { - background-position: 0px -102px; + background-position: 0px -102px; } .tsd-kind-module.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -102px; + background-position: -17px -102px; } .tsd-kind-module.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -102px; + background-position: -34px -102px; } .tsd-kind-enum > .tsd-kind-icon:before { - background-position: 0px -119px; + background-position: 0px -119px; } .tsd-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -119px; + background-position: -17px -119px; } .tsd-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -119px; + background-position: -34px -119px; } .tsd-kind-enum-member > .tsd-kind-icon:before { - background-position: 0px -136px; + background-position: 0px -136px; } .tsd-kind-enum-member.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -136px; + background-position: -17px -136px; } .tsd-kind-enum-member.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -136px; + background-position: -34px -136px; } .tsd-kind-signature > .tsd-kind-icon:before { - background-position: 0px -153px; + background-position: 0px -153px; } .tsd-kind-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -153px; + background-position: -17px -153px; } .tsd-kind-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -153px; + background-position: -34px -153px; } .tsd-kind-type-alias > .tsd-kind-icon:before { - background-position: 0px -170px; + background-position: 0px -170px; } .tsd-kind-type-alias.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -170px; + background-position: -17px -170px; } .tsd-kind-type-alias.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -170px; + background-position: -34px -170px; } .tsd-kind-type-alias.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: 0px -187px; + background-position: 0px -187px; } -.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -17px -187px; +.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -17px -187px; } -.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-private - > .tsd-kind-icon:before { - background-position: -34px -187px; +.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { + background-position: -34px -187px; } .tsd-kind-variable > .tsd-kind-icon:before { - background-position: -136px -0px; + background-position: -136px -0px; } .tsd-kind-variable.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -0px; + background-position: -153px -0px; } .tsd-kind-variable.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-variable.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -0px; + background-position: -51px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -0px; } .tsd-kind-variable.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -0px; + background-position: -170px -0px; } -.tsd-kind-variable.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -0px; +.tsd-kind-variable.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -0px; } .tsd-kind-variable.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-variable.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -0px; + background-position: -204px -0px; } -.tsd-kind-variable.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -0px; +.tsd-kind-variable.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -0px; } .tsd-kind-property > .tsd-kind-icon:before { - background-position: -136px -0px; + background-position: -136px -0px; } .tsd-kind-property.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -0px; + background-position: -153px -0px; } .tsd-kind-property.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-property.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -0px; + background-position: -51px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -0px; } .tsd-kind-property.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -0px; + background-position: -170px -0px; } -.tsd-kind-property.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -0px; +.tsd-kind-property.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -0px; } .tsd-kind-property.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-property.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -0px; + background-position: -204px -0px; } -.tsd-kind-property.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -0px; +.tsd-kind-property.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -0px; } .tsd-kind-get-signature > .tsd-kind-icon:before { - background-position: -136px -17px; + background-position: -136px -17px; } .tsd-kind-get-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -17px; + background-position: -153px -17px; } .tsd-kind-get-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -17px; + background-position: -119px -17px; } .tsd-kind-get-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -17px; + background-position: -51px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -17px; } .tsd-kind-get-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -17px; + background-position: -170px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -17px; +.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -17px; +.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -17px; } .tsd-kind-get-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -17px; + background-position: -204px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -17px; +.tsd-kind-get-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -17px; } .tsd-kind-set-signature > .tsd-kind-icon:before { - background-position: -136px -34px; + background-position: -136px -34px; } .tsd-kind-set-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -34px; + background-position: -153px -34px; } .tsd-kind-set-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -34px; + background-position: -119px -34px; } .tsd-kind-set-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -34px; + background-position: -51px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -34px; } .tsd-kind-set-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -34px; + background-position: -170px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -34px; +.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -34px; +.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -34px; } .tsd-kind-set-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -34px; + background-position: -204px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -34px; +.tsd-kind-set-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -34px; } .tsd-kind-accessor > .tsd-kind-icon:before { - background-position: -136px -51px; + background-position: -136px -51px; } .tsd-kind-accessor.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -51px; + background-position: -153px -51px; } .tsd-kind-accessor.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -51px; + background-position: -119px -51px; } .tsd-kind-accessor.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -51px; + background-position: -51px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -51px; } .tsd-kind-accessor.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -51px; + background-position: -170px -51px; } -.tsd-kind-accessor.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -51px; +.tsd-kind-accessor.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -51px; } .tsd-kind-accessor.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -51px; + background-position: -119px -51px; } .tsd-kind-accessor.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -51px; + background-position: -204px -51px; } -.tsd-kind-accessor.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -51px; +.tsd-kind-accessor.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -51px; } .tsd-kind-function > .tsd-kind-icon:before { - background-position: -136px -68px; + background-position: -136px -68px; } .tsd-kind-function.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -68px; + background-position: -153px -68px; } .tsd-kind-function.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-function.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -68px; + background-position: -51px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -68px; } .tsd-kind-function.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -68px; + background-position: -170px -68px; } -.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -68px; +.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -68px; } .tsd-kind-function.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-function.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -68px; + background-position: -204px -68px; } -.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -68px; +.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -68px; } .tsd-kind-method > .tsd-kind-icon:before { - background-position: -136px -68px; + background-position: -136px -68px; } .tsd-kind-method.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -68px; + background-position: -153px -68px; } .tsd-kind-method.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-method.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -68px; + background-position: -51px -68px; } -.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -68px; +.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -68px; } -.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -68px; +.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -68px; } -.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -68px; +.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -68px; } .tsd-kind-method.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-method.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -68px; + background-position: -170px -68px; } .tsd-kind-method.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -187px -68px; + background-position: -187px -68px; } .tsd-kind-method.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-method.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -68px; + background-position: -204px -68px; } -.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -68px; +.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -68px; } .tsd-kind-call-signature > .tsd-kind-icon:before { - background-position: -136px -68px; + background-position: -136px -68px; } .tsd-kind-call-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -68px; + background-position: -153px -68px; } .tsd-kind-call-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-call-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -68px; + background-position: -51px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -68px; } .tsd-kind-call-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -68px; + background-position: -170px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -68px; +.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -68px; +.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -68px; } .tsd-kind-call-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -68px; + background-position: -204px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -68px; +.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -68px; } .tsd-kind-function.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: -136px -85px; + background-position: -136px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -153px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -153px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class - > .tsd-kind-icon:before { - background-position: -51px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class > .tsd-kind-icon:before { + background-position: -51px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -85px; } .tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -85px; + > .tsd-kind-icon:before { + background-position: -102px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum - > .tsd-kind-icon:before { - background-position: -170px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum > .tsd-kind-icon:before { + background-position: -170px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -85px; } .tsd-kind-method.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: -136px -85px; + background-position: -136px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -153px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -153px -85px; } .tsd-kind-method.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -85px; + background-position: -119px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class - > .tsd-kind-icon:before { - background-position: -51px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class > .tsd-kind-icon:before { + background-position: -51px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -85px; } .tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -85px; + > .tsd-kind-icon:before { + background-position: -102px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum - > .tsd-kind-icon:before { - background-position: -170px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum > .tsd-kind-icon:before { + background-position: -170px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -85px; } .tsd-kind-constructor > .tsd-kind-icon:before { - background-position: -136px -102px; + background-position: -136px -102px; } .tsd-kind-constructor.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -102px; + background-position: -153px -102px; } .tsd-kind-constructor.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -102px; + background-position: -119px -102px; } .tsd-kind-constructor.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -102px; + background-position: -51px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } .tsd-kind-constructor.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -102px; + background-position: -170px -102px; } -.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -102px; +.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -102px; } -.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } .tsd-kind-constructor.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -102px; + background-position: -204px -102px; } -.tsd-kind-constructor.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -102px; +.tsd-kind-constructor.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -102px; } .tsd-kind-constructor-signature > .tsd-kind-icon:before { - background-position: -136px -102px; + background-position: -136px -102px; } .tsd-kind-constructor-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -102px; + background-position: -153px -102px; } .tsd-kind-constructor-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -102px; + background-position: -119px -102px; } .tsd-kind-constructor-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -102px; + background-position: -51px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } .tsd-kind-constructor-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -102px; + background-position: -170px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -102px; } .tsd-kind-index-signature > .tsd-kind-icon:before { - background-position: -136px -119px; + background-position: -136px -119px; } .tsd-kind-index-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -119px; + background-position: -153px -119px; } .tsd-kind-index-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -119px; + background-position: -119px -119px; } .tsd-kind-index-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -119px; + background-position: -51px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -119px; } .tsd-kind-index-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -119px; + background-position: -170px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -119px; +.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -119px; +.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -119px; } .tsd-kind-index-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -119px; + background-position: -204px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -119px; +.tsd-kind-index-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -119px; } .tsd-kind-event > .tsd-kind-icon:before { - background-position: -136px -136px; + background-position: -136px -136px; } .tsd-kind-event.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -136px; + background-position: -153px -136px; } .tsd-kind-event.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -136px; + background-position: -119px -136px; } .tsd-kind-event.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -136px; + background-position: -51px -136px; } .tsd-kind-event.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { - background-position: -68px -136px; + background-position: -68px -136px; } .tsd-kind-event.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { - background-position: -85px -136px; + background-position: -85px -136px; } -.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -136px; +.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -136px; } .tsd-kind-event.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -136px; + background-position: -119px -136px; } .tsd-kind-event.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -136px; + background-position: -170px -136px; } .tsd-kind-event.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -187px -136px; + background-position: -187px -136px; } .tsd-kind-event.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -136px; + background-position: -119px -136px; } .tsd-kind-event.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -136px; + background-position: -204px -136px; } -.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -136px; +.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -136px; } .tsd-is-static > .tsd-kind-icon:before { - background-position: -136px -153px; + background-position: -136px -153px; } .tsd-is-static.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -153px; + background-position: -153px -153px; } .tsd-is-static.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -153px; + background-position: -119px -153px; } .tsd-is-static.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -153px; + background-position: -51px -153px; } .tsd-is-static.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { - background-position: -68px -153px; + background-position: -68px -153px; } .tsd-is-static.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { - background-position: -85px -153px; + background-position: -85px -153px; } -.tsd-is-static.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -153px; +.tsd-is-static.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -153px; } .tsd-is-static.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -153px; + background-position: -119px -153px; } .tsd-is-static.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -153px; + background-position: -170px -153px; } .tsd-is-static.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -187px -153px; + background-position: -187px -153px; } .tsd-is-static.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -153px; + background-position: -119px -153px; } .tsd-is-static.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -153px; + background-position: -204px -153px; } -.tsd-is-static.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -153px; +.tsd-is-static.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -153px; } .tsd-is-static.tsd-kind-function > .tsd-kind-icon:before { - background-position: -136px -170px; + background-position: -136px -170px; } .tsd-is-static.tsd-kind-function.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -170px; + background-position: -153px -170px; } .tsd-is-static.tsd-kind-function.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -170px; + background-position: -119px -170px; } .tsd-is-static.tsd-kind-function.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -170px; + background-position: -51px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } .tsd-is-static.tsd-kind-function.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -170px; + background-position: -170px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -170px; } .tsd-is-static.tsd-kind-method > .tsd-kind-icon:before { - background-position: -136px -170px; + background-position: -136px -170px; } .tsd-is-static.tsd-kind-method.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -170px; + background-position: -153px -170px; } .tsd-is-static.tsd-kind-method.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -170px; + background-position: -119px -170px; } .tsd-is-static.tsd-kind-method.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -170px; + background-position: -51px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } .tsd-is-static.tsd-kind-method.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -170px; + background-position: -170px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -170px; } .tsd-is-static.tsd-kind-call-signature > .tsd-kind-icon:before { - background-position: -136px -170px; + background-position: -136px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -153px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-is-protected > .tsd-kind-icon:before { + background-position: -153px -170px; } .tsd-is-static.tsd-kind-call-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -170px; + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class - > .tsd-kind-icon:before { - background-position: -51px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class > .tsd-kind-icon:before { + background-position: -51px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum - > .tsd-kind-icon:before { - background-position: -170px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { + background-position: -170px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -170px; } .tsd-is-static.tsd-kind-event > .tsd-kind-icon:before { - background-position: -136px -187px; + background-position: -136px -187px; } .tsd-is-static.tsd-kind-event.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -187px; + background-position: -153px -187px; } .tsd-is-static.tsd-kind-event.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -187px; + background-position: -119px -187px; } .tsd-is-static.tsd-kind-event.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -187px; + background-position: -51px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -187px; } .tsd-is-static.tsd-kind-event.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -187px; + background-position: -170px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -187px; } diff --git a/docs/classes/Sern.Handler.html b/docs/classes/Sern.Handler.html index 1f7c5633..1ce9aded 100644 --- a/docs/classes/Sern.Handler.html +++ b/docs/classes/Sern.Handler.html @@ -1,29 +1,992 @@ -Handler | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Handler

Index

Constructors

Properties

wrapper: Wrapper

Accessors

  • get client(): Client<boolean>
  • readonly

    Returns Client<boolean>

    the discord.js client (DiscordJS#Client));

    -
  • get commandDir(): string
  • get prefix(): string
  • get privateServers(): { id: string; test: boolean }[]
  • readonly

    Returns { id: string; test: boolean }[]

    []} Private server ID for testing or personal use

    -

Methods

  • commandResult(module: CommandVal, message: Message<boolean>): Promise<undefined | possibleOutput<string>>
  • Parameters

    • module: CommandVal
      -

      Command file information

      -
    • message: Message<boolean>
      -

      The message object

      -

    Returns Promise<undefined | possibleOutput<string>>

    Takes return value and replies it, if possible input

    -
  • findModuleFrom<T>(ctx: T): undefined | CommandVal
  • Type parameters

    • T: CommandInteraction<CacheType> | Message<boolean>

    Parameters

    • ctx: T
      -

      name of possible command

      -

    Returns undefined | CommandVal

  • interactionResult(module: CommandVal, interaction: CommandInteraction<CacheType>): Promise<undefined | possibleOutput<string>>
  • Parameters

    • module: CommandVal
      -

      Command file information

      -
    • interaction: CommandInteraction<CacheType>
      -

      The Discord.js command interaction (DiscordJS#CommandInteraction))

      -

    Returns Promise<undefined | possibleOutput<string>>

    Takes return value and replies it, if possible input

    -
  • registerModules(modArr: { absPath: string; mod: Module<unknown>; name: string }[]): Promise<void>
  • -

    This function chains Files.buildData

    -

    Parameters

    • modArr: { absPath: string; mod: Module<unknown>; name: string }[]
      -

      module information

      -

    Returns Promise<void>

  • reloadSlash(cmdName: string, description: string, options: ApplicationCommandOptionData[]): Promise<void>
  • Parameters

    • cmdName: string
      -

      name of command

      -
    • description: string
      -

      description of command

      -
    • options: ApplicationCommandOptionData[]
      -

      any options for the slash command

      -

    Returns Promise<void>

Legend

  • Private property
  • Private method
  • Constructor

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Handler - SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Class Handler

+
+
+
+
+
+
+
+

Hierarchy

+
    +
  • Handler
  • +
+
+
+

Index

+
+
+
+

Constructors

+ +
+
+

Properties

+ +
+
+

Accessors

+ +
+
+

Methods

+ +
+
+
+
+
+

Constructors

+
+ + + +
    +
  • + +

    Parameters

    +
      +
    • +
      + wrapper: + Wrapper +
      +
      +
      +

      The data that is required to run sern handler

      +
      +
      +
    • +
    +

    + Returns Handler +

    +
  • +
+
+
+
+

Properties

+
+ + +
+ wrapper: + Wrapper +
+ +
+
+
+

Accessors

+
+ + +
    +
  • + get client(): Client<boolean> +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    + Returns Client<boolean> +

    +

    the discord.js client (DiscordJS#Client));

    +
  • +
+
+
+ + +
    +
  • + get commandDir(): string +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    Returns string

    +

    Directory of the commands folder

    +
  • +
+
+
+ + +
    +
  • + get prefix(): string +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    Returns string

    +

    The prefix used for legacy commands

    +
  • +
+
+
+ + +
    +
  • + get privateServers(): { id: string; test: boolean }[] +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    + Returns { id: string; test: boolean }[] +

    +

    []} Private server ID for testing or personal use

    +
  • +
+
+
+
+

Methods

+
+ + +
    +
  • + commandResult(module: CommandVal, message: Message<boolean>): Promise<undefined | possibleOutput<string>> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      module: CommandVal
      +
      +
      +

      Command file information

      +
      +
      +
    • +
    • +
      + message: Message<boolean> +
      +
      +
      +

      The message object

      +
      +
      +
    • +
    +

    + Returns Promise<undefined | possibleOutput<string>> +

    +

    Takes return value and replies it, if possible input

    +
  • +
+
+
+ + +
    +
  • + findModuleFrom<T>(ctx: T): undefined | CommandVal +
  • +
+
    +
  • + +

    Type parameters

    +
      +
    • +

      + T: CommandInteraction<CacheType> | Message<boolean> +

      +
    • +
    +

    Parameters

    +
      +
    • +
      ctx: T
      +
      +
      +

      name of possible command

      +
      +
      +
    • +
    +

    + Returns undefined | CommandVal +

    +
    +
  • +
+
+
+ + +
    +
  • + interactionResult(module: CommandVal, interaction: CommandInteraction<CacheType>): Promise<undefined | possibleOutput<string>> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      module: CommandVal
      +
      +
      +

      Command file information

      +
      +
      +
    • +
    • +
      + interaction: CommandInteraction<CacheType> +
      +
      +
      +

      The Discord.js command interaction (DiscordJS#CommandInteraction))

      +
      +
      +
    • +
    +

    + Returns Promise<undefined | possibleOutput<string>> +

    +

    Takes return value and replies it, if possible input

    +
  • +
+
+
+ + +
    +
  • + registerModules(modArr: { absPath: string; mod: Module<unknown>; name: string }[]): Promise<void> +
  • +
+
    +
  • + +
    +
    +

    This function chains Files.buildData

    +
    +
    +

    Parameters

    +
      +
    • +
      + modArr: { absPath: string; mod: Module<unknown>; name: string }[] +
      +
      +
      +

      module information

      +
      +
      +
    • +
    +

    + Returns Promise<void> +

    +
  • +
+
+
+ + +
    +
  • + reloadSlash(cmdName: string, description: string, options: ApplicationCommandOptionData[]): Promise<void> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      cmdName: string
      +
      +
      +

      name of command

      +
      +
      +
    • +
    • +
      description: string
      +
      +
      +

      description of command

      +
      +
      +
    • +
    • +
      + options: ApplicationCommandOptionData[] +
      +
      +
      +

      any options for the slash command

      +
      +
      +
    • +
    +

    + Returns Promise<void> +

    +
  • +
+
+
+
+ +
+
+
+
+

Legend

+
+
    +
  • + Private property +
  • +
  • + Private method +
  • +
+
    +
  • Constructor
  • +
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/enums/Sern.CommandType.html b/docs/enums/Sern.CommandType.html index 47542977..4f09714a 100644 --- a/docs/enums/Sern.CommandType.html +++ b/docs/enums/Sern.CommandType.html @@ -1 +1,204 @@ -CommandType | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Enumeration CommandType

Index

Enumeration members

Enumeration members

SLASH = 2
TEXT = 1

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + CommandType - SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Enumeration CommandType

+
+
+
+
+
+
+
+

Index

+
+
+
+

Enumeration members

+ +
+
+
+
+
+

Enumeration members

+
+ + +
SLASH = 2
+ +
+
+ + +
TEXT = 1
+ +
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/index.html b/docs/index.html index 8c881568..88639543 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,56 +1,168 @@ -sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

sern-handler

- -

Sern Handler

-
- -NPM version NPM downloads Builds Passing + + + + + + SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+

sern-handler

+
+
+
+
+
+
+ +

Sern Handler

+
+ + NPM version + NPM downloads + Builds Passing -

Sern can automate and streamline development of your discord bot with new version compatibility and full customization.

- +

+ Sern can automate and streamline development of your discord bot with new version compatibility and full + customization. +

+ - -

Installation

-
-
npm install sern-handler
+            
+              

Installation

+
+
npm install sern-handler
 
-
yarn add sern-handler
+            
yarn add sern-handler
 
-
pnpm add sern-handler
+            
pnpm add sern-handler
 
- -

Basic Usage

-
+ +

Basic Usage

+
- -

index.js

-
-
import { Client, Intents } from 'discord.js';
import { Sern } from 'sern-handler';
import { prefix, token } from '../src/secrets.json';

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS
]
});

new Sern.Handler({
client,
prefix,
commands : 'dist/commands',
privateServers : [
{
test : true,
id: 'server-id'
}
],
init: async (handler) => {
// Optional function to initialize anything else on bot startup
},
});


client.login(token); + +

index.js

+
+
import { Client, Intents } from 'discord.js';
import { Sern } from 'sern-handler';
import { prefix, token } from '../src/secrets.json';

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS
]
});

new Sern.Handler({
client,
prefix,
commands : 'dist/commands',
privateServers : [
{
test : true,
id: 'server-id'
}
],
init: async (handler) => {
// Optional function to initialize anything else on bot startup
},
});


client.login(token);
- -

ping.js

-
-
import { Sern, Types } from 'sern-handler';
import { Ok } from 'ts-results';

export default {
alias: [],
desc : 'A ping pong command',
visibility : 'private',
test : false,
type: Sern.CommandType.SLASH | Sern.CommandType.TEXT,
execute : async ({ message, interaction }, args) => {
interaction.reply({ content: 'Pong! });
}
}; + +

ping.js

+
+
import { Sern, Types } from 'sern-handler';
import { Ok } from 'ts-results';

export default {
alias: [],
desc : 'A ping pong command',
visibility : 'private',
test : false,
type: Sern.CommandType.SLASH | Sern.CommandType.TEXT,
execute : async ({ message, interaction }, args) => {
interaction.reply({ content: 'Pong! });
}
};
-

See documentation for TypeScript examples and more

+

See documentation for TypeScript examples and more

- -

Links link

-
- + +

Links link

+
+ - -

Contribute

-
-
    -
  • Pull up on issues and tell me if there are bugs
  • -
  • All kinds of contributions are welcomed!
  • -
-

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + +

Contribute

+
+
    +
  • + Pull up on issues and tell me if there are bugs +
  • +
  • All kinds of contributions are welcomed!
  • +
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/interfaces/Sern.Module.html b/docs/interfaces/Sern.Module.html index 71934dad..2f2e2b74 100644 --- a/docs/interfaces/Sern.Module.html +++ b/docs/interfaces/Sern.Module.html @@ -1,8 +1,559 @@ -Module | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Module<T>

-

An object that gets imported and acts as a command.

-
property

{string} desc

-
property

{Visibility} visibility

-
property

{CommandType} type

-
property

{(eventParams : Context, args : Ok<T=string>) => Awaitable<possibleOutput | void>)} execute

-
prop

{(ctx: Context, args: Arg) => Utils.ArgType} parse

-

Type parameters

  • T = string

Hierarchy

  • Module

Index

Properties

alias: string[]
desc: string
test: boolean
visibility: Visibility

Methods

Legend

  • Property
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Module | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Interface Module<T>

+
+
+
+
+
+
+
+
+
+

An object that gets imported and acts as a command.

+
+
+
property
+

{string} desc

+
property
+

{Visibility} visibility

+
property
+

{CommandType} type

+
property
+
+

+ {(eventParams : Context, args : Ok<T=string>) => Awaitable<possibleOutput | void>} + execute +

+
+
prop
+
+
+
+
+
+

Type parameters

+
    +
  • +

    T = string

    +
  • +
+
+
+

Hierarchy

+
    +
  • Module
  • +
+
+
+

Index

+
+
+
+

Properties

+ +
+
+

Methods

+ +
+
+
+
+
+

Properties

+
+ + +
+ alias: string[] +
+ +
+
+ + +
+ desc: string +
+ +
+
+ + +
+ test: boolean +
+ +
+
+ + +
+ type: + CommandType +
+ +
+
+ + +
+ visibility: + Visibility +
+ +
+
+
+

Methods

+
+ + + + +
+
+ + + + +
+
+
+ +
+
+
+
+

Legend

+
+
    +
  • Property
  • +
  • Method
  • +
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/interfaces/Sern.Wrapper.html b/docs/interfaces/Sern.Wrapper.html index 01312d3d..7fe8f9d3 100644 --- a/docs/interfaces/Sern.Wrapper.html +++ b/docs/interfaces/Sern.Wrapper.html @@ -1,8 +1,409 @@ -Wrapper | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Wrapper

-

An object to be passed into Sern.Handler constructor.

-
property

{readonly Client} client

-
property

{readonly string} prefix

-
property

{readonly string} commands

-
prop

{(handler : Handler) => void)} init

-
property

{readonly {test: boolean, id: string}[]} privateServers

-

Hierarchy

  • Wrapper

Index

Properties

client: Client<boolean>
commands: string
prefix: string
privateServers: { id: string; test: boolean }[]

Methods

Legend

  • Property
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Wrapper | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Interface Wrapper

+
+
+
+
+
+
+
+
+
+

An object to be passed into Sern.Handler constructor.

+
+
+
property
+

{readonly Client} client

+
property
+

{readonly string} prefix

+
property
+

{readonly string} commands

+
prop
+

{(handler : Handler) => void)} init

+
property
+

{readonly {test: boolean, id: string}[]} privateServers

+
+
+
+
+

Hierarchy

+
    +
  • Wrapper
  • +
+
+
+

Index

+
+
+
+

Properties

+ +
+
+

Methods

+ +
+
+
+
+
+

Properties

+
+ + +
+ client: Client<boolean> +
+ +
+
+ + +
+ commands: string +
+ +
+
+ + +
+ prefix: string +
+ +
+
+ + +
+ privateServers: + { id: string; test: boolean }[] +
+ +
+
+
+

Methods

+
+ + +
    +
  • + init(handler: Handler): void +
  • +
+ +
+
+
+ +
+
+
+
+

Legend

+
+
    +
  • Property
  • +
  • Method
  • +
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules.html b/docs/modules.html index 3d28a777..44bf4f6b 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1 +1,115 @@ -sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

sern-handler

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+

sern-handler

+
+
+
+
+
+
+

Index

+
+
+
+

Namespaces

+ +
+
+
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules/Sern.html b/docs/modules/Sern.html index 98d3b902..ac7c905b 100644 --- a/docs/modules/Sern.html +++ b/docs/modules/Sern.html @@ -1 +1,155 @@ -Sern | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Sern

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Sern | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Namespace Sern

+
+
+
+
+
+
+
+

Index

+
+
+
+

Enumerations

+ +
+
+

Classes

+ +
+
+

Interfaces

+ +
+
+
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules/Types.html b/docs/modules/Types.html index 00e931cb..2ae10487 100644 --- a/docs/modules/Types.html +++ b/docs/modules/Types.html @@ -1 +1,533 @@ -Types | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Types

Index

Type aliases

Arg: ParseType<{ slash: SlashOptions; text: string }>
Context: { interaction: Option<CommandInteraction>; message: Option<Message> }

Type declaration

  • interaction: Option<CommandInteraction>
  • message: Option<Message>
Nullable<T>: T | null

Type parameters

  • T

ParseType<T>: { [ K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never }[keyof T]

Type parameters

  • T

SlashOptions: Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused">
Visibility: "private" | "public"
execute: Module<unknown>["execute"]
possibleOutput<T>: T | (MessagePayload & MessageOptions)

Type parameters

  • T = string

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Types | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Namespace Types

+
+
+
+
+
+
+
+

Index

+
+
+
+

Type aliases

+ +
+
+
+
+
+

Type aliases

+
+ + +
+ Arg: + ParseType<{ slash: SlashOptions; text: string }> +
+ +
+
+ + +
+ Context: + { interaction: Option<CommandInteraction>; message: Option<Message> } +
+ +
+

Type declaration

+
    +
  • +
    + interaction: Option<CommandInteraction> +
    +
  • +
  • +
    + message: Option<Message> +
    +
  • +
+
+
+
+ + +
+ Nullable<T>: + T | null +
+ +

Type parameters

+
    +
  • T

  • +
+
+
+ + +
+ ParseType<T>: + { [ K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never + }[keyof T] +
+ +

Type parameters

+
    +
  • T

  • +
+
+
+ + +
+ SlashOptions: + Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused"> +
+ +
+
+ + +
+ Visibility: + "private" | "public" +
+ +
+
+ + +
+ execute: + Module<unknown>["execute"] +
+ +
+
+ + +
+ possibleOutput<T>: + T | (MessagePayload & MessageOptions) +
+ +

Type parameters

+
    +
  • +

    T = string

    +
  • +
+
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules/Utils.html b/docs/modules/Utils.html index b4b76565..74c2dfdb 100644 --- a/docs/modules/Utils.html +++ b/docs/modules/Utils.html @@ -1,25 +1,659 @@ -Utils | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Utils

Index

Type aliases

ArgType<T>: Result<T, possibleOutput>
-

Wrapper type taking Ok(T) or Err(possibleOutput) e.g Result<T, possibleOutput

-

Type parameters

  • T

Functions

  • parseBool(arg: string, onFailure?: possibleOutput<string>, regexes?: { noRegex: RegExp; yesRegex: RegExp }): ArgType<boolean>
  • toArr(arg: string, sep?: string): ArgType<string[]>

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Utils | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Namespace Utils

+
+
+
+
+
+
+
+

Index

+
+
+
+

Type aliases

+ +
+
+

Functions

+ +
+
+
+
+
+

Type aliases

+
+ + +
+ ArgType<T>: + Result<T, possibleOutput> +
+ +
+
+

+ Wrapper type taking Ok(T) or Err(possibleOutput) e.g + Result<T, possibleOutput +

+
+
+

Type parameters

+
    +
  • T

  • +
+
+
+
+

Functions

+
+ + +
    +
  • + parseBool(arg: string, onFailure?: possibleOutput<string>, regexes?: { noRegex: RegExp; yesRegex: RegExp }): ArgType<boolean> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      arg: string
      +
      +
      +

      command arguments

      +
      +
      +
    • +
    • +
      + onFailure: + possibleOutput<string> = ... +
      +
      +
      +

      If cannot parse arg into boolean.

      +
      +
      +
    • +
    • +
      + regexes: { noRegex: RegExp; yesRegex: RegExp } = ... +
      +
        +
      • +
        + noRegex: RegExp +
        +
      • +
      • +
        + yesRegex: RegExp +
        +
      • +
      +
    • +
    +

    + Returns + ArgType<boolean> +

    +
    +

    attemps to parse args as a boolean

    +
    +
  • +
+
+
+ + + + +
+
+ + +
    +
  • + toArr(arg: string, sep?: string): ArgType<string[]> +
  • +
+ +
+
+ + + + +
+
+ + + + +
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + From 74cc1e86ba22000e68e1ab9ad53eefe3694836a4 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 12 Apr 2022 23:13:37 +0300 Subject: [PATCH 003/128] Revert "style: Formatted 17 files & changes messageHelper util" This reverts commit 988d7fa6d2f07fadd05d1fc5a42c26d4767b0b44. --- .prettierrc | 2 +- package-lock.json | 69 +- package.json | 4 +- src/handler/events/interactionCreate.ts | 9 +- src/handler/events/messageEvent.ts | 68 +- src/handler/events/observableHandling.ts | 80 +- src/handler/events/readyEvent.ts | 91 +- src/handler/logger.ts | 54 +- src/handler/sern.ts | 50 +- src/handler/structures/context.ts | 207 +-- src/handler/structures/errors.ts | 10 +- .../structures/modules/commands/module.ts | 62 +- .../modules/commands/moduleHandler.ts | 37 +- src/handler/structures/modules/module.ts | 16 +- src/handler/structures/structxports.ts | 9 +- src/handler/structures/wrapper.ts | 21 +- src/handler/utilities/markup.ts | 1472 ++++++++--------- src/handler/utilities/messageHelpers.ts | 34 +- src/handler/utilities/readFile.ts | 16 +- tests/functions.test.ts | 22 +- 20 files changed, 1113 insertions(+), 1220 deletions(-) diff --git a/.prettierrc b/.prettierrc index 0c670739..2f316681 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,5 @@ "trailingComma": "all", "singleQuote": true, "printWidth": 120, - "tabWidth": 2 + "tabWidth": 4 } diff --git a/package-lock.json b/package-lock.json index fe6d367b..4c10a54c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -26,7 +26,7 @@ "cz-conventional-changelog": "^3.0.1", "jest": "^27.5.1", "standard-version": "^9.3.2", - "typedoc": "^0.22.14", + "typedoc": "^0.22.11", "typescript": "^4.5.5" } }, @@ -8494,16 +8494,16 @@ } }, "node_modules/typedoc": { - "version": "0.22.14", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", - "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", "dev": true, "dependencies": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.12", - "minimatch": "^5.0.1", - "shiki": "^0.10.1" + "marked": "^4.0.10", + "minimatch": "^3.0.4", + "shiki": "^0.10.0" }, "bin": { "typedoc": "bin/typedoc" @@ -8512,28 +8512,7 @@ "node": ">= 12.10.0" }, "peerDependencies": { - "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x" - } - }, - "node_modules/typedoc/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/typedoc/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" + "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x" } }, "node_modules/typescript": { @@ -15317,36 +15296,16 @@ } }, "typedoc": { - "version": "0.22.14", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", - "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", "dev": true, "requires": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.12", - "minimatch": "^5.0.1", - "shiki": "^0.10.1" - }, - "dependencies": { - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - } + "marked": "^4.0.10", + "minimatch": "^3.0.4", + "shiki": "^0.10.0" } }, "typescript": { diff --git a/package.json b/package.json index fb2f5b0e..ba3c0028 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "description": "", "main": "dist/index.js", - "scripts": { + "scripts": { "compile": "tsc", "watch": "tsc -w", "lint": "eslint src/**/*.ts", @@ -34,7 +34,7 @@ "cz-conventional-changelog": "^3.0.1", "jest": "^27.5.1", "standard-version": "^9.3.2", - "typedoc": "^0.22.14", + "typedoc": "^0.22.11", "typescript": "^4.5.5" }, "config": { diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index e463ce79..e44152cc 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,11 +1,10 @@ -import type { Interaction } from 'discord.js'; -import type Wrapper from '../structures/wrapper'; - -import * as Files from '../utilities/readFile'; -import Context from '../structures/context'; +import type { Interaction } from 'discord.js'; import { fromEvent, Observable, of, concatMap } from 'rxjs'; import { CommandType } from '../sern'; +import Context from '../structures/context'; +import type Wrapper from '../structures/wrapper'; +import * as Files from '../utilities/readFile'; import { filterTap } from './observableHandling'; import { filter } from 'rxjs'; diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 925b3f44..d2ee6b6c 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -1,43 +1,39 @@ -import type { Message } from 'discord.js'; -import type Wrapper from '../structures/wrapper'; - -import { fromEvent, Observable, of, concatMap } from 'rxjs'; - +import type { ChatInputCommandInteraction, Message } from 'discord.js'; +import { fromEvent, Observable, of, concatMap } from 'rxjs'; +import { CommandType } from '../sern'; import Context from '../structures/context'; -import * as Files from '../utilities/readFile'; - +import type Wrapper from '../structures/wrapper'; import { fmt } from '../utilities/messageHelpers'; -import { CommandType } from '../sern'; +import * as Files from '../utilities/readFile'; import { filterTap, ignoreNonBot } from './observableHandling'; -export const onMessageCreate = (wrapper: Wrapper) => { - const { client, defaultPrefix } = wrapper; - - (>fromEvent(client, 'messageCreate')) - .pipe( - ignoreNonBot(defaultPrefix), - concatMap(m => { - const [prefix, ...data] = fmt({ msg: m, prefix: defaultPrefix }); +export const onMessageCreate = (wrapper : Wrapper) => { + const { client, defaultPrefix } = wrapper; + (> fromEvent( client, 'messageCreate')) + .pipe ( + ignoreNonBot(defaultPrefix), + concatMap ( m => { + const [ prefix, ...data ] = fmt(m, defaultPrefix); const posMod = Files.Commands.get(prefix) ?? Files.Alias.get(prefix); - return of(posMod) - .pipe( - filterTap(CommandType.TEXT, mod => { - const ctx = Context.wrap(m); - mod.execute(ctx, ['text', data]); - }) - ); - }) - ).subscribe({ - error(e) { - // Log the errors - - throw e; - }, - next(command) { - // Log on each command emitted - - console.log(command); - }, - }); + return of( posMod ) + .pipe ( + filterTap(CommandType.TEXT, mod => { + const ctx = Context.wrap(m); + mod.execute(ctx, ['text', data]); + }) + ); + }) + ).subscribe ({ + error(e) { + //log things + throw e; + }, + next(command) { + //log on each command emitted + console.log(command); + }, + }); + + }; diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index 93d33811..d5892b8d 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -1,65 +1,63 @@ import type { Awaitable, Message } from 'discord.js'; - import type { CommandType } from '../sern'; import type { Module } from '../structures/structxports'; -import type { ModuleDefs } from '../structures/modules/commands/moduleHandler'; - import { Observable, throwError } from 'rxjs'; +import type { ModuleDefs } from '../structures/modules/commands/moduleHandler'; import { SernError } from '../structures/errors'; -import { isFromBot, isFromDM } from '../utilities/messageHelpers'; +import { isNotFromBot, isNotFromDM } from '../utilities/messageHelpers'; -export function match(mod: Module | undefined, type: CommandType): boolean { +export function match(mod: Module | undefined, type : CommandType) : boolean { return mod !== undefined && (mod.type & type) != 0; } export function filterTap( - cmdType: T, - tap: (mod: ModuleDefs[T]) => Awaitable + cmdType : T, + tap: (mod : ModuleDefs[T]) => Awaitable ) { - return (src: Observable) => - new Observable(subscriber => { - return src.subscribe({ + return (src : Observable) => + new Observable( subscriber => { + return src.subscribe({ next(modul) { - if (match(modul, cmdType)) { - const asModT = modul; - tap(asModT); - subscriber.next(asModT); + if(match(modul, cmdType)) { + const asModT = modul; + tap(asModT); + subscriber.next(asModT); } else { - if (modul === undefined) { - return throwError(() => SernError.UNDEFINED_MODULE); - } - return throwError(() => SernError.MISMATCH_MODULE_TYPE); + if (modul === undefined) { + return throwError(() => SernError.UNDEFINED_MODULE); + } + return throwError(() => SernError.MISMATCH_MODULE_TYPE); } }, - error: (e) => subscriber.error(e), + error: (e) => subscriber.error(e), complete: () => subscriber.complete() }); }); -} + } -export function ignoreNonBot(prefix: string) { - return (src: Observable) => +export function ignoreNonBot(prefix : string) { + return (src : Observable) => new Observable(subscriber => { - return src.subscribe({ - next(m) { - const passAll = [ - !isFromDM, - !isFromBot, - (m: Message) => - m.content - .slice(0, prefix.length) - .localeCompare(prefix, - undefined, { sensitivity: 'accent' } - ) === 0 - ].every(fn => fn(m)); + return src.subscribe({ + next(m) { + const passAll = [ + isNotFromDM, + isNotFromBot, + (m : Message) => + m.content + .slice(0,prefix.length) + .localeCompare(prefix, + undefined, { sensitivity : 'accent' } + ) === 0 + ].every( fn => fn(m)); - if (passAll) { - subscriber.next(m); - } - }, - error: (e) => subscriber.error(e), - complete: () => subscriber.complete() + if (passAll) { + subscriber.next(m); + } + }, + error: (e) => subscriber.error(e), + complete: () => subscriber.complete() }); - }); + }); } diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 2593cbec..b389f944 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -1,62 +1,61 @@ +import { first, from, fromEvent } from 'rxjs'; +import { basename } from 'path'; +import * as Files from '../utilities/readFile'; import type Wrapper from '../structures/wrapper'; import type { Module } from '../structures/structxports'; import type { HandlerCallback, ModuleHandlers, ModuleStates, ModuleType } from '../structures/modules/commands/moduleHandler'; - -import * as Files from '../utilities/readFile'; -import { first, from, fromEvent } from 'rxjs'; -import { basename } from 'path'; import { CommandType } from '../sern'; -export const onReady = (wrapper: Wrapper) => { +export const onReady = ( wrapper : Wrapper ) => { const { client, init, commands } = wrapper; fromEvent(client, 'ready') - .pipe(first()) - .subscribe(() => { - init?.(wrapper); - Files.buildData(commands) - .then(createCommandCache); - }) + .pipe(first()) + .subscribe(() => { + init?.( wrapper ); + Files.buildData( commands ) + .then( createCommandCache ); + }) }; // Refactor : ? Possibly repetitive and verbose. -const handler = (name: string) => -({ - [CommandType.TEXT]: mod => { - mod.alias.forEach(a => Files.Alias.set(a, mod)); - Files.Commands.set(name, mod); - }, - [CommandType.SLASH]: mod => { - Files.Commands.set(name, mod); - }, - [CommandType.BOTH]: mod => { - Files.Commands.set(name, mod); - mod.alias.forEach(a => Files.Alias.set(a, mod)); - }, - [CommandType.MENU_USER]: mod => { - Files.ContextMenuUser.set(name, mod); - }, - [CommandType.MENU_MSG]: mod => { - Files.ContextMenuMsg.set(name, mod); - }, - [CommandType.BUTTON]: mod => { - Files.Buttons.set(name, mod); - }, - [CommandType.MENU_SELECT]: mod => { - Files.SelectMenus.set(name, mod); - } +const handler = ( name : string ) => + ({ + [CommandType.TEXT] : mod => { + mod.alias.forEach ( a => Files.Alias.set(a,mod)); + Files.Commands.set( name, mod ); + }, + [CommandType.SLASH]: mod => { + Files.Commands.set( name , mod); + }, + [CommandType.BOTH] : mod => { + Files.Commands.set ( name, mod); + mod.alias.forEach (a => Files.Alias.set(a, mod)); + }, + [CommandType.MENU_USER] : mod => { + Files.ContextMenuUser.set ( name, mod ); + }, + [CommandType.MENU_MSG] : mod => { + Files.ContextMenuMsg.set (name, mod ); + }, + [CommandType.BUTTON] : mod => { + Files.Buttons.set(name, mod); + }, + [CommandType.MENU_SELECT] : mod => { + Files.SelectMenus.set(name, mod); + } -} as ModuleHandlers); + } as ModuleHandlers); -const registerModules = (name: string, mod: ModuleStates[T]) => - (>handler(name)[mod.type])(mod); +const registerModules = (name : string, mod : ModuleStates[T]) => + (> handler(name)[mod.type])(mod); -function setCommands({ mod, absPath }: { mod: Module, absPath: string }) { - const name = mod.name ?? Files.fmtFileName(basename(absPath)); - registerModules(name, mod); +function setCommands ( { mod, absPath } : { mod : Module, absPath : string } ) { + const name = mod.name ?? Files.fmtFileName(basename(absPath)); + registerModules(name, mod); } -function createCommandCache( - arr: { mod: Module, absPath: string }[] -) { - from(arr).subscribe(setCommands); +function createCommandCache( + arr: {mod: Module, absPath: string}[] + ) { + from(arr).subscribe ( setCommands ); } diff --git a/src/handler/logger.ts b/src/handler/logger.ts index 25901d71..aff768d1 100644 --- a/src/handler/logger.ts +++ b/src/handler/logger.ts @@ -1,34 +1,34 @@ + export enum sEvent { - GLOBAL_SLASH, - LOCAL_SLASH, - MISUSE_CMD, - CRASH, - TEXT_CMD, - DM, + GLOBAL_SLASH, + LOCAL_SLASH, + MISUSE_CMD, + DM, + CRASH, + TEXT_CMD, } export default class Logger { - public clear() { - console.clear(); - } + public clear() { + console.clear(); + } - public log(e: T, guildId: string, message: string) { - // TODO: Add colored logging - console.log(`[${new Date().toISOString()}] [${sEvent[e]}] @ ${guildId} :: ${message}`); - } + public log(e: T, guildId: string, message: string) { + // add colored logging? + console.log(`[${new Date().toISOString()}] [${sEvent[e]}] @ ${guildId} :: ${message}`); + } - /** - * Utilizes console.table() to print out memory usage of current process. - * Optional at startup. - */ - - public tableRam() { - console.table( - Object.entries(process.memoryUsage()) - .map(([k, v]: [string, number]) => { - return { [k]: `${(((Math.round(v) / 1024 / 1024) * 100) / 100).toFixed(2)} MBs` }; - }) - .reduce((r, c) => Object.assign(r, c), {}), - ); - } + /** + * Utilizes console.table() to print out memory usage of current process. + * Optional at startup. + */ + public tableRam() { + console.table( + Object.entries(process.memoryUsage()) + .map(([k, v]: [string, number]) => { + return { [k]: `${(((Math.round(v) / 1024 / 1024) * 100) / 100).toFixed(2)} MBs` }; + }) + .reduce((r, c) => Object.assign(r, c), {}), + ); + } } diff --git a/src/handler/sern.ts b/src/handler/sern.ts index 1d7e560d..c9ed8ad7 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -1,41 +1,45 @@ -import type { DiscordEvent, } from '../types/handler'; -import type { Client } from 'discord.js'; -import type Wrapper from './structures/wrapper'; +import type { + DiscordEvent, +} from '../types/handler'; + +import type { + Client, +} from 'discord.js'; +import type Wrapper from './structures/wrapper'; import { fromEvent } from 'rxjs'; import { SernError } from './structures/errors'; import { onReady } from './events/readyEvent'; import { onMessageCreate } from './events/messageEvent'; import { onInteractionCreate } from './events/interactionCreate'; -export function init(wrapper: Wrapper) { - const { events, client } = wrapper; - if (events !== undefined) eventObserver(client, events); - - onReady(wrapper); - onMessageCreate(wrapper); - onInteractionCreate(wrapper); +export function init( wrapper : Wrapper ) { + const { events, client } = wrapper; + if (events !== undefined) eventObserver(client, events); + onReady( wrapper ); + onMessageCreate( wrapper ); + onInteractionCreate ( wrapper ); } -function eventObserver(client: Client, events: DiscordEvent[]) { - events.forEach(([event, cb]) => { - if (event === 'ready') throw Error(SernError.RESERVED_EVENT); - fromEvent(client, event, cb).subscribe(); +function eventObserver(client: Client, events: DiscordEvent[] ) { + events.forEach( ( [event, cb] ) => { + if (event === 'ready') throw Error(SernError.RESERVED_EVENT); + fromEvent(client, event, cb).subscribe(); }); } + /** * @enum { number }; */ - export enum CommandType { - TEXT = 0b000001, - SLASH = 0b000010, - MENU_USER = 0b000100, - MENU_MSG = 0b001000, - BUTTON = 0b010000, - MENU_SELECT = 0b100000, - BOTH = 0b000011, - ANY = 0b111111, + TEXT = 0b000001, + SLASH = 0b000010, + MENU_USER = 0b000100, + MENU_MSG = 0b001000, + BUTTON = 0b010000, + MENU_SELECT= 0b100000, + BOTH = 0b000011, + ANY = 0b111111 } diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index fdbe7057..b95ae3ee 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -1,108 +1,121 @@ import type { - Awaitable, - ChatInputCommandInteraction, - Guild, - GuildMember, - Message, - Snowflake, - TextBasedChannel, - User, + Awaitable, + ChatInputCommandInteraction, + Guild, + GuildMember, + Message, + Snowflake, + TextBasedChannel, + User } from 'discord.js'; import { None, Option, Some } from 'ts-results'; import type { Nullish } from '../../types/handler'; - -function firstSome(...args: Option[]): Nullish { - for (const op of args) { - if (op.some) return op.val; - } - return null; +function firstSome(...args : Option[]) : Nullish { + for ( const op of args ) { + if (op.some) return op.val; + } + return null; } - export default class Context { - private constructor( - private oMsg: Option = None, - private oInterac: Option = None, - ) { - this.oMsg = oMsg; - this.oInterac = oInterac; - } - static wrap(wrappable: ChatInputCommandInteraction | Message): Context { - if ('token' in wrappable) { - return new Context(None, Some(wrappable)); + + private constructor( + private oMsg: Option = None, + private oInterac: Option = None + ) { + this.oMsg = oMsg; + this.oInterac = oInterac; + } + static wrap( + wrappable: ChatInputCommandInteraction|Message + ) : Context { + if ( 'token' in wrappable ) { + return new Context( None, Some(wrappable)); + } + return new Context(Some(wrappable), None); + } + public isEmpty() { + return this.oMsg.none && this.oInterac.none; + } + public get message() { + return this.oMsg.unwrap(); + } + public get interaction() { + return this.oInterac.unwrap(); } - return new Context(Some(wrappable), None); - } - public isEmpty() { - return this.oMsg.none && this.oInterac.none; - } - public get message() { - return this.oMsg.unwrap(); - } - public get interaction() { - return this.oInterac.unwrap(); - } - public get id(): Snowflake { - return firstSome( - this.oInterac.map((i) => i.id), - this.oMsg.map((m) => m.id), - )!; - } - public get channel(): Nullish { - return firstSome( - this.oMsg.map((m) => m.channel), - this.oInterac.map((i) => i.channel), - ); - } - public get user(): User { - return firstSome( - this.oMsg.map((m) => m.author), - this.oInterac.map((i) => i.user), - )!; - } - public get createdTimestamp(): number { - return firstSome( - this.oMsg.map((m) => m.createdTimestamp), - this.oInterac.map((i) => i.createdTimestamp), - )!; - } + public get id() : Snowflake { + return firstSome( + this.oInterac.map( i => i.id), + this.oMsg.map(m => m.id) + )!; + } + public get channel() : Nullish { + return firstSome( + this.oMsg.map(m => m.channel), + this.oInterac.map(i => i.channel) + ); + } + public get user(): User { + return firstSome( + this.oMsg.map(m => m.author), + this.oInterac.map(i => i.user) + )!; + } + public get createdTimestamp() : number { + return firstSome( + this.oMsg.map(m => m.createdTimestamp), + this.oInterac.map(i => i.createdTimestamp) + )!; + } - public get guild(): Guild { - return firstSome( - this.oMsg.map((m) => m.guild!), - this.oInterac.map((i) => i.guild), - )!; - } - public get guildId(): Snowflake { - return firstSome( - this.oMsg.map((m) => m.guildId), - this.oInterac.map((i) => i.guildId), - )!; - } - public get member(): Nullish { - return firstSome( - this.oMsg.andThen((m) => Some(m.member!)), - this.oInterac.andThen((i) => (i.inCachedGuild() ? Some(i.member) : None)), - ); - } - /* - * Returns the underlying Context but allows for doing other operations - */ - public onInteraction(onInteraction: (interaction: ChatInputCommandInteraction) => Awaitable): Context { - this.oInterac.map(onInteraction); - return this; - } - public onMessage(onMessage: (message: Message) => Awaitable): Context { - this.oMsg.map(onMessage); - return this; - } - public takeInteractionValue(extract: (interaction: ChatInputCommandInteraction) => T): Nullish { - if (this.oInterac.none) return null; - return extract(this.oInterac.val); - } - public takeMessageValue(extract: (message: Message) => T): Nullish { - if (this.oMsg.none) return null; - return extract(this.oMsg.val); - } + public get guild() : Guild { + return firstSome( + this.oMsg.map(m => m.guild!), + this.oInterac.map(i => i.guild) + )!; + } + public get guildId() : Snowflake { + return firstSome( + this.oMsg.map(m => m.guildId), + this.oInterac.map(i => i.guildId) + )!; + } + public get member() : Nullish { + return firstSome( + this.oMsg.andThen(m => Some(m.member!)), + this.oInterac.andThen(i => i.inCachedGuild() ? Some(i.member) : None) + ); + } + /* + * Returns the underlying Context but allows for doing other operations + */ + public onInteraction( + onInteraction : ( interaction : ChatInputCommandInteraction ) => Awaitable, + ): Context { + this.oInterac.map(onInteraction); + return this; + } + public onMessage( + onMessage : ( message : Message ) => Awaitable + ): Context { + this.oMsg.map( onMessage ); + return this; + } + public takeInteractionValue( + extract : (interaction : ChatInputCommandInteraction) => T + ): Nullish { + if(this.oInterac.none) return null; + return extract(this.oInterac.val); + } + public takeMessageValue( + extract : (message: Message) => T + ): Nullish { + if(this.oMsg.none) return null; + return extract(this.oMsg.val); + } + } + + + diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index 3a6c2559..c29128ea 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -1,7 +1,7 @@ export enum SernError { - RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.', - NO_ALIAS = 'You cannot provide an array with elements to a slash command.', - NOT_VALID_MOD_TYPE = 'Detected an unknown module type', - UNDEFINED_MODULE = `A module could not be detected at`, - MISMATCH_MODULE_TYPE = `A module type mismatched with event emitted!`, + RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.', + NO_ALIAS = 'You cannot provide an array with elements to a slash command.', + NOT_VALID_MOD_TYPE = 'Detected an unknown module type', + UNDEFINED_MODULE = `A module could not be detected at`, + MISMATCH_MODULE_TYPE = `A module type mismatched with event emitted!` } diff --git a/src/handler/structures/modules/commands/module.ts b/src/handler/structures/modules/commands/module.ts index fe68227b..33147845 100644 --- a/src/handler/structures/modules/commands/module.ts +++ b/src/handler/structures/modules/commands/module.ts @@ -1,51 +1,45 @@ -import type { - ApplicationCommandOptionData, - Awaitable, - ButtonInteraction, - MessageContextMenuInteraction, - ContextMenuInteraction, - SelectMenuInteraction, -} from 'discord.js'; - +import type { ApplicationCommandOptionData, Awaitable, ButtonInteraction, ContextMenuCommandInteraction, MessageContextMenuCommandInteraction, SelectMenuInteraction } from 'discord.js'; import type { Override } from '../../../../types/handler'; import type { CommandType } from '../../../sern'; import type { BaseModule } from '../module'; -// Possible refactoring to interfaces and not types +//possible refactoring to interfaces and not types export type TextCommand = { - type: CommandType.TEXT; - alias: string[] | []; + type : CommandType.TEXT; + alias : string[] | [], } & BaseModule; export type SlashCommand = { - type: CommandType.SLASH; - options: ApplicationCommandOptionData[] | []; -} & BaseModule; + type : CommandType.SLASH; + options : ApplicationCommandOptionData[] | [], +} & BaseModule; export type BothCommand = { - type: CommandType.BOTH; - alias: string[] | []; - options: ApplicationCommandOptionData[] | []; + type : CommandType.BOTH; + alias : string[] | []; + options : ApplicationCommandOptionData[] | [], } & BaseModule; export type ContextMenuUser = { - type: CommandType.MENU_USER; -} & Override Awaitable }>; + type : CommandType.MENU_USER; +} & Override Awaitable }>; export type ContextMenuMsg = { - type: CommandType.MENU_MSG; -} & Override Awaitable }>; + type : CommandType.MENU_MSG; +} & Override Awaitable }>; export type ButtonCommand = { - type: CommandType.BUTTON; -} & Override Awaitable }>; + type : CommandType.BUTTON; +} & Override Awaitable }>; export type SelectMenuCommand = { - type: CommandType.MENU_SELECT; -} & Override Awaitable }>; + type : CommandType.MENU_SELECT; +} & Override Awaitable }>; + -export type Module = - | TextCommand - | SlashCommand - | BothCommand - | ContextMenuUser - | ContextMenuMsg - | ButtonCommand - | SelectMenuCommand; +export type Module = + TextCommand + | SlashCommand + | BothCommand + | ContextMenuUser + | ContextMenuMsg + | ButtonCommand + | SelectMenuCommand; + diff --git a/src/handler/structures/modules/commands/moduleHandler.ts b/src/handler/structures/modules/commands/moduleHandler.ts index 5814d7c5..caf1e018 100644 --- a/src/handler/structures/modules/commands/moduleHandler.ts +++ b/src/handler/structures/modules/commands/moduleHandler.ts @@ -1,31 +1,24 @@ import { CommandType } from '../../../sern'; -import type { - TextCommand, - BothCommand, - ButtonCommand, - SlashCommand, - ContextMenuMsg, - ContextMenuUser, - SelectMenuCommand, -} from './module'; +import type { TextCommand, BothCommand, ButtonCommand, SlashCommand, ContextMenuMsg, ContextMenuUser, SelectMenuCommand } from './module'; +//https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union -// https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union // Explicit Module Definitions for mapping export type ModuleDefs = { - [CommandType.TEXT]: TextCommand; - [CommandType.SLASH]: SlashCommand; - [CommandType.BOTH]: BothCommand; - [CommandType.MENU_MSG]: ContextMenuMsg; - [CommandType.MENU_USER]: ContextMenuUser; - [CommandType.BUTTON]: ButtonCommand; - [CommandType.MENU_SELECT]: SelectMenuCommand; -}; + [CommandType.TEXT] : TextCommand, + [CommandType.SLASH] : SlashCommand, + [CommandType.BOTH] : BothCommand, + [CommandType.MENU_MSG] : ContextMenuMsg, + [CommandType.MENU_USER] : ContextMenuUser, + [CommandType.BUTTON] : ButtonCommand, + [CommandType.MENU_SELECT] : SelectMenuCommand +} //Keys of ModuleDefs export type ModuleType = keyof ModuleDefs; // The keys mapped to a constructed union with its type -export type ModuleStates = { [K in ModuleType]: { type: K } & ModuleDefs[K] }; -// A handler callback that is called on each ModuleDef -export type HandlerCallback = (params: ModuleStates[K]) => unknown; +export type ModuleStates = { [ K in ModuleType ] : { type : K } & ModuleDefs[K] }; +// A handler callback that is called on each ModuleDef +export type HandlerCallback = ( params : ModuleStates[K] ) => unknown; //An object that acts as the mapped object to handler -export type ModuleHandlers = { [K in ModuleType]: HandlerCallback }; +export type ModuleHandlers = { [K in ModuleType] : HandlerCallback }; + diff --git a/src/handler/structures/modules/module.ts b/src/handler/structures/modules/module.ts index f127114c..606ef62e 100644 --- a/src/handler/structures/modules/module.ts +++ b/src/handler/structures/modules/module.ts @@ -1,9 +1,13 @@ -import type { Awaitable, ChatInputCommandInteraction, Interaction } from 'discord.js'; -import type { Args } from '../../..'; -import type Context from '../context'; +import type { Awaitable, ChatInputCommandInteraction, Interaction } from "discord.js"; +import type { Args } from "../../.."; +import type Context from "../context"; export interface BaseModule { - name?: string; - description: string; - execute: (ctx: Context, args: Args) => Awaitable; + name? : string; + description : string; + execute: (ctx: Context, args: Args) => Awaitable; } + + + + diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index 46a6f3c4..1ae69979 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -2,4 +2,11 @@ import Context from './context'; import type { SlashCommand, TextCommand, BothCommand, Module } from '../structures/modules/commands/module'; import type Wrapper from './wrapper'; -export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper }; +export { + Context, + SlashCommand, + TextCommand, + BothCommand, + Module, + Wrapper +}; diff --git a/src/handler/structures/wrapper.ts b/src/handler/structures/wrapper.ts index b0ad93bf..54168d1e 100644 --- a/src/handler/structures/wrapper.ts +++ b/src/handler/structures/wrapper.ts @@ -4,19 +4,18 @@ import type { DiscordEvent } from '../../types/handler'; /** * An object to be passed into Sern.Handler constructor. * @typedef {object} Wrapper - * @property {readonly Client} Client - * @property {readonly string} The default prefix - * @property {readonly string} Commands - * @prop {(handler: Handler) => void)} init - * @prop { readonly DiscordEvent[] } Events + * @property {readonly Client} client + * @property {readonly string} defaultPrefix + * @property {readonly string} commands + * @prop {(handler : Handler) => void)} init + * @prop { readonly DiscordEvent[] } events */ - interface Wrapper { - readonly client: Client; - readonly defaultPrefix: string; - readonly commands: string; - init?: (handler: Wrapper) => void; - readonly events?: DiscordEvent[]; + readonly client: Client; + readonly defaultPrefix: string; + readonly commands: string; + init?: (handler: Wrapper) => void; + readonly events? : DiscordEvent[]; } export default Wrapper; diff --git a/src/handler/utilities/markup.ts b/src/handler/utilities/markup.ts index 89ebe2a9..4dba8275 100644 --- a/src/handler/utilities/markup.ts +++ b/src/handler/utilities/markup.ts @@ -1,796 +1,730 @@ -/** - * An enumeration of all the valid Discord timestamp styles. - */ - -export enum TimestampStyles { - BOTH_LONG = 'F', - BOTH_SHORT = 'f', - DATE_LONG = 'D', - DATE_SHORT = 'd', - RELATIVE = 'R', - TIME_LONG = 'T', - TIME_SHORT = 't' -} - -/** - * Utility to cut messages by bytes and not characters - */ - -export function trueSlice(text: string, limit?: number): string { - if (limit) { - return new TextDecoder().decode( - new TextEncoder().encode(text).slice(0, limit) - ); - } - return text; -} - -/** - * Object that holds all the Discord Markup identifiers. - */ - -export const Strings = { - BOLD: '**', - CODEBLOCK: '```', - CODESTRING: '`', - CODESTRING_DOUBLE: '``', - ESCAPE: '\\', - ITALICS: '_', - SPOILER: '||', - STRIKE: '~~', - UNDERLINE: '__' -}; - -/** - * Object that maps all the Discord Markup identifiers to their respective RegExp matchers. - */ - -const Regexes = { - [Strings.BOLD]: /\*\*/g, - [Strings.CODEBLOCK]: new RegExp(Strings.CODEBLOCK, 'g'), - [Strings.CODESTRING]: new RegExp(Strings.CODESTRING, 'g'), - [Strings.ESCAPE]: /\\/g, - [Strings.ITALICS]: /(_|\*)/g, - [Strings.SPOILER]: /\|\|/g, - [Strings.STRIKE]: new RegExp(Strings.STRIKE, 'g'), - [Strings.UNDERLINE]: new RegExp(Strings.UNDERLINE, 'g'), - - EVERYONE: /@(everyone|here)/g, - LINK: /\]\(/g, - MENTION: /<@([!&]?[0-9]{16,21})>/g, - MENTION_HARDCORE: /@/g, - URL: /\)/g -}; - -/** - * Object to replace Discord Markup identifiers with when escaping strings. - */ - -const Replacements = { - [Strings.BOLD]: '\\*\\*', - [Strings.CODEBLOCK]: '``\u200b`', - [Strings.CODESTRING]: '\\`', - [Strings.ESCAPE]: '\\\\', - [Strings.ITALICS]: '\\$1', - [Strings.SPOILER]: '\\|\\|', - [Strings.STRIKE]: '\\~\\~', - [Strings.UNDERLINE]: '\\_\\_', - MENTION: '\u200b' -}; - -/** - * Utility to escape some Discord Markup Identifier - */ - -function EscapeBasic(raw: string, key: keyof typeof Strings) { - return raw.replace(Regexes[key], Replacements[key]); -} - -/** - * Object of all the Escape functions used to apply mixed markup - */ - -export const Escape: Record< - keyof typeof Strings, - typeof EscapeBasic -> = (Object.keys(Strings) as Array).reduce( - (p, v) => Object.assign(p, { [v]: (raw: string) => EscapeBasic(raw, v) }), - {} as Record -); - -/** - * String formatting for freezing Discord timestamps that have the Relative (R) flag - */ - -const FrozenTimestampStyles: Record = { - [TimestampStyles.BOTH_LONG]: - '{day}, {month} {date}, {year} {hour}:{minute} {meridian}', - [TimestampStyles.BOTH_SHORT]: - '{month} {date}, {year} {hour}:{minute} {meridian}', - [TimestampStyles.DATE_LONG]: '{month} {date}, {year}', - [TimestampStyles.DATE_SHORT]: '{month_short}/{date}/{year}', - [TimestampStyles.RELATIVE]: '{relative}', - [TimestampStyles.TIME_LONG]: '{hour}:{minute}:{second} {meridian}', - [TimestampStyles.TIME_SHORT]: '{hour}:{minute} {meridian}' -}; - -/** - * Holds metadata and string conversions of a UNIX Timestamp - */ - -interface Timestamp { - raw: number; - month: string; - month_short: string; - date: string; - year: string; - second: string; - meridian: 'AM' | 'PM'; - hour: string; - minute: string; - day: string; - relative: string; -} - -/** - * Converter for number to Days of the Week - */ - -const Days: Record = { - 0: 'Sunday', - 1: 'Monday', - 2: 'Tuesday', - 3: 'Wednesday', - 4: 'Thursday', - 5: 'Friday', - 6: 'Saturday' -}; - -/** - * Converter for number to Months of the Year - */ - -const Months: Record = { - 0: 'January', - 1: 'February', - 2: 'March', - 3: 'April', - 4: 'May', - 5: 'June', - 6: 'July', - 7: 'August', - 8: 'September', - 9: 'October', - 10: 'November', - 11: 'December' -}; - -/** - * Converts a Date object to a Timestamp object - */ - -function formatDate(date: Date): Timestamp { - return { - relative: toTimeString(date.getTime(), TimestampUnits), - raw: date.getTime(), - date: date - .getDate() - .toString() - .padStart(2, '0'), - day: Days[date.getDay()], - hour: date - .getHours() - .toString() - .padStart(2, '0'), - meridian: date.getHours() > 12 ? 'PM' : 'AM', - minute: date - .getMinutes() - .toString() - .padStart(2, '0'), - month: Months[date.getMonth()], - month_short: (date.getMonth() + 1).toString().padStart(2, '0'), - second: date - .getSeconds() - .toString() - .padStart(2, '0'), - year: date.getFullYear().toString() + /** + * An enumeration of all the valid Discord timestamp styles. + */ + export enum TimestampStyles { + BOTH_LONG = 'F', + BOTH_SHORT = 'f', + DATE_LONG = 'D', + DATE_SHORT = 'd', + RELATIVE = 'R', + TIME_LONG = 'T', + TIME_SHORT = 't' + } + /** + * Utility to cut messages by bytes and not characters + */ + export function trueSlice(text: string, limit?: number): string { + if (limit) { + return new TextDecoder().decode( + new TextEncoder().encode(text).slice(0, limit) + ); + } + return text; + } + /** + * Object that holds all the Discord Markup identifiers. + */ + export const Strings = { + BOLD: '**', + CODEBLOCK: '```', + CODESTRING: '`', + CODESTRING_DOUBLE: '``', + ESCAPE: '\\', + ITALICS: '_', + SPOILER: '||', + STRIKE: '~~', + UNDERLINE: '__' }; -} - -/** - * Collectively multiplies bigints together - */ - -function multiplyLarge(...nums: Array): bigint { - return nums.map(BigInt).reduce((p, v) => (p *= v), 1n); -} - -/** - * Get the absolute value of a bigint - */ - -function bigintAbs(int: bigint) { - if (int < 0) return -int; - return int; -} - -/** - * Object of Units matched with their string representations. - */ - -const TimestampUnits = { - myriad: multiplyLarge(10, 10, 10, 10, 12, 4, 7, 24, 60, 1000), - millenium: multiplyLarge(10, 10, 10, 12, 4, 7, 24, 60, 1000), - century: multiplyLarge(10, 10, 12, 4, 7, 24, 60, 1000), - decade: multiplyLarge(10, 12, 4, 7, 24, 60, 60, 1000), - year: multiplyLarge(12, 4, 7, 24, 60, 60, 1000), - month: multiplyLarge(4, 7, 24, 60, 60, 1000), - week: multiplyLarge(7, 24, 60, 60, 1000), - day: multiplyLarge(24, 60, 60, 1000), - hour: multiplyLarge(60, 60, 1000), - minute: multiplyLarge(60, 1000), - second: multiplyLarge(1000), - millisecond: multiplyLarge(1) -}; - -/** - * Utility type. Used to force Object.entries to allow non-strings. - */ - -type ObjectEntries = Array<[K, V]>; - -/** - * Converts a UNIX timestamp to a Relative String - */ - -function toTimeString( - unix: bigint | number, - units: Record, - isFromNow = false, - limit?: number -) { - if (typeof unix === 'number') unix = BigInt(unix); + /** + * Object that maps all the Discord Markup identifiers to their respective RegExp matchers. + */ + const Regexes = { + [Strings.BOLD]: /\*\*/g, + [Strings.CODEBLOCK]: new RegExp(Strings.CODEBLOCK, 'g'), + [Strings.CODESTRING]: new RegExp(Strings.CODESTRING, 'g'), + [Strings.ESCAPE]: /\\/g, + [Strings.ITALICS]: /(_|\*)/g, + [Strings.SPOILER]: /\|\|/g, + [Strings.STRIKE]: new RegExp(Strings.STRIKE, 'g'), + [Strings.UNDERLINE]: new RegExp(Strings.UNDERLINE, 'g'), + EVERYONE: /@(everyone|here)/g, + LINK: /\]\(/g, + MENTION: /<@([!&]?[0-9]{16,21})>/g, + MENTION_HARDCORE: /@/g, + URL: /\)/g + }; + /** + * Object to replace Discord Markup identifiers with when escaping strings. + */ + const Replacements = { + [Strings.BOLD]: '\\*\\*', + [Strings.CODEBLOCK]: '``\u200b`', + [Strings.CODESTRING]: '\\`', + [Strings.ESCAPE]: '\\\\', + [Strings.ITALICS]: '\\$1', + [Strings.SPOILER]: '\\|\\|', + [Strings.STRIKE]: '\\~\\~', + [Strings.UNDERLINE]: '\\_\\_', + MENTION: '\u200b' + }; + /** + * Utility to escape some Discord Markup Identifier + */ + function EscapeBasic(raw: string, key: keyof typeof Strings) { + return raw.replace(Regexes[key], Replacements[key]); + } + /** + * Object of all the Escape functions used to apply mixed markup + */ + export const Escape: Record< + keyof typeof Strings, + typeof EscapeBasic + > = (Object.keys(Strings) as Array).reduce( + (p, v) => Object.assign(p, { [v]: (raw: string) => EscapeBasic(raw, v) }), + {} as Record + ); + /** + * String formatting for freezing Discord timestamps that have the Relative (R) flag + */ + const FrozenTimestampStyles: Record = { + [TimestampStyles.BOTH_LONG]: + '{day}, {month} {date}, {year} {hour}:{minute} {meridian}', + [TimestampStyles.BOTH_SHORT]: + '{month} {date}, {year} {hour}:{minute} {meridian}', + [TimestampStyles.DATE_LONG]: '{month} {date}, {year}', + [TimestampStyles.DATE_SHORT]: '{month_short}/{date}/{year}', + [TimestampStyles.RELATIVE]: '{relative}', + [TimestampStyles.TIME_LONG]: '{hour}:{minute}:{second} {meridian}', + [TimestampStyles.TIME_SHORT]: '{hour}:{minute} {meridian}' + }; + /** + * Holds metadata and string conversions of a UNIX Timestamp + */ + interface Timestamp { + raw: number; + month: string; + month_short: string; + date: string; + year: string; + second: string; + meridian: 'AM' | 'PM'; + hour: string; + minute: string; + day: string; + relative: string; + } + /** + * Converter for number to Days of the Week + */ + const Days: Record = { + 0: 'Sunday', + 1: 'Monday', + 2: 'Tuesday', + 3: 'Wednesday', + 4: 'Thursday', + 5: 'Friday', + 6: 'Saturday' + }; + /** + * Converter for number to Months of the Year + */ + const Months: Record = { + 0: 'January', + 1: 'February', + 2: 'March', + 3: 'April', + 4: 'May', + 5: 'June', + 6: 'July', + 7: 'August', + 8: 'September', + 9: 'October', + 10: 'November', + 11: 'December' + }; + /** + * Converts a Date object to a Timestamp object + */ + function formatDate(date: Date): Timestamp { + return { + relative: toTimeString(date.getTime(), TimestampUnits), + raw: date.getTime(), + date: date + .getDate() + .toString() + .padStart(2, '0'), + day: Days[date.getDay()], + hour: date + .getHours() + .toString() + .padStart(2, '0'), + meridian: date.getHours() > 12 ? 'PM' : 'AM', + minute: date + .getMinutes() + .toString() + .padStart(2, '0'), + month: Months[date.getMonth()], + month_short: (date.getMonth() + 1).toString().padStart(2, '0'), + second: date + .getSeconds() + .toString() + .padStart(2, '0'), + year: date.getFullYear().toString() + }; + } + /** + * Collectively multiplies bigints together + */ + function multiplyLarge(...nums: Array): bigint { + return nums.map(BigInt).reduce((p, v) => (p *= v), 1n); + } + /** + * Get the absolute value of a bigint + */ + function bigintAbs(int: bigint) { + if (int < 0) return -int; + return int; + } + /** + * Object of Units matched with their string representations. + */ + const TimestampUnits = { + myriad: multiplyLarge(10, 10, 10, 10, 12, 4, 7, 24, 60, 1000), + millenium: multiplyLarge(10, 10, 10, 12, 4, 7, 24, 60, 1000), + century: multiplyLarge(10, 10, 12, 4, 7, 24, 60, 1000), + decade: multiplyLarge(10, 12, 4, 7, 24, 60, 60, 1000), + year: multiplyLarge(12, 4, 7, 24, 60, 60, 1000), + month: multiplyLarge(4, 7, 24, 60, 60, 1000), + week: multiplyLarge(7, 24, 60, 60, 1000), + day: multiplyLarge(24, 60, 60, 1000), + hour: multiplyLarge(60, 60, 1000), + minute: multiplyLarge(60, 1000), + second: multiplyLarge(1000), + millisecond: multiplyLarge(1) + }; + /** + * Utility type. Used to force Object.entries to allow non-strings. + */ + type ObjectEntries = Array<[K, V]>; + /** + * Converts a UNIX timestamp to a Relative String + */ + function toTimeString( + unix: bigint | number, + units: Record, + isFromNow = false, + limit?: number + ) { + if (typeof unix === 'number') unix = BigInt(unix); - if (isFromNow) unix = bigintAbs(unix - BigInt(Date.now())); - if (unix === 0n) return '0 milliseconds'; + if (isFromNow) unix = bigintAbs(unix - BigInt(Date.now())); + if (unix === 0n) return '0 milliseconds'; - const formatted: Map = new Map(); - const unitList: ObjectEntries = Object.entries(units) as any; - let run = unix; + const formatted: Map = new Map(); + const unitList: ObjectEntries = Object.entries(units) as any; + let run = unix; - for (const [unit, value] of unitList) { - if (run < value) continue; - const runs = run / value + 1n; + for (const [unit, value] of unitList) { + if (run < value) continue; + const runs = run / value + 1n; - for (let loop = 0; loop <= runs; loop++) { - if (run < value) break; - const item = formatted.get(unit); + for (let loop = 0; loop <= runs; loop++) { + if (run < value) break; + const item = formatted.get(unit); - if (item) formatted.set(unit, item + 1); - else formatted.set(unit, 1); + if (item) formatted.set(unit, item + 1); + else formatted.set(unit, 1); - run -= value; + run -= value; + } } - } - let returned: Array = []; - for (const [key, value] of formatted) { - const unit = key + (value === 1 ? '' : 's'); - returned.push(`${value} ${unit}`); - } - if (limit !== undefined) { - returned = returned.slice(0, limit); - } - return returned.join(', '); -} - -/** - * Freezes a UNIT timestamp into some time string based on the Timestamp Style - */ - -function freezeUnix({ unix, style }:{ unix: number; style: TimestampStyles; }): string { - const date = new Date(unix); - const timestamp = formatDate(date); - let ret = FrozenTimestampStyles[style]; - for (const [key, value] of Object.entries(timestamp)) { - ret = ret.split(`{${key}}`).join(value); - } - return ret; -} - -/** - * Instanced Class for formatting strings into their Markup variants - */ - -class FormatInner { - public raw: string; - public static: typeof FormatInner = FormatInner; - constructor(raw: string | FormatInner) { - if (raw instanceof FormatInner) { - raw = raw.raw; + let returned: Array = []; + for (const [key, value] of formatted) { + const unit = key + (value === 1 ? '' : 's'); + returned.push(`${value} ${unit}`); } - this.raw = raw; - } - toString() { - return this.raw; - } - valueOf() { - return this.raw; - } - italics() { - return this.build('ITALICS', this.raw); - } - bold() { - return this.build('BOLD', this.raw); - } - codestring() { - const useDouble = this.raw.includes(Strings.CODESTRING); - if (useDouble) { - return this.codestringDouble(); + if (limit !== undefined) { + returned = returned.slice(0, limit); } - return this.codestringSingle(); - } - codestringDouble() { - return this.build('CODESTRING_DOUBLE', this.raw); - } - codestringSingle() { - return this.build('CODESTRING', this.raw); - } - codeblock(language?: string) { - let full = ''; - if (language) { - full += language + '\n'; + return returned.join(', '); + } + /** + * Freezes a UNIT timestamp into some time string based on the Timestamp Style + */ + function freezeUnix(unix: number, style: TimestampStyles) { + const date = new Date(unix); + const timestamp = formatDate(date); + let ret = FrozenTimestampStyles[style]; + for (const [key, value] of Object.entries(timestamp)) { + ret = ret.split(`{${key}}`).join(value); } - full += this.raw; - return this.build('CODEBLOCK', full); - } - spoiler() { - return this.build('SPOILER', this.raw); - } - strike() { - return this.build('STRIKE', this.raw); - } - underline() { - return this.build('UNDERLINE', this.raw); - } - - build(key: keyof typeof Strings, w: string) { - const escaped = Escape[key](w, key); - const ret = this.static.wrap(escaped, Strings[key]); - return new this.static(ret); - } - static wrap(raw: string, what: string) { - return `${what}${raw}${what}`; - } -} - -/** - * Formats strings into their Markup Variants - */ - -export class Format extends FormatInner { - static bold(text: string) { - return new this(text).bold(); - } - static build(text: string, key: keyof typeof Strings) { - return new this(text).build(key, text); - } - static codeblock(text: string, language?: string) { - return new this(text).codeblock(language); - } - static codestring(text: string) { - return new this(text).codestring(); - } - static codestringSingle(text: string) { - return new this(text).codestringSingle(); - } - static codestringDouble(text: string) { - return new this(text).codestringDouble(); - } - static italics(text: string) { - return new this(text).italics(); - } - static spoiler(text: string) { - return new this(text).spoiler(); - } - static strike(text: string) { - return new this(text).strike(); - } - static underline(text: string) { - return new this(text).underline(); - } - static timestamp( - unix: number | Date | string, - format: TimestampStyles = TimestampStyles.BOTH_SHORT, - isSeconds = false - ) { - if (typeof unix === 'string') unix = Number(unix); - if (unix instanceof Date) unix = unix.getTime(); - - if (!isSeconds) { - unix /= 1000; + return ret; + } + /** + * Instanced Class for formatting strings into their Markup variants + */ + class FormatInner { + public raw: string; + public static: typeof FormatInner = FormatInner; + constructor(raw: string | FormatInner) { + if (raw instanceof FormatInner) { + raw = raw.raw; + } + this.raw = raw; + } + toString() { + return this.raw; + } + valueOf() { + return this.raw; + } + italics() { + return this.build('ITALICS', this.raw); + } + bold() { + return this.build('BOLD', this.raw); + } + codestring() { + const useDouble = this.raw.includes(Strings.CODESTRING); + if (useDouble) { + return this.codestringDouble(); + } + return this.codestringSingle(); + } + codestringDouble() { + return this.build('CODESTRING_DOUBLE', this.raw); + } + codestringSingle() { + return this.build('CODESTRING', this.raw); + } + codeblock(language?: string) { + let full = ''; + if (language) { + full += language + '\n'; + } + full += this.raw; + return this.build('CODEBLOCK', full); + } + spoiler() { + return this.build('SPOILER', this.raw); + } + strike() { + return this.build('STRIKE', this.raw); + } + underline() { + return this.build('UNDERLINE', this.raw); } - unix = Math.floor(unix); - return new this(``); - } - static date( - unix: number | Date | string, - format: TimestampStyles = TimestampStyles.BOTH_SHORT, - isSeconds = false - ) { - if (typeof unix === 'string') unix = Number(unix); - if (unix instanceof Date) unix = unix.getTime(); - if (isSeconds) { - unix *= 1000; + build(key: keyof typeof Strings, w: string) { + const escaped = Escape[key](w, key); + const ret = this.static.wrap(escaped, Strings[key]); + return new this.static(ret); + } + static wrap(raw: string, what: string) { + return `${what}${raw}${what}`; } - return new this(freezeUnix({ unix, style: format })); } - static link(text: string, url: string | URL) { - if (url instanceof URL) url = url.href; - return new this(`[${text}](${url})`); + /** + * Formats strings into their Markup Variants + */ + export class Format extends FormatInner { + static bold(text: string) { + return new this(text).bold(); + } + static build(text: string, key: keyof typeof Strings) { + return new this(text).build(key, text); + } + static codeblock(text: string, language?: string) { + return new this(text).codeblock(language); + } + static codestring(text: string) { + return new this(text).codestring(); + } + static codestringSingle(text: string) { + return new this(text).codestringSingle(); + } + static codestringDouble(text: string) { + return new this(text).codestringDouble(); + } + static italics(text: string) { + return new this(text).italics(); + } + static spoiler(text: string) { + return new this(text).spoiler(); + } + static strike(text: string) { + return new this(text).strike(); + } + static underline(text: string) { + return new this(text).underline(); + } + static timestamp( + unix: number | Date | string, + format: TimestampStyles = TimestampStyles.BOTH_SHORT, + isSeconds = false + ) { + if (typeof unix === 'string') unix = Number(unix); + if (unix instanceof Date) unix = unix.getTime(); + + if (!isSeconds) { + unix /= 1000; + } + unix = Math.floor(unix); + return new this(``); + } + static date( + unix: number | Date | string, + format: TimestampStyles = TimestampStyles.BOTH_SHORT, + isSeconds = false + ) { + if (typeof unix === 'string') unix = Number(unix); + if (unix instanceof Date) unix = unix.getTime(); + + if (isSeconds) { + unix *= 1000; + } + return new this(freezeUnix(unix, format)); + } + static link(text: string, url: string | URL) { + if (url instanceof URL) url = url.href; + return new this(`[${text}](${url})`); + } } -} - -/** - * Enumeration of names used in the Matching process - */ - -enum DiscordRegexNames { - EMOJI = 'EMOJI', - JUMP_CHANNEL = 'JUMP_CHANNEL', - JUMP_CHANNEL_MESSAGE = 'JUMP_CHANNEL_MESSAGE', - MENTION_CHANNEL = 'MENTION_CHANNEL', - MENTION_ROLE = 'MENTION_ROLE', - MENTION_USER = 'MENTION_USER', - TEXT_BOLD = 'TEXT_BOLD', - TEXT_CODEBLOCK = 'TEXT_CODEBLOCK', - TEXT_CODESTRING = 'TEXT_CODESTRING', - TEXT_ITALICS = 'TEXT_ITALICS', - TEXT_SNOWFLAKE = 'TEXT_SNOWFLAKE', - TEXT_SPOILER = 'TEXT_SPOILER', - TEXT_STRIKE = 'TEXT_STRIKE', - TEXT_UNDERLINE = 'TEXT_UNDERLINE', - TEXT_URL = 'TEXT_URL' -} - -/** - * Mapping of Matching Names to their respective Regular Expressions - */ - -export const DiscordRegex = { - [DiscordRegexNames.EMOJI]: //g, - [DiscordRegexNames.JUMP_CHANNEL]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)$/g, - [DiscordRegexNames.JUMP_CHANNEL_MESSAGE]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)\/(\d+)$/g, - [DiscordRegexNames.MENTION_CHANNEL]: /<#(\d+)>/g, - [DiscordRegexNames.MENTION_ROLE]: /<@&(\d+)>/g, - [DiscordRegexNames.MENTION_USER]: /<@(!?)(\d+)>/g, - [DiscordRegexNames.TEXT_BOLD]: /\*\*([\s\S]+?)\*\*/g, - [DiscordRegexNames.TEXT_CODEBLOCK]: /```(([a-z0-9-]+?)\n+)?\n*([^]+?)\n*```/gi, - [DiscordRegexNames.TEXT_CODESTRING]: /`([\s\S]+?)`/g, - [DiscordRegexNames.TEXT_ITALICS]: /_([\s\S]+?)_|\*([\s\S]+?)\*/g, - [DiscordRegexNames.TEXT_SNOWFLAKE]: /(\d+)/g, - [DiscordRegexNames.TEXT_SPOILER]: /\|\|([\s\S]+?)\|\|/g, - [DiscordRegexNames.TEXT_STRIKE]: /~~([\s\S]+?)~~(?!_)/g, - [DiscordRegexNames.TEXT_UNDERLINE]: /__([\s\S]+?)__/g, - [DiscordRegexNames.TEXT_URL]: /((?:https?):\/\/[^\s<]+[^<.,:;''\]\s])/g -}; - -/** - * Object containing all the data from some Matching sequence - */ - -export interface DiscordRegexMatch { - animated?: boolean; - channelId?: string; - guildId?: string; - id?: string; - language?: string; - matched: string; - mentionType?: string; - messageId?: string; - name?: string; - text?: string; - species: DiscordRegexNames; -} - -/** - * The result of a matched string. - */ - -export interface DiscordRegexPayload { - match: { - regex: RegExp; - type: string; + /** + * Enumeration of names used in the Matching process + */ + enum DiscordRegexNames { + EMOJI = 'EMOJI', + JUMP_CHANNEL = 'JUMP_CHANNEL', + JUMP_CHANNEL_MESSAGE = 'JUMP_CHANNEL_MESSAGE', + MENTION_CHANNEL = 'MENTION_CHANNEL', + MENTION_ROLE = 'MENTION_ROLE', + MENTION_USER = 'MENTION_USER', + TEXT_BOLD = 'TEXT_BOLD', + TEXT_CODEBLOCK = 'TEXT_CODEBLOCK', + TEXT_CODESTRING = 'TEXT_CODESTRING', + TEXT_ITALICS = 'TEXT_ITALICS', + TEXT_SNOWFLAKE = 'TEXT_SNOWFLAKE', + TEXT_SPOILER = 'TEXT_SPOILER', + TEXT_STRIKE = 'TEXT_STRIKE', + TEXT_UNDERLINE = 'TEXT_UNDERLINE', + TEXT_URL = 'TEXT_URL' + } + /** + * Mapping of Matching Names to their respective Regular Expressions + */ + export const DiscordRegex = { + [DiscordRegexNames.EMOJI]: //g, + [DiscordRegexNames.JUMP_CHANNEL]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)$/g, + [DiscordRegexNames.JUMP_CHANNEL_MESSAGE]: /^(?:https?):\/\/(?:(?:(?:canary|ptb)\.)?(?:discord|discordapp)\.com\/channels\/)(\@me|\d+)\/(\d+)\/(\d+)$/g, + [DiscordRegexNames.MENTION_CHANNEL]: /<#(\d+)>/g, + [DiscordRegexNames.MENTION_ROLE]: /<@&(\d+)>/g, + [DiscordRegexNames.MENTION_USER]: /<@(!?)(\d+)>/g, + [DiscordRegexNames.TEXT_BOLD]: /\*\*([\s\S]+?)\*\*/g, + [DiscordRegexNames.TEXT_CODEBLOCK]: /```(([a-z0-9-]+?)\n+)?\n*([^]+?)\n*```/gi, + [DiscordRegexNames.TEXT_CODESTRING]: /`([\s\S]+?)`/g, + [DiscordRegexNames.TEXT_ITALICS]: /_([\s\S]+?)_|\*([\s\S]+?)\*/g, + [DiscordRegexNames.TEXT_SNOWFLAKE]: /(\d+)/g, + [DiscordRegexNames.TEXT_SPOILER]: /\|\|([\s\S]+?)\|\|/g, + [DiscordRegexNames.TEXT_STRIKE]: /~~([\s\S]+?)~~(?!_)/g, + [DiscordRegexNames.TEXT_UNDERLINE]: /__([\s\S]+?)__/g, + [DiscordRegexNames.TEXT_URL]: /((?:https?):\/\/[^\s<]+[^<.,:;"'\]\s])/g }; - matches: Array; -} - -export interface EmojiMatch extends DiscordRegexMatch { - name: string; - id: string; - animated: boolean; - species: DiscordRegexNames.EMOJI; -} - -export interface JumpMatch extends DiscordRegexMatch { - guildId: string; - species: - | DiscordRegexNames.JUMP_CHANNEL - | DiscordRegexNames.JUMP_CHANNEL_MESSAGE; -} - -export interface JumpChannelMatch extends JumpMatch { - channelId: string; - species: DiscordRegexNames.JUMP_CHANNEL; -} - -export interface JumpChannelMessageMatch extends JumpMatch { - channelId: string; - messageId: string; - species: DiscordRegexNames.JUMP_CHANNEL_MESSAGE; -} - -export interface MentionableMatch extends DiscordRegexMatch { - id: string; - species: - | DiscordRegexNames.MENTION_CHANNEL - | DiscordRegexNames.MENTION_ROLE - | DiscordRegexNames.MENTION_USER; -} - -export interface MentionChannelMatch extends MentionableMatch { - species: DiscordRegexNames.MENTION_CHANNEL; -} - -export interface MentionRoleMatch extends MentionableMatch { - species: DiscordRegexNames.MENTION_ROLE; -} - -export interface MentionUserMatch extends MentionableMatch { - mentionType: string; - species: DiscordRegexNames.MENTION_USER; -} - -export interface TextMatch extends DiscordRegexMatch { - text: string; - species: - | DiscordRegexNames.TEXT_BOLD - | DiscordRegexNames.TEXT_CODEBLOCK - | DiscordRegexNames.TEXT_CODESTRING - | DiscordRegexNames.TEXT_ITALICS - | DiscordRegexNames.TEXT_SNOWFLAKE - | DiscordRegexNames.TEXT_SPOILER - | DiscordRegexNames.TEXT_STRIKE - | DiscordRegexNames.TEXT_UNDERLINE - | DiscordRegexNames.TEXT_URL; -} - -export interface TextCodeblockMatch extends TextMatch { - language: string; - species: DiscordRegexNames.TEXT_CODEBLOCK; -} - -export interface TextBoldMatch extends TextMatch { - species: DiscordRegexNames.TEXT_BOLD; -} - -export interface TextCodestringMatch extends TextMatch { - species: DiscordRegexNames.TEXT_CODESTRING; -} - -export interface TextItalicsMatch extends TextMatch { - species: DiscordRegexNames.TEXT_ITALICS; -} - -export interface TextSnowflakeMatch extends TextMatch { - species: DiscordRegexNames.TEXT_SNOWFLAKE; -} - -export interface TextSpoilerMatch extends TextMatch { - species: DiscordRegexNames.TEXT_SPOILER; -} - -export interface TextStrikeMatch extends TextMatch { - species: DiscordRegexNames.TEXT_STRIKE; -} - -export interface TextUnderlineMatch extends TextMatch { - species: DiscordRegexNames.TEXT_UNDERLINE; -} - -export interface TextUrlMatch extends TextMatch { - species: DiscordRegexNames.TEXT_URL; -} - -class MatchInner { - public raw: string; - public static: typeof MatchInner = MatchInner; - - constructor(raw: string) { - this.raw = raw; - } - - emoji(): DiscordRegexPayload { - return this.match(DiscordRegexNames.EMOJI); - } - jumpChannel(): DiscordRegexPayload { - return this.match(DiscordRegexNames.JUMP_CHANNEL); - } - jumpChannelMessage(): DiscordRegexPayload { - return this.match(DiscordRegexNames.JUMP_CHANNEL_MESSAGE); - } - mentionChannel(): DiscordRegexPayload { - return this.match(DiscordRegexNames.MENTION_CHANNEL); - } - mentionRole(): DiscordRegexPayload { - return this.match(DiscordRegexNames.MENTION_ROLE); - } - mentionUser(): DiscordRegexPayload { - return this.match(DiscordRegexNames.MENTION_USER); - } - codeblock(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_CODEBLOCK); - } - bold(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_BOLD); - } - codestring(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_CODESTRING); - } - italics(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_ITALICS); - } - snowflake(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_SNOWFLAKE); - } - spoiler(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_SPOILER); - } - strike(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_STRIKE); - } - underline(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_UNDERLINE); - } - url(): DiscordRegexPayload { - return this.match(DiscordRegexNames.TEXT_URL); - } - - match( - type: DiscordRegexNames, - onlyFirst = false - ): DiscordRegexPayload { - const regex = DiscordRegex[type]; - if (regex === undefined) { - throw new global.Error(`Unknown regex type: ${type}`); - } - regex.lastIndex = 0; - - const payload: DiscordRegexPayload = { - match: { regex, type }, - matches: [] + /** + * Object containing all the data from some Matching sequence + */ + export interface DiscordRegexMatch { + animated?: boolean; + channelId?: string; + guildId?: string; + id?: string; + language?: string; + matched: string; + mentionType?: string; + messageId?: string; + name?: string; + text?: string; + species: DiscordRegexNames; + } + /** + * The result of a matched string. + */ + export interface DiscordRegexPayload { + match: { + regex: RegExp; + type: string; }; + matches: Array; + } + export interface EmojiMatch extends DiscordRegexMatch { + name: string; + id: string; + animated: boolean; + species: DiscordRegexNames.EMOJI; + } + export interface JumpMatch extends DiscordRegexMatch { + guildId: string; + species: + | DiscordRegexNames.JUMP_CHANNEL + | DiscordRegexNames.JUMP_CHANNEL_MESSAGE; + } + export interface JumpChannelMatch extends JumpMatch { + channelId: string; + species: DiscordRegexNames.JUMP_CHANNEL; + } + export interface JumpChannelMessageMatch extends JumpMatch { + channelId: string; + messageId: string; + species: DiscordRegexNames.JUMP_CHANNEL_MESSAGE; + } + export interface MentionableMatch extends DiscordRegexMatch { + id: string; + species: + | DiscordRegexNames.MENTION_CHANNEL + | DiscordRegexNames.MENTION_ROLE + | DiscordRegexNames.MENTION_USER; + } + export interface MentionChannelMatch extends MentionableMatch { + species: DiscordRegexNames.MENTION_CHANNEL; + } + export interface MentionRoleMatch extends MentionableMatch { + species: DiscordRegexNames.MENTION_ROLE; + } + export interface MentionUserMatch extends MentionableMatch { + mentionType: string; + species: DiscordRegexNames.MENTION_USER; + } + export interface TextMatch extends DiscordRegexMatch { + text: string; + species: + | DiscordRegexNames.TEXT_BOLD + | DiscordRegexNames.TEXT_CODEBLOCK + | DiscordRegexNames.TEXT_CODESTRING + | DiscordRegexNames.TEXT_ITALICS + | DiscordRegexNames.TEXT_SNOWFLAKE + | DiscordRegexNames.TEXT_SPOILER + | DiscordRegexNames.TEXT_STRIKE + | DiscordRegexNames.TEXT_UNDERLINE + | DiscordRegexNames.TEXT_URL; + } + export interface TextCodeblockMatch extends TextMatch { + language: string; + species: DiscordRegexNames.TEXT_CODEBLOCK; + } + export interface TextBoldMatch extends TextMatch { + species: DiscordRegexNames.TEXT_BOLD; + } + export interface TextCodestringMatch extends TextMatch { + species: DiscordRegexNames.TEXT_CODESTRING; + } + export interface TextItalicsMatch extends TextMatch { + species: DiscordRegexNames.TEXT_ITALICS; + } + export interface TextSnowflakeMatch extends TextMatch { + species: DiscordRegexNames.TEXT_SNOWFLAKE; + } + export interface TextSpoilerMatch extends TextMatch { + species: DiscordRegexNames.TEXT_SPOILER; + } + export interface TextStrikeMatch extends TextMatch { + species: DiscordRegexNames.TEXT_STRIKE; + } + export interface TextUnderlineMatch extends TextMatch { + species: DiscordRegexNames.TEXT_UNDERLINE; + } + export interface TextUrlMatch extends TextMatch { + species: DiscordRegexNames.TEXT_URL; + } + + class MatchInner { + public raw: string; + public static: typeof MatchInner = MatchInner; + + constructor(raw: string) { + this.raw = raw; + } - let match: RegExpExecArray | null = null; - while ((match = regex.exec(this.raw))) { - const result: DiscordRegexMatch = { matched: match[0], species: type }; - switch (type) { - case DiscordRegexNames.EMOJI: - { - result.name = match[1] as string; - result.id = match[2] as string; - result.animated = this.raw.startsWith(' { + return this.match(DiscordRegexNames.EMOJI); + } + jumpChannel(): DiscordRegexPayload { + return this.match(DiscordRegexNames.JUMP_CHANNEL); + } + jumpChannelMessage(): DiscordRegexPayload { + return this.match(DiscordRegexNames.JUMP_CHANNEL_MESSAGE); + } + mentionChannel(): DiscordRegexPayload { + return this.match(DiscordRegexNames.MENTION_CHANNEL); + } + mentionRole(): DiscordRegexPayload { + return this.match(DiscordRegexNames.MENTION_ROLE); + } + mentionUser(): DiscordRegexPayload { + return this.match(DiscordRegexNames.MENTION_USER); + } + codeblock(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_CODEBLOCK); + } + bold(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_BOLD); + } + codestring(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_CODESTRING); + } + italics(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_ITALICS); + } + snowflake(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_SNOWFLAKE); + } + spoiler(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_SPOILER); + } + strike(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_STRIKE); + } + underline(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_UNDERLINE); + } + url(): DiscordRegexPayload { + return this.match(DiscordRegexNames.TEXT_URL); + } + + match( + type: DiscordRegexNames, + onlyFirst = false + ): DiscordRegexPayload { + const regex = DiscordRegex[type]; + if (regex === undefined) { + throw new global.Error(`Unknown regex type: ${type}`); + } + regex.lastIndex = 0; + + const payload: DiscordRegexPayload = { + match: { regex, type }, + matches: [] + }; + + let match: RegExpExecArray | null = null; + while ((match = regex.exec(this.raw))) { + const result: DiscordRegexMatch = { matched: match[0], species: type }; + switch (type) { + case DiscordRegexNames.EMOJI: + { + result.name = match[1] as string; + result.id = match[2] as string; + result.animated = this.raw.startsWith('(); export const ContextMenuMsg = new Map(); export const Commands = new Map(); @@ -12,7 +11,8 @@ export const Alias = new Map(); export const Buttons = new Map(); export const SelectMenus = new Map(); -// Thanks to @Townsy45 + +// Courtesy @Townsy45 function readPath(dir: string, arrayOfFiles: string[] = []): string[] { try { const files = readdirSync(dir); @@ -30,20 +30,20 @@ function readPath(dir: string, arrayOfFiles: string[] = []): string[] { export const fmtFileName = (n: string) => n.substring(0, n.length - 3); /** - * + * * @param {commandsDir} Relative path to commands directory * @returns {Promise<{ mod: Command; absPath: string; }[]>} data from command files */ -export async function buildData(commandDir: string): Promise< +export async function buildData(commandDir: string ): Promise< { mod: Module; absPath: string; }[] > { return Promise.all( - getCommands(commandDir).map(async (absPath) => { - const mod = (await import(absPath)).module; + getCommands(commandDir).map( async (absPath) => { + const mod = (await import(absPath)).module; if (mod === undefined) throw Error(`${SernError.UNDEFINED_MODULE} ${absPath}`); return { mod, absPath }; }), diff --git a/tests/functions.test.ts b/tests/functions.test.ts index 5ac007fa..e142bd28 100644 --- a/tests/functions.test.ts +++ b/tests/functions.test.ts @@ -1,13 +1,13 @@ -import { hasPrefix, fmt, isFromBot } from '../src/handler/utilities/messageHelpers'; - +import { hasPrefix, fmt, isNotFromBot } from '../src/handler/utilities/messageHelpers'; describe('FUNCTIONS', () => { - test('If hasPrefix is a function', () => { - expect(typeof hasPrefix).toBe('function'); - }); - test('if fmt is a function', () => { - expect(typeof fmt).toBe('function'); - }); - test('if isBot is a function', () => { - expect(typeof isFromBot).toBe('function'); - }); + test('If hasPrefix is a function', () => { + expect(typeof hasPrefix).toBe('function'); + }); + test('if fmt is a function', () => { + expect(typeof fmt).toBe('function'); + }); + test('if isBot is a function', () => { + expect(typeof isNotFromBot).toBe('function'); + }); + }); From 6106a78ac7b078c5472695bd505c327d2862caae Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 12 Apr 2022 23:16:14 +0300 Subject: [PATCH 004/128] style(style.css): Formatted main style file with tabwidth 2 --- docs/assets/style.css | 1558 ++++++++++++++++++++--------------------- 1 file changed, 779 insertions(+), 779 deletions(-) diff --git a/docs/assets/style.css b/docs/assets/style.css index a16ed029..0e048966 100644 --- a/docs/assets/style.css +++ b/docs/assets/style.css @@ -1,110 +1,55 @@ -@import url("./icons.css"); +@import url('./icons.css'); :root { - /* Light */ - --light-color-background: #fcfcfc; - --light-color-secondary-background: #fff; - --light-color-text: #222; - --light-color-text-aside: #707070; - --light-color-link: #4da6ff; - --light-color-menu-divider: #eee; - --light-color-menu-divider-focus: #000; - --light-color-menu-label: #707070; - --light-color-panel: var(--light-color-secondary-background); - --light-color-panel-divider: #eee; - --light-color-comment-tag: #707070; - --light-color-comment-tag-text: #fff; - --light-color-ts: #9600ff; - --light-color-ts-interface: #647f1b; - --light-color-ts-enum: #937210; - --light-color-ts-class: #0672de; - --light-color-ts-private: #707070; - --light-color-toolbar: #fff; - --light-color-toolbar-text: #333; - --light-icon-filter: invert(0); - --light-external-icon: url("data:image/svg+xml;utf8,"); - - /* Dark */ - --dark-color-background: #36393f; - --dark-color-secondary-background: #2f3136; - --dark-color-text: #ffffff; - --dark-color-text-aside: #e6e4e4; - --dark-color-link: #00aff4; - --dark-color-menu-divider: #eee; - --dark-color-menu-divider-focus: #000; - --dark-color-menu-label: #707070; - --dark-color-panel: var(--dark-color-secondary-background); - --dark-color-panel-divider: #818181; - --dark-color-comment-tag: #dcddde; - --dark-color-comment-tag-text: #2f3136; - --dark-color-ts: #c97dff; - --dark-color-ts-interface: #9cbe3c; - --dark-color-ts-enum: #d6ab29; - --dark-color-ts-class: #3695f3; - --dark-color-ts-private: #e2e2e2; - --dark-color-toolbar: #34373c; - --dark-color-toolbar-text: #ffffff; - --dark-icon-filter: invert(1); - --dark-external-icon: url("data:image/svg+xml;utf8,"); + /* Light */ + --light-color-background: #fcfcfc; + --light-color-secondary-background: #fff; + --light-color-text: #222; + --light-color-text-aside: #707070; + --light-color-link: #4da6ff; + --light-color-menu-divider: #eee; + --light-color-menu-divider-focus: #000; + --light-color-menu-label: #707070; + --light-color-panel: var(--light-color-secondary-background); + --light-color-panel-divider: #eee; + --light-color-comment-tag: #707070; + --light-color-comment-tag-text: #fff; + --light-color-ts: #9600ff; + --light-color-ts-interface: #647f1b; + --light-color-ts-enum: #937210; + --light-color-ts-class: #0672de; + --light-color-ts-private: #707070; + --light-color-toolbar: #fff; + --light-color-toolbar-text: #333; + --light-icon-filter: invert(0); + --light-external-icon: url("data:image/svg+xml;utf8,"); + + /* Dark */ + --dark-color-background: #36393f; + --dark-color-secondary-background: #2f3136; + --dark-color-text: #ffffff; + --dark-color-text-aside: #e6e4e4; + --dark-color-link: #00aff4; + --dark-color-menu-divider: #eee; + --dark-color-menu-divider-focus: #000; + --dark-color-menu-label: #707070; + --dark-color-panel: var(--dark-color-secondary-background); + --dark-color-panel-divider: #818181; + --dark-color-comment-tag: #dcddde; + --dark-color-comment-tag-text: #2f3136; + --dark-color-ts: #c97dff; + --dark-color-ts-interface: #9cbe3c; + --dark-color-ts-enum: #d6ab29; + --dark-color-ts-class: #3695f3; + --dark-color-ts-private: #e2e2e2; + --dark-color-toolbar: #34373c; + --dark-color-toolbar-text: #ffffff; + --dark-icon-filter: invert(1); + --dark-external-icon: url("data:image/svg+xml;utf8,"); } @media (prefers-color-scheme: light) { - :root { - --color-background: var(--light-color-background); - --color-secondary-background: var(--light-color-secondary-background); - --color-text: var(--light-color-text); - --color-text-aside: var(--light-color-text-aside); - --color-link: var(--light-color-link); - --color-menu-divider: var(--light-color-menu-divider); - --color-menu-divider-focus: var(--light-color-menu-divider-focus); - --color-menu-label: var(--light-color-menu-label); - --color-panel: var(--light-color-panel); - --color-panel-divider: var(--light-color-panel-divider); - --color-comment-tag: var(--light-color-comment-tag); - --color-comment-tag-text: var(--light-color-comment-tag-text); - --color-ts: var(--light-color-ts); - --color-ts-interface: var(--light-color-ts-interface); - --color-ts-enum: var(--light-color-ts-enum); - --color-ts-class: var(--light-color-ts-class); - --color-ts-private: var(--light-color-ts-private); - --color-toolbar: var(--light-color-toolbar); - --color-toolbar-text: var(--light-color-toolbar-text); - --icon-filter: var(--light-icon-filter); - --external-icon: var(--light-external-icon); - } -} - -@media (prefers-color-scheme: dark) { - :root { - --color-background: var(--dark-color-background); - --color-secondary-background: var(--dark-color-secondary-background); - --color-text: var(--dark-color-text); - --color-text-aside: var(--dark-color-text-aside); - --color-link: var(--dark-color-link); - --color-menu-divider: var(--dark-color-menu-divider); - --color-menu-divider-focus: var(--dark-color-menu-divider-focus); - --color-menu-label: var(--dark-color-menu-label); - --color-panel: var(--dark-color-panel); - --color-panel-divider: var(--dark-color-panel-divider); - --color-comment-tag: var(--dark-color-comment-tag); - --color-comment-tag-text: var(--dark-color-comment-tag-text); - --color-ts: var(--dark-color-ts); - --color-ts-interface: var(--dark-color-ts-interface); - --color-ts-enum: var(--dark-color-ts-enum); - --color-ts-class: var(--dark-color-ts-class); - --color-ts-private: var(--dark-color-ts-private); - --color-toolbar: var(--dark-color-toolbar); - --color-toolbar-text: var(--dark-color-toolbar-text); - --icon-filter: var(--dark-icon-filter); - --external-icon: var(--dark-external-icon); - } -} - -body { - margin: 0; -} - -body.light { + :root { --color-background: var(--light-color-background); --color-secondary-background: var(--light-color-secondary-background); --color-text: var(--light-color-text); @@ -126,9 +71,11 @@ body.light { --color-toolbar-text: var(--light-color-toolbar-text); --icon-filter: var(--light-icon-filter); --external-icon: var(--light-external-icon); + } } -body.dark { +@media (prefers-color-scheme: dark) { + :root { --color-background: var(--dark-color-background); --color-secondary-background: var(--dark-color-secondary-background); --color-text: var(--dark-color-text); @@ -150,6 +97,59 @@ body.dark { --color-toolbar-text: var(--dark-color-toolbar-text); --icon-filter: var(--dark-icon-filter); --external-icon: var(--dark-external-icon); + } +} + +body { + margin: 0; +} + +body.light { + --color-background: var(--light-color-background); + --color-secondary-background: var(--light-color-secondary-background); + --color-text: var(--light-color-text); + --color-text-aside: var(--light-color-text-aside); + --color-link: var(--light-color-link); + --color-menu-divider: var(--light-color-menu-divider); + --color-menu-divider-focus: var(--light-color-menu-divider-focus); + --color-menu-label: var(--light-color-menu-label); + --color-panel: var(--light-color-panel); + --color-panel-divider: var(--light-color-panel-divider); + --color-comment-tag: var(--light-color-comment-tag); + --color-comment-tag-text: var(--light-color-comment-tag-text); + --color-ts: var(--light-color-ts); + --color-ts-interface: var(--light-color-ts-interface); + --color-ts-enum: var(--light-color-ts-enum); + --color-ts-class: var(--light-color-ts-class); + --color-ts-private: var(--light-color-ts-private); + --color-toolbar: var(--light-color-toolbar); + --color-toolbar-text: var(--light-color-toolbar-text); + --icon-filter: var(--light-icon-filter); + --external-icon: var(--light-external-icon); +} + +body.dark { + --color-background: var(--dark-color-background); + --color-secondary-background: var(--dark-color-secondary-background); + --color-text: var(--dark-color-text); + --color-text-aside: var(--dark-color-text-aside); + --color-link: var(--dark-color-link); + --color-menu-divider: var(--dark-color-menu-divider); + --color-menu-divider-focus: var(--dark-color-menu-divider-focus); + --color-menu-label: var(--dark-color-menu-label); + --color-panel: var(--dark-color-panel); + --color-panel-divider: var(--dark-color-panel-divider); + --color-comment-tag: var(--dark-color-comment-tag); + --color-comment-tag-text: var(--dark-color-comment-tag-text); + --color-ts: var(--dark-color-ts); + --color-ts-interface: var(--dark-color-ts-interface); + --color-ts-enum: var(--dark-color-ts-enum); + --color-ts-class: var(--dark-color-ts-class); + --color-ts-private: var(--dark-color-ts-private); + --color-toolbar: var(--dark-color-toolbar); + --color-toolbar-text: var(--dark-color-toolbar-text); + --icon-filter: var(--dark-icon-filter); + --external-icon: var(--dark-external-icon); } h1, @@ -158,97 +158,97 @@ h3, h4, h5, h6 { - line-height: 1.2; + line-height: 1.2; } h1 { - font-size: 2em; - margin: 0.67em 0; + font-size: 2em; + margin: 0.67em 0; } h2 { - font-size: 1.5em; - margin: 0.83em 0; + font-size: 1.5em; + margin: 0.83em 0; } h3 { - font-size: 1.17em; - margin: 1em 0; + font-size: 1.17em; + margin: 1em 0; } h4, .tsd-index-panel h3 { - font-size: 1em; - margin: 1.33em 0; + font-size: 1em; + margin: 1.33em 0; } h5 { - font-size: 0.83em; - margin: 1.67em 0; + font-size: 0.83em; + margin: 1.67em 0; } h6 { - font-size: 0.67em; - margin: 2.33em 0; + font-size: 0.67em; + margin: 2.33em 0; } pre { - white-space: pre; - white-space: pre-wrap; - word-wrap: break-word; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; } dl, menu, ol, ul { - margin: 1em 0; + margin: 1em 0; } dd { - margin: 0 0 0 40px; + margin: 0 0 0 40px; } .container { - max-width: 1200px; - margin: 0 auto; - padding: 0 40px; + max-width: 1200px; + margin: 0 auto; + padding: 0 40px; } @media (max-width: 640px) { - .container { - padding: 0 20px; - } + .container { + padding: 0 20px; + } } .container-main { - padding-bottom: 200px; + padding-bottom: 200px; } .row { - display: flex; - position: relative; - margin: 0 -10px; + display: flex; + position: relative; + margin: 0 -10px; } .row:after { - visibility: hidden; - display: block; - content: ""; - clear: both; - height: 0; + visibility: hidden; + display: block; + content: ''; + clear: both; + height: 0; } .col-4, .col-8 { - box-sizing: border-box; - float: left; - padding: 0 10px; + box-sizing: border-box; + float: left; + padding: 0 10px; } .col-4 { - width: 33.3333333333%; + width: 33.3333333333%; } .col-8 { - width: 66.6666666667%; + width: 66.6666666667%; } ul.tsd-descriptions > li > :first-child, @@ -263,7 +263,7 @@ ul.tsd-descriptions > li > :first-child > :first-child > :first-child, .tsd-panel > :first-child > :first-child > :first-child, .col-8 > :first-child > :first-child > :first-child, .col-4 > :first-child > :first-child > :first-child { - margin-top: 0; + margin-top: 0; } ul.tsd-descriptions > li > :last-child, .tsd-panel > :last-child, @@ -277,1137 +277,1137 @@ ul.tsd-descriptions > li > :last-child > :last-child > :last-child, .tsd-panel > :last-child > :last-child > :last-child, .col-8 > :last-child > :last-child > :last-child, .col-4 > :last-child > :last-child > :last-child { - margin-bottom: 0; + margin-bottom: 0; } @keyframes fade-in { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } @keyframes fade-out { - from { - opacity: 1; - visibility: visible; - } - to { - opacity: 0; - } + from { + opacity: 1; + visibility: visible; + } + to { + opacity: 0; + } } @keyframes fade-in-delayed { - 0% { - opacity: 0; - } - 33% { - opacity: 0; - } - 100% { - opacity: 1; - } + 0% { + opacity: 0; + } + 33% { + opacity: 0; + } + 100% { + opacity: 1; + } } @keyframes fade-out-delayed { - 0% { - opacity: 1; - visibility: visible; - } - 66% { - opacity: 0; - } - 100% { - opacity: 0; - } + 0% { + opacity: 1; + visibility: visible; + } + 66% { + opacity: 0; + } + 100% { + opacity: 0; + } } @keyframes shift-to-left { - from { - transform: translate(0, 0); - } - to { - transform: translate(-25%, 0); - } + from { + transform: translate(0, 0); + } + to { + transform: translate(-25%, 0); + } } @keyframes unshift-to-left { - from { - transform: translate(-25%, 0); - } - to { - transform: translate(0, 0); - } + from { + transform: translate(-25%, 0); + } + to { + transform: translate(0, 0); + } } @keyframes pop-in-from-right { - from { - transform: translate(100%, 0); - } - to { - transform: translate(0, 0); - } + from { + transform: translate(100%, 0); + } + to { + transform: translate(0, 0); + } } @keyframes pop-out-to-right { - from { - transform: translate(0, 0); - visibility: visible; - } - to { - transform: translate(100%, 0); - } + from { + transform: translate(0, 0); + visibility: visible; + } + to { + transform: translate(100%, 0); + } } body { - background: var(--color-background); - font-family: "Segoe UI", sans-serif; - font-size: 16px; - color: var(--color-text); + background: var(--color-background); + font-family: 'Segoe UI', sans-serif; + font-size: 16px; + color: var(--color-text); } a { - color: var(--color-link); - text-decoration: none; + color: var(--color-link); + text-decoration: none; } a:hover { - text-decoration: underline; + text-decoration: underline; } -a.external[target="_blank"] { - background-image: var(--external-icon); - background-position: top 3px right; - background-repeat: no-repeat; - padding-right: 13px; +a.external[target='_blank'] { + background-image: var(--external-icon); + background-position: top 3px right; + background-repeat: no-repeat; + padding-right: 13px; } code, pre { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - padding: 0.2em; - margin: 0; - font-size: 14px; + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; + padding: 0.2em; + margin: 0; + font-size: 14px; } pre { - padding: 10px; + padding: 10px; } pre code { - padding: 0; - font-size: 100%; + padding: 0; + font-size: 100%; } blockquote { - margin: 1em 0; - padding-left: 1em; - border-left: 4px solid gray; + margin: 1em 0; + padding-left: 1em; + border-left: 4px solid gray; } .tsd-typography { - line-height: 1.333em; + line-height: 1.333em; } .tsd-typography ul { - list-style: square; - padding: 0 0 0 20px; - margin: 0; + list-style: square; + padding: 0 0 0 20px; + margin: 0; } .tsd-typography h4, .tsd-typography .tsd-index-panel h3, .tsd-index-panel .tsd-typography h3, .tsd-typography h5, .tsd-typography h6 { - font-size: 1em; - margin: 0; + font-size: 1em; + margin: 0; } .tsd-typography h5, .tsd-typography h6 { - font-weight: normal; + font-weight: normal; } .tsd-typography p, .tsd-typography ul, .tsd-typography ol { - margin: 1em 0; + margin: 1em 0; } @media (min-width: 901px) and (max-width: 1024px) { - html .col-content { - width: 72%; - } - html .col-menu { - width: 28%; - } - html .tsd-navigation { - padding-left: 10px; - } + html .col-content { + width: 72%; + } + html .col-menu { + width: 28%; + } + html .tsd-navigation { + padding-left: 10px; + } } @media (max-width: 900px) { - html .col-content { - float: none; - width: 100%; - } - html .col-menu { - position: fixed !important; - overflow: auto; - -webkit-overflow-scrolling: touch; - z-index: 1024; - top: 0 !important; - bottom: 0 !important; - left: auto !important; - right: 0 !important; - width: 100%; - padding: 20px 20px 0 0; - max-width: 450px; - visibility: hidden; - background-color: var(--color-panel); - transform: translate(100%, 0); - } - html .col-menu > *:last-child { - padding-bottom: 20px; - } - html .overlay { - content: ""; - display: block; - position: fixed; - z-index: 1023; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: rgba(0, 0, 0, 0.75); - visibility: hidden; - } - - .to-has-menu .overlay { - animation: fade-in 0.4s; - } - - .to-has-menu :is(header, footer, .col-content) { - animation: shift-to-left 0.4s; - } - - .to-has-menu .col-menu { - animation: pop-in-from-right 0.4s; - } - - .from-has-menu .overlay { - animation: fade-out 0.4s; - } - - .from-has-menu :is(header, footer, .col-content) { - animation: unshift-to-left 0.4s; - } - - .from-has-menu .col-menu { - animation: pop-out-to-right 0.4s; - } - - .has-menu body { - overflow: hidden; - } - .has-menu .overlay { - visibility: visible; - } - .has-menu :is(header, footer, .col-content) { - transform: translate(-25%, 0); - } - .has-menu .col-menu { - visibility: visible; - transform: translate(0, 0); - display: grid; - grid-template-rows: auto 1fr; - max-height: 100vh; - } - .has-menu .tsd-navigation { - max-height: 100%; - } + html .col-content { + float: none; + width: 100%; + } + html .col-menu { + position: fixed !important; + overflow: auto; + -webkit-overflow-scrolling: touch; + z-index: 1024; + top: 0 !important; + bottom: 0 !important; + left: auto !important; + right: 0 !important; + width: 100%; + padding: 20px 20px 0 0; + max-width: 450px; + visibility: hidden; + background-color: var(--color-panel); + transform: translate(100%, 0); + } + html .col-menu > *:last-child { + padding-bottom: 20px; + } + html .overlay { + content: ''; + display: block; + position: fixed; + z-index: 1023; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.75); + visibility: hidden; + } + + .to-has-menu .overlay { + animation: fade-in 0.4s; + } + + .to-has-menu :is(header, footer, .col-content) { + animation: shift-to-left 0.4s; + } + + .to-has-menu .col-menu { + animation: pop-in-from-right 0.4s; + } + + .from-has-menu .overlay { + animation: fade-out 0.4s; + } + + .from-has-menu :is(header, footer, .col-content) { + animation: unshift-to-left 0.4s; + } + + .from-has-menu .col-menu { + animation: pop-out-to-right 0.4s; + } + + .has-menu body { + overflow: hidden; + } + .has-menu .overlay { + visibility: visible; + } + .has-menu :is(header, footer, .col-content) { + transform: translate(-25%, 0); + } + .has-menu .col-menu { + visibility: visible; + transform: translate(0, 0); + display: grid; + grid-template-rows: auto 1fr; + max-height: 100vh; + } + .has-menu .tsd-navigation { + max-height: 100%; + } } .tsd-page-title { - padding: 70px 0 20px 0; - margin: 0 0 40px 0; - background: var(--color-panel); - box-shadow: 0 0 5px rgba(0, 0, 0, 0.35); + padding: 70px 0 20px 0; + margin: 0 0 40px 0; + background: var(--color-panel); + box-shadow: 0 0 5px rgba(0, 0, 0, 0.35); } .tsd-page-title h1 { - margin: 0; + margin: 0; } .tsd-breadcrumb { - margin: 0; - padding: 0; - color: var(--color-text-aside); + margin: 0; + padding: 0; + color: var(--color-text-aside); } .tsd-breadcrumb a { - color: var(--color-text-aside); - text-decoration: none; + color: var(--color-text-aside); + text-decoration: none; } .tsd-breadcrumb a:hover { - text-decoration: underline; + text-decoration: underline; } .tsd-breadcrumb li { - display: inline; + display: inline; } .tsd-breadcrumb li:after { - content: " / "; + content: ' / '; } dl.tsd-comment-tags { - overflow: hidden; + overflow: hidden; } dl.tsd-comment-tags dt { - float: left; - padding: 1px 5px; - margin: 0 10px 0 0; - border-radius: 4px; - border: 1px solid var(--color-comment-tag); - color: var(--color-comment-tag); - font-size: 0.8em; - font-weight: normal; + float: left; + padding: 1px 5px; + margin: 0 10px 0 0; + border-radius: 4px; + border: 1px solid var(--color-comment-tag); + color: var(--color-comment-tag); + font-size: 0.8em; + font-weight: normal; } dl.tsd-comment-tags dd { - margin: 0 0 10px 0; + margin: 0 0 10px 0; } dl.tsd-comment-tags dd:before, dl.tsd-comment-tags dd:after { - display: table; - content: " "; + display: table; + content: ' '; } dl.tsd-comment-tags dd pre, dl.tsd-comment-tags dd:after { - clear: both; + clear: both; } dl.tsd-comment-tags p { - margin: 0; + margin: 0; } .tsd-panel.tsd-comment .lead { - font-size: 1.1em; - line-height: 1.333em; - margin-bottom: 2em; + font-size: 1.1em; + line-height: 1.333em; + margin-bottom: 2em; } .tsd-panel.tsd-comment .lead:last-child { - margin-bottom: 0; + margin-bottom: 0; } .toggle-protected .tsd-is-private { - display: none; + display: none; } .toggle-public .tsd-is-private, .toggle-public .tsd-is-protected, .toggle-public .tsd-is-private-protected { - display: none; + display: none; } .toggle-inherited .tsd-is-inherited { - display: none; + display: none; } .toggle-externals .tsd-is-external { - display: none; + display: none; } #tsd-filter { - position: relative; - display: inline-block; - height: 40px; - vertical-align: bottom; + position: relative; + display: inline-block; + height: 40px; + vertical-align: bottom; } .no-filter #tsd-filter { - display: none; + display: none; } #tsd-filter .tsd-filter-group { - display: inline-block; - height: 40px; - vertical-align: bottom; - white-space: nowrap; + display: inline-block; + height: 40px; + vertical-align: bottom; + white-space: nowrap; } #tsd-filter input { - display: none; + display: none; } @media (max-width: 900px) { - #tsd-filter .tsd-filter-group { - display: block; - position: absolute; - top: 40px; - right: 20px; - height: auto; - background-color: var(--color-panel); - visibility: hidden; - transform: translate(50%, 0); - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); - } - .has-options #tsd-filter .tsd-filter-group { - visibility: visible; - } - .to-has-options #tsd-filter .tsd-filter-group { - animation: fade-in 0.2s; - } - .from-has-options #tsd-filter .tsd-filter-group { - animation: fade-out 0.2s; - } - #tsd-filter label, - #tsd-filter .tsd-select { - display: block; - padding-right: 20px; - } + #tsd-filter .tsd-filter-group { + display: block; + position: absolute; + top: 40px; + right: 20px; + height: auto; + background-color: var(--color-panel); + visibility: hidden; + transform: translate(50%, 0); + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + } + .has-options #tsd-filter .tsd-filter-group { + visibility: visible; + } + .to-has-options #tsd-filter .tsd-filter-group { + animation: fade-in 0.2s; + } + .from-has-options #tsd-filter .tsd-filter-group { + animation: fade-out 0.2s; + } + #tsd-filter label, + #tsd-filter .tsd-select { + display: block; + padding-right: 20px; + } } footer { - border-top: 1px solid var(--color-panel-divider); - background-color: var(--color-panel); + border-top: 1px solid var(--color-panel-divider); + background-color: var(--color-panel); } footer:after { - content: ""; - display: table; + content: ''; + display: table; } footer.with-border-bottom { - border-bottom: 1px solid var(--color-panel-divider); + border-bottom: 1px solid var(--color-panel-divider); } footer .tsd-legend-group { - font-size: 0; + font-size: 0; } footer .tsd-legend { - display: inline-block; - width: 25%; - padding: 0; - font-size: 16px; - list-style: none; - line-height: 1.333em; - vertical-align: top; + display: inline-block; + width: 25%; + padding: 0; + font-size: 16px; + list-style: none; + line-height: 1.333em; + vertical-align: top; } @media (max-width: 900px) { - footer .tsd-legend { - width: 50%; - } + footer .tsd-legend { + width: 50%; + } } .tsd-hierarchy { - list-style: square; - padding: 0 0 0 20px; - margin: 0; + list-style: square; + padding: 0 0 0 20px; + margin: 0; } .tsd-hierarchy .target { - font-weight: bold; + font-weight: bold; } .tsd-index-panel .tsd-index-content { - margin-bottom: -30px !important; + margin-bottom: -30px !important; } .tsd-index-panel .tsd-index-section { - margin-bottom: 30px !important; + margin-bottom: 30px !important; } .tsd-index-panel h3 { - margin: 0 -20px 10px -20px; - padding: 0 20px 10px 20px; - border-bottom: 1px solid var(--color-panel-divider); + margin: 0 -20px 10px -20px; + padding: 0 20px 10px 20px; + border-bottom: 1px solid var(--color-panel-divider); } .tsd-index-panel ul.tsd-index-list { - -webkit-column-count: 3; - -moz-column-count: 3; - -ms-column-count: 3; - -o-column-count: 3; - column-count: 3; - -webkit-column-gap: 20px; - -moz-column-gap: 20px; - -ms-column-gap: 20px; - -o-column-gap: 20px; - column-gap: 20px; - padding: 0; - list-style: none; - line-height: 1.333em; + -webkit-column-count: 3; + -moz-column-count: 3; + -ms-column-count: 3; + -o-column-count: 3; + column-count: 3; + -webkit-column-gap: 20px; + -moz-column-gap: 20px; + -ms-column-gap: 20px; + -o-column-gap: 20px; + column-gap: 20px; + padding: 0; + list-style: none; + line-height: 1.333em; } @media (max-width: 900px) { - .tsd-index-panel ul.tsd-index-list { - -webkit-column-count: 1; - -moz-column-count: 1; - -ms-column-count: 1; - -o-column-count: 1; - column-count: 1; - } + .tsd-index-panel ul.tsd-index-list { + -webkit-column-count: 1; + -moz-column-count: 1; + -ms-column-count: 1; + -o-column-count: 1; + column-count: 1; + } } @media (min-width: 901px) and (max-width: 1024px) { - .tsd-index-panel ul.tsd-index-list { - -webkit-column-count: 2; - -moz-column-count: 2; - -ms-column-count: 2; - -o-column-count: 2; - column-count: 2; - } + .tsd-index-panel ul.tsd-index-list { + -webkit-column-count: 2; + -moz-column-count: 2; + -ms-column-count: 2; + -o-column-count: 2; + column-count: 2; + } } .tsd-index-panel ul.tsd-index-list li { - -webkit-page-break-inside: avoid; - -moz-page-break-inside: avoid; - -ms-page-break-inside: avoid; - -o-page-break-inside: avoid; - page-break-inside: avoid; + -webkit-page-break-inside: avoid; + -moz-page-break-inside: avoid; + -ms-page-break-inside: avoid; + -o-page-break-inside: avoid; + page-break-inside: avoid; } .tsd-index-panel a, .tsd-index-panel .tsd-parent-kind-module a { - color: var(--color-ts); + color: var(--color-ts); } .tsd-index-panel .tsd-parent-kind-interface a { - color: var(--color-ts-interface); + color: var(--color-ts-interface); } .tsd-index-panel .tsd-parent-kind-enum a { - color: var(--color-ts-enum); + color: var(--color-ts-enum); } .tsd-index-panel .tsd-parent-kind-class a { - color: var(--color-ts-class); + color: var(--color-ts-class); } .tsd-index-panel .tsd-kind-module a { - color: var(--color-ts); + color: var(--color-ts); } .tsd-index-panel .tsd-kind-interface a { - color: var(--color-ts-interface); + color: var(--color-ts-interface); } .tsd-index-panel .tsd-kind-enum a { - color: var(--color-ts-enum); + color: var(--color-ts-enum); } .tsd-index-panel .tsd-kind-class a { - color: var(--color-ts-class); + color: var(--color-ts-class); } .tsd-index-panel .tsd-is-private a { - color: var(--color-ts-private); + color: var(--color-ts-private); } .tsd-flag { - display: inline-block; - padding: 1px 5px; - border-radius: 4px; - color: var(--color-comment-tag-text); - background-color: var(--color-comment-tag); - text-indent: 0; - font-size: 14px; - font-weight: normal; + display: inline-block; + padding: 1px 5px; + border-radius: 4px; + color: var(--color-comment-tag-text); + background-color: var(--color-comment-tag); + text-indent: 0; + font-size: 14px; + font-weight: normal; } .tsd-anchor { - position: absolute; - top: -100px; + position: absolute; + top: -100px; } .tsd-member { - position: relative; + position: relative; } .tsd-member .tsd-anchor + h3 { - margin-top: 0; - margin-bottom: 0; - border-bottom: none; + margin-top: 0; + margin-bottom: 0; + border-bottom: none; } .tsd-member [data-tsd-kind] { - color: var(--color-ts); + color: var(--color-ts); } -.tsd-member [data-tsd-kind="Interface"] { - color: var(--color-ts-interface); +.tsd-member [data-tsd-kind='Interface'] { + color: var(--color-ts-interface); } -.tsd-member [data-tsd-kind="Enum"] { - color: var(--color-ts-enum); +.tsd-member [data-tsd-kind='Enum'] { + color: var(--color-ts-enum); } -.tsd-member [data-tsd-kind="Class"] { - color: var(--color-ts-class); +.tsd-member [data-tsd-kind='Class'] { + color: var(--color-ts-class); } -.tsd-member [data-tsd-kind="Private"] { - color: var(--color-ts-private); +.tsd-member [data-tsd-kind='Private'] { + color: var(--color-ts-private); } .tsd-navigation { - margin: 0 0 0 40px; + margin: 0 0 0 40px; } .tsd-navigation a { - display: block; - padding-top: 2px; - padding-bottom: 2px; - border-left: 2px solid transparent; - color: var(--color-text); - text-decoration: none; - transition: border-left-color 0.1s; + display: block; + padding-top: 2px; + padding-bottom: 2px; + border-left: 2px solid transparent; + color: var(--color-text); + text-decoration: none; + transition: border-left-color 0.1s; } .tsd-navigation a:hover { - text-decoration: underline; + text-decoration: underline; } .tsd-navigation ul { - margin: 0; - padding: 0; - list-style: none; + margin: 0; + padding: 0; + list-style: none; } .tsd-navigation li { - padding: 0; + padding: 0; } .tsd-navigation.primary { - padding-bottom: 40px; + padding-bottom: 40px; } .tsd-navigation.primary a { - display: block; - padding-top: 6px; - padding-bottom: 6px; + display: block; + padding-top: 6px; + padding-bottom: 6px; } .tsd-navigation.primary ul li a { - padding-left: 5px; + padding-left: 5px; } .tsd-navigation.primary ul li li a { - padding-left: 25px; + padding-left: 25px; } .tsd-navigation.primary ul li li li a { - padding-left: 45px; + padding-left: 45px; } .tsd-navigation.primary ul li li li li a { - padding-left: 65px; + padding-left: 65px; } .tsd-navigation.primary ul li li li li li a { - padding-left: 85px; + padding-left: 85px; } .tsd-navigation.primary ul li li li li li li a { - padding-left: 105px; + padding-left: 105px; } .tsd-navigation.primary > ul { - border-bottom: 1px solid var(--color-panel-divider); + border-bottom: 1px solid var(--color-panel-divider); } .tsd-navigation.primary li { - border-top: 1px solid var(--color-panel-divider); + border-top: 1px solid var(--color-panel-divider); } .tsd-navigation.primary li.current > a { - font-weight: bold; + font-weight: bold; } .tsd-navigation.primary li.label span { - display: block; - padding: 20px 0 6px 5px; - color: var(--color-menu-label); + display: block; + padding: 20px 0 6px 5px; + color: var(--color-menu-label); } .tsd-navigation.primary li.globals + li > span, .tsd-navigation.primary li.globals + li > a { - padding-top: 20px; + padding-top: 20px; } .tsd-navigation.secondary { - max-height: calc(100vh - 1rem - 40px); - overflow: auto; - position: sticky; - top: calc(0.5rem + 40px); - transition: 0.3s; + max-height: calc(100vh - 1rem - 40px); + overflow: auto; + position: sticky; + top: calc(0.5rem + 40px); + transition: 0.3s; } .tsd-navigation.secondary.tsd-navigation--toolbar-hide { - max-height: calc(100vh - 1rem); - top: 0.5rem; + max-height: calc(100vh - 1rem); + top: 0.5rem; } .tsd-navigation.secondary ul { - transition: opacity 0.2s; + transition: opacity 0.2s; } .tsd-navigation.secondary ul li a { - padding-left: 25px; + padding-left: 25px; } .tsd-navigation.secondary ul li li a { - padding-left: 45px; + padding-left: 45px; } .tsd-navigation.secondary ul li li li a { - padding-left: 65px; + padding-left: 65px; } .tsd-navigation.secondary ul li li li li a { - padding-left: 85px; + padding-left: 85px; } .tsd-navigation.secondary ul li li li li li a { - padding-left: 105px; + padding-left: 105px; } .tsd-navigation.secondary ul li li li li li li a { - padding-left: 125px; + padding-left: 125px; } .tsd-navigation.secondary ul.current a { - border-left-color: var(--color-panel-divider); + border-left-color: var(--color-panel-divider); } .tsd-navigation.secondary li.focus > a, .tsd-navigation.secondary ul.current li.focus > a { - border-left-color: var(--color-menu-divider-focus); + border-left-color: var(--color-menu-divider-focus); } .tsd-navigation.secondary li.current { - margin-top: 20px; - margin-bottom: 20px; - border-left-color: var(--color-panel-divider); + margin-top: 20px; + margin-bottom: 20px; + border-left-color: var(--color-panel-divider); } .tsd-navigation.secondary li.current > a { - font-weight: bold; + font-weight: bold; } @media (min-width: 901px) { - .menu-sticky-wrap { - position: static; - } + .menu-sticky-wrap { + position: static; + } } .tsd-panel { - margin: 20px 0; - padding: 20px; - background-color: var(--color-panel); - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + margin: 20px 0; + padding: 20px; + background-color: var(--color-panel); + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); } .tsd-panel:empty { - display: none; + display: none; } .tsd-panel > h1, .tsd-panel > h2, .tsd-panel > h3 { - margin: 1.5em -20px 10px -20px; - padding: 0 20px 10px 20px; - border-bottom: 1px solid var(--color-panel-divider); + margin: 1.5em -20px 10px -20px; + padding: 0 20px 10px 20px; + border-bottom: 1px solid var(--color-panel-divider); } .tsd-panel > h1.tsd-before-signature, .tsd-panel > h2.tsd-before-signature, .tsd-panel > h3.tsd-before-signature { - margin-bottom: 0; - border-bottom: 0; + margin-bottom: 0; + border-bottom: 0; } .tsd-panel table { - display: block; - width: 100%; - overflow: auto; - margin-top: 10px; - word-break: normal; - word-break: keep-all; - border-collapse: collapse; + display: block; + width: 100%; + overflow: auto; + margin-top: 10px; + word-break: normal; + word-break: keep-all; + border-collapse: collapse; } .tsd-panel table th { - font-weight: bold; + font-weight: bold; } .tsd-panel table th, .tsd-panel table td { - padding: 6px 13px; - border: 1px solid var(--color-panel-divider); + padding: 6px 13px; + border: 1px solid var(--color-panel-divider); } .tsd-panel table tr { - background: var(--color-background); + background: var(--color-background); } .tsd-panel table tr:nth-child(even) { - background: var(--color-secondary-background); + background: var(--color-secondary-background); } .tsd-panel-group { - margin: 60px 0; + margin: 60px 0; } .tsd-panel-group > h1, .tsd-panel-group > h2, .tsd-panel-group > h3 { - padding-left: 20px; - padding-right: 20px; + padding-left: 20px; + padding-right: 20px; } #tsd-search { - transition: background-color 0.2s; + transition: background-color 0.2s; } #tsd-search .title { - position: relative; - z-index: 2; + position: relative; + z-index: 2; } #tsd-search .field { - position: absolute; - left: 0; - top: 0; - right: 40px; - height: 40px; + position: absolute; + left: 0; + top: 0; + right: 40px; + height: 40px; } #tsd-search .field input { - box-sizing: border-box; - position: relative; - top: -50px; - z-index: 1; - width: 100%; - padding: 0 10px; - opacity: 0; - outline: 0; - border: 0; - background: transparent; - color: var(--color-text); + box-sizing: border-box; + position: relative; + top: -50px; + z-index: 1; + width: 100%; + padding: 0 10px; + opacity: 0; + outline: 0; + border: 0; + background: transparent; + color: var(--color-text); } #tsd-search .field label { - position: absolute; - overflow: hidden; - right: -40px; + position: absolute; + overflow: hidden; + right: -40px; } #tsd-search .field input, #tsd-search .title { - transition: opacity 0.2s; + transition: opacity 0.2s; } #tsd-search .results { - position: absolute; - visibility: hidden; - top: 40px; - width: 100%; - margin: 0; - padding: 0; - list-style: none; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + position: absolute; + visibility: hidden; + top: 40px; + width: 100%; + margin: 0; + padding: 0; + list-style: none; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); } #tsd-search .results li { - padding: 0 10px; - background-color: var(--color-background); + padding: 0 10px; + background-color: var(--color-background); } #tsd-search .results li:nth-child(even) { - background-color: var(--color-panel); + background-color: var(--color-panel); } #tsd-search .results li.state { - display: none; + display: none; } #tsd-search .results li.current, #tsd-search .results li:hover { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } #tsd-search .results a { - display: block; + display: block; } #tsd-search .results a:before { - top: 10px; + top: 10px; } #tsd-search .results span.parent { - color: var(--color-text-aside); - font-weight: normal; + color: var(--color-text-aside); + font-weight: normal; } #tsd-search.has-focus { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } #tsd-search.has-focus .field input { - top: 0; - opacity: 1; + top: 0; + opacity: 1; } #tsd-search.has-focus .title { - z-index: 0; - opacity: 0; + z-index: 0; + opacity: 0; } #tsd-search.has-focus .results { - visibility: visible; + visibility: visible; } #tsd-search.loading .results li.state.loading { - display: block; + display: block; } #tsd-search.failure .results li.state.failure { - display: block; + display: block; } .tsd-signature { - margin: 0 0 1em 0; - padding: 10px; - border: 1px solid var(--color-panel-divider); - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - font-size: 14px; - overflow-x: auto; + margin: 0 0 1em 0; + padding: 10px; + border: 1px solid var(--color-panel-divider); + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; + font-size: 14px; + overflow-x: auto; } .tsd-signature.tsd-kind-icon { - padding-left: 30px; + padding-left: 30px; } .tsd-signature.tsd-kind-icon:before { - top: 10px; - left: 10px; + top: 10px; + left: 10px; } .tsd-panel > .tsd-signature { - margin-left: -20px; - margin-right: -20px; - border-width: 1px 0; + margin-left: -20px; + margin-right: -20px; + border-width: 1px 0; } .tsd-panel > .tsd-signature.tsd-kind-icon { - padding-left: 40px; + padding-left: 40px; } .tsd-panel > .tsd-signature.tsd-kind-icon:before { - left: 20px; + left: 20px; } .tsd-signature-symbol { - color: var(--color-text-aside); - font-weight: normal; + color: var(--color-text-aside); + font-weight: normal; } .tsd-signature-type { - font-style: italic; - font-weight: normal; + font-style: italic; + font-weight: normal; } .tsd-signatures { - padding: 0; - margin: 0 0 1em 0; - border: 1px solid var(--color-panel-divider); + padding: 0; + margin: 0 0 1em 0; + border: 1px solid var(--color-panel-divider); } .tsd-signatures .tsd-signature { - margin: 0; - border-width: 1px 0 0 0; - transition: background-color 0.1s; + margin: 0; + border-width: 1px 0 0 0; + transition: background-color 0.1s; } .tsd-signatures .tsd-signature:first-child { - border-top-width: 0; + border-top-width: 0; } .tsd-signatures .tsd-signature.current { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } .tsd-signatures.active > .tsd-signature { - cursor: pointer; + cursor: pointer; } .tsd-panel > .tsd-signatures { - margin-left: -20px; - margin-right: -20px; - border-width: 1px 0; + margin-left: -20px; + margin-right: -20px; + border-width: 1px 0; } .tsd-panel > .tsd-signatures .tsd-signature.tsd-kind-icon { - padding-left: 40px; + padding-left: 40px; } .tsd-panel > .tsd-signatures .tsd-signature.tsd-kind-icon:before { - left: 20px; + left: 20px; } .tsd-panel > a.anchor + .tsd-signatures { - border-top-width: 0; - margin-top: -20px; + border-top-width: 0; + margin-top: -20px; } ul.tsd-descriptions { - position: relative; - overflow: hidden; - padding: 0; - list-style: none; + position: relative; + overflow: hidden; + padding: 0; + list-style: none; } ul.tsd-descriptions.active > .tsd-description { - display: none; + display: none; } ul.tsd-descriptions.active > .tsd-description.current { - display: block; + display: block; } ul.tsd-descriptions.active > .tsd-description.fade-in { - animation: fade-in-delayed 0.3s; + animation: fade-in-delayed 0.3s; } ul.tsd-descriptions.active > .tsd-description.fade-out { - animation: fade-out-delayed 0.3s; - position: absolute; - display: block; - top: 0; - left: 0; - right: 0; - opacity: 0; - visibility: hidden; + animation: fade-out-delayed 0.3s; + position: absolute; + display: block; + top: 0; + left: 0; + right: 0; + opacity: 0; + visibility: hidden; } ul.tsd-descriptions h4, ul.tsd-descriptions .tsd-index-panel h3, .tsd-index-panel ul.tsd-descriptions h3 { - font-size: 16px; - margin: 1em 0 0.5em 0; + font-size: 16px; + margin: 1em 0 0.5em 0; } ul.tsd-parameters, ul.tsd-type-parameters { - list-style: square; - margin: 0; - padding-left: 20px; + list-style: square; + margin: 0; + padding-left: 20px; } ul.tsd-parameters > li.tsd-parameter-signature, ul.tsd-type-parameters > li.tsd-parameter-signature { - list-style: none; - margin-left: -20px; + list-style: none; + margin-left: -20px; } ul.tsd-parameters h5, ul.tsd-type-parameters h5 { - font-size: 16px; - margin: 1em 0 0.5em 0; + font-size: 16px; + margin: 1em 0 0.5em 0; } ul.tsd-parameters .tsd-comment, ul.tsd-type-parameters .tsd-comment { - margin-top: -0.5em; + margin-top: -0.5em; } .tsd-sources { - font-size: 14px; - color: var(--color-text-aside); - margin: 0 0 1em 0; + font-size: 14px; + color: var(--color-text-aside); + margin: 0 0 1em 0; } .tsd-sources a { - color: var(--color-text-aside); - text-decoration: underline; + color: var(--color-text-aside); + text-decoration: underline; } .tsd-sources ul, .tsd-sources p { - margin: 0 !important; + margin: 0 !important; } .tsd-sources ul { - list-style: none; - padding: 0; + list-style: none; + padding: 0; } .tsd-page-toolbar { - position: fixed; - z-index: 1; - top: 0; - left: 0; - width: 100%; - height: 40px; - color: var(--color-toolbar-text); - background: var(--color-toolbar); - border-bottom: 1px solid var(--color-panel-divider); - transition: transform 0.3s linear; + position: fixed; + z-index: 1; + top: 0; + left: 0; + width: 100%; + height: 40px; + color: var(--color-toolbar-text); + background: var(--color-toolbar); + border-bottom: 1px solid var(--color-panel-divider); + transition: transform 0.3s linear; } .tsd-page-toolbar a { - color: var(--color-toolbar-text); - text-decoration: none; + color: var(--color-toolbar-text); + text-decoration: none; } .tsd-page-toolbar a.title { - font-weight: bold; + font-weight: bold; } .tsd-page-toolbar a.title:hover { - text-decoration: underline; + text-decoration: underline; } .tsd-page-toolbar .table-wrap { - display: table; - width: 100%; - height: 40px; + display: table; + width: 100%; + height: 40px; } .tsd-page-toolbar .table-cell { - display: table-cell; - position: relative; - white-space: nowrap; - line-height: 40px; + display: table-cell; + position: relative; + white-space: nowrap; + line-height: 40px; } .tsd-page-toolbar .table-cell:first-child { - width: 100%; + width: 100%; } .tsd-page-toolbar--hide { - transform: translateY(-100%); + transform: translateY(-100%); } .tsd-select .tsd-select-list li:before, .tsd-select .tsd-select-label:before, .tsd-widget:before { - content: ""; - display: inline-block; - width: 40px; - height: 40px; - margin: 0 -8px 0 0; - background-image: url(./widgets.png); - background-repeat: no-repeat; - text-indent: -1024px; - vertical-align: bottom; - filter: var(--icon-filter); + content: ''; + display: inline-block; + width: 40px; + height: 40px; + margin: 0 -8px 0 0; + background-image: url(./widgets.png); + background-repeat: no-repeat; + text-indent: -1024px; + vertical-align: bottom; + filter: var(--icon-filter); } @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { - .tsd-select .tsd-select-list li:before, - .tsd-select .tsd-select-label:before, - .tsd-widget:before { - background-image: url(./widgets@2x.png); - background-size: 320px 40px; - } + .tsd-select .tsd-select-list li:before, + .tsd-select .tsd-select-label:before, + .tsd-widget:before { + background-image: url(./widgets@2x.png); + background-size: 320px 40px; + } } .tsd-widget { - display: inline-block; - overflow: hidden; - opacity: 0.8; - height: 40px; - transition: opacity 0.1s, background-color 0.2s; - vertical-align: bottom; - cursor: pointer; + display: inline-block; + overflow: hidden; + opacity: 0.8; + height: 40px; + transition: opacity 0.1s, background-color 0.2s; + vertical-align: bottom; + cursor: pointer; } .tsd-widget:hover { - opacity: 0.9; + opacity: 0.9; } .tsd-widget.active { - opacity: 1; - background-color: var(--color-panel-divider); + opacity: 1; + background-color: var(--color-panel-divider); } .tsd-widget.no-caption { - width: 40px; + width: 40px; } .tsd-widget.no-caption:before { - margin: 0; + margin: 0; } .tsd-widget.search:before { - background-position: 0 0; + background-position: 0 0; } .tsd-widget.menu:before { - background-position: -40px 0; + background-position: -40px 0; } .tsd-widget.options:before { - background-position: -80px 0; + background-position: -80px 0; } .tsd-widget.options, .tsd-widget.menu { - display: none; + display: none; } @media (max-width: 900px) { - .tsd-widget.options, - .tsd-widget.menu { - display: inline-block; - } + .tsd-widget.options, + .tsd-widget.menu { + display: inline-block; + } } -input[type="checkbox"] + .tsd-widget:before { - background-position: -120px 0; +input[type='checkbox'] + .tsd-widget:before { + background-position: -120px 0; } -input[type="checkbox"]:checked + .tsd-widget:before { - background-position: -160px 0; +input[type='checkbox']:checked + .tsd-widget:before { + background-position: -160px 0; } .tsd-select { - position: relative; - display: inline-block; - height: 40px; - transition: opacity 0.1s, background-color 0.2s; - vertical-align: bottom; - cursor: pointer; + position: relative; + display: inline-block; + height: 40px; + transition: opacity 0.1s, background-color 0.2s; + vertical-align: bottom; + cursor: pointer; } .tsd-select .tsd-select-label { - opacity: 0.6; - transition: opacity 0.2s; + opacity: 0.6; + transition: opacity 0.2s; } .tsd-select .tsd-select-label:before { - background-position: -240px 0; + background-position: -240px 0; } .tsd-select.active .tsd-select-label { - opacity: 0.8; + opacity: 0.8; } .tsd-select.active .tsd-select-list { - visibility: visible; - opacity: 1; - transition-delay: 0s; + visibility: visible; + opacity: 1; + transition-delay: 0s; } .tsd-select .tsd-select-list { - position: absolute; - visibility: hidden; - top: 40px; - left: 0; - margin: 0; - padding: 0; - opacity: 0; - list-style: none; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); - transition: visibility 0s 0.2s, opacity 0.2s; + position: absolute; + visibility: hidden; + top: 40px; + left: 0; + margin: 0; + padding: 0; + opacity: 0; + list-style: none; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + transition: visibility 0s 0.2s, opacity 0.2s; } .tsd-select .tsd-select-list li { - padding: 0 20px 0 0; - background-color: var(--color-background); + padding: 0 20px 0 0; + background-color: var(--color-background); } .tsd-select .tsd-select-list li:before { - background-position: 40px 0; + background-position: 40px 0; } .tsd-select .tsd-select-list li:nth-child(even) { - background-color: var(--color-panel); + background-color: var(--color-panel); } .tsd-select .tsd-select-list li:hover { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } .tsd-select .tsd-select-list li.selected:before { - background-position: -200px 0; + background-position: -200px 0; } @media (max-width: 900px) { - .tsd-select .tsd-select-list { - top: 0; - left: auto; - right: 100%; - margin-right: -5px; - } - .tsd-select .tsd-select-label:before { - background-position: -280px 0; - } + .tsd-select .tsd-select-list { + top: 0; + left: auto; + right: 100%; + margin-right: -5px; + } + .tsd-select .tsd-select-label:before { + background-position: -280px 0; + } } img { - max-width: 100%; + max-width: 100%; } .tsd-anchor-icon { - margin-left: 10px; - vertical-align: middle; - color: var(--color-text); + margin-left: 10px; + vertical-align: middle; + color: var(--color-text); } .tsd-anchor-icon svg { - width: 1em; - height: 1em; - visibility: hidden; + width: 1em; + height: 1em; + visibility: hidden; } .tsd-anchor-link:hover > .tsd-anchor-icon svg { - visibility: visible; + visibility: visible; } From 85acc731cdee08b69c17050ec30701840109e7ab Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 14 Apr 2022 22:49:38 +0300 Subject: [PATCH 005/128] chore: Added docs maintainer --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..42d14d29 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +src/* @jacoobes +docs/* @Murtatrxx \ No newline at end of file From af3be1d10af6b340ef416ea14d3f8c0656cd6427 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 14 Apr 2022 22:57:16 +0300 Subject: [PATCH 006/128] chore: Changed typedoc configration --- .gitignore | 15 +++++++++------ package.json | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index 81ce2e3d..6e1ef477 100644 --- a/.gitignore +++ b/.gitignore @@ -54,19 +54,20 @@ typings/ # Yarn Integrity file .yarn-integrity -# dotenv environment variables file +# Typedoc raw output +.typedoc + +# Dotenv environment variables file .env -# parcel-bundler cache (https://parceljs.org/) +# Parcel-bundler cache (https://parceljs.org/) .cache -# next.js build output +# next.js and nuxt.js build output .next - -# nuxt.js build output .nuxt -# vuepress build output +# Vuepress build output .vuepress/dist # Serverless directories @@ -75,6 +76,8 @@ typings/ # FuseBox cache .fusebox/ +# TypeScript build output dist +# VisualStudio config file .vs \ No newline at end of file diff --git a/package.json b/package.json index ba3c0028..5033a4d6 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "release": "standard-version && git push --follow-tags", "test": "jest --coverage --verbose", "commit": "cz", - "docs": "typedoc src/index.ts --out docs" + "docs": "typedoc src/index.ts --out .typedoc" }, "keywords": [], "author": "", From 7e9ce62fee44ff8ce4c45b78a91a9ac18229aadf Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 14 Apr 2022 23:00:27 +0300 Subject: [PATCH 007/128] chore(README.md): Removed coming soon from links --- README.md | 93 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 48 insertions(+), 45 deletions(-) diff --git a/README.md b/README.md index 47b6d47a..1626d4d2 100644 --- a/README.md +++ b/README.md @@ -1,91 +1,94 @@ # Sern Handler + NPM version NPM downloads Builds Passing Sern can automate and streamline development of your discord bot with new version compatibility and full customization. -- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) +- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) ## Installation ```sh npm install sern-handler ``` + ```sh yarn add sern-handler ``` + ```sh pnpm add sern-handler ``` ## Basic Usage -#### ` index.js ` +#### ` index.js (CommonJS)` + ```js -import { Client, Intents } from 'discord.js'; -import { Sern } from 'sern-handler'; -import { prefix, token } from '../src/secrets.json'; +const { Client, Intents } = require('discord.js'); +const { Sern } = require('sern-handler'); +const { prefix, token } = require('./config.json'); const client = new Client({ - intents: [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MEMBERS - ] + intents: [ + Intents.FLAGS.GUILDS, + Intents.FLAGS.GUILD_MESSAGES, + Intents.FLAGS.GUILD_MEMBERS + ], }); new Sern.Handler({ - client, - prefix, - commands : 'dist/commands', - privateServers : [ - { - test : true, - id: 'server-id' - } - ], - init: async (handler) => { - // Optional function to initialize anything else on bot startup + client, + prefix, + commands: 'src/commands', + privateServers: [ + { + test: true, + id: 'server-id', }, + ], + init: async (handler) => { + // Optional function to initialize anything else on bot startup + }, }); - client.login(token); ``` -#### ` ping.js ` +#### ` ping.js (CommonJS)` + ```js -import { Sern, Types } from 'sern-handler'; -import { Ok } from 'ts-results'; - -export default { - alias: [], - desc : 'A ping pong command', - visibility : 'private', - test : false, - type: Sern.CommandType.SLASH | Sern.CommandType.TEXT, - execute : async ({ message, interaction }, args) => 'pong!' +const { Sern, Types } = require('sern-handler'); + +module.exports = { + alias: [], + desc: 'A ping pong command', + visibility: 'private', + test: false, + type: Sern.CommandType.SLASH | Sern.CommandType.TEXT, + execute: async ({ message, interaction }, args) => 'pong!', }; ``` See [documentation](https://sern-handler.js.org) for TypeScript examples and more -## Links ![link](https://img.shields.io/badge/Coming-Soon-purple) +## Links -- [Official Documentation](https://tmp.com) -- [Example Bot](https://tmp.com) -- [Discord Server](https://google.com) +- [Official Documentation](https://sern-handler.js.org) +- [Example Bot](https://github.com/sern-handler/cheemsBanker) +- [Support Server](https://discord.com/invite/Yvb7DnqjXX) ## Contribute -- Pull up on [issues](https://github.com/sern-handler/Sern/issues) and tell us, if there are bugs -- All kinds of contributions are welcomed! +- Pull up on [issues](https://github.com/sern-handler/Sern/issues) and tell us, if there are bugs +- All kinds of contributions are welcomed! ## TODO -- Default commands -- Categories -- Ruling out all bugs in the command system -- Better support for slash commands -- More Build scripts -- Logger +- [ ] Default commands +- [ ] Categories +- [ ] Ruling out all bugs in the command system +- [ ] Better support for slash commands +- [ ] More Build scripts +- [ ] Logger From cc37927f2755de70bf33d4edb5b13e990cf5792f Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 14 Apr 2022 23:22:38 +0300 Subject: [PATCH 008/128] chore: Updated Prettier formatter tab width --- .prettierrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index 2f316681..0c670739 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,5 @@ "trailingComma": "all", "singleQuote": true, "printWidth": 120, - "tabWidth": 4 + "tabWidth": 2 } From 0021fffaad42438a42c1ec2393f5c71d26b1b68f Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 24 Apr 2022 18:14:33 +0300 Subject: [PATCH 009/128] docs(readme): Improved Readme readability --- README.md | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 1626d4d2..295bb947 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,25 @@ # Sern Handler - -NPM version NPM downloads Builds Passing + +NPM version NPM downloads Builds Passing -Sern can automate and streamline development of your discord bot with new version compatibility and full customization. +A discord.js wrapper for you to automate and streamline your bot development. Also, we are providing a [cli](https://github.com/sern-handler/cli) for you to use. - A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) ## Installation ```sh -npm install sern-handler +npm install @sern/handler ``` ```sh -yarn add sern-handler +yarn add @sern/handler +``` ``` ```sh -pnpm add sern-handler +pnpm add @sern/handler ``` ## Basic Usage @@ -76,7 +77,7 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor ## Links - [Official Documentation](https://sern-handler.js.org) -- [Example Bot](https://github.com/sern-handler/cheemsBanker) +- [Public Templates](https://github.com/sern-handler/templates) - [Support Server](https://discord.com/invite/Yvb7DnqjXX) ## Contribute @@ -84,11 +85,6 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor - Pull up on [issues](https://github.com/sern-handler/Sern/issues) and tell us, if there are bugs - All kinds of contributions are welcomed! -## TODO +## Roadmap ![link](https://img.shields.io/badge/Coming-Soon-purple) -- [ ] Default commands -- [ ] Categories -- [ ] Ruling out all bugs in the command system -- [ ] Better support for slash commands -- [ ] More Build scripts -- [ ] Logger +You can check our roadmap to see what's going to be added in the future. From 45ebeb5cb99d4c96d2f55ee7ba8c9d67e32c5d90 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 25 Apr 2022 08:39:12 +0300 Subject: [PATCH 010/128] docs(README): Fixed installation box --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 295bb947..83a2adc9 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,6 @@ npm install @sern/handler ```sh yarn add @sern/handler ``` -``` ```sh pnpm add @sern/handler From e9d35ff443800ec555dfbd5037edcabb63deba13 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:27:49 +0300 Subject: [PATCH 011/128] style(README.md): Improved readability --- README.md | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 83a2adc9..50ecc498 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ NPM version NPM downloads Builds Passing -A discord.js wrapper for you to automate and streamline your bot development. Also, we are providing a [cli](https://github.com/sern-handler/cli) for you to use. +A discord.js wrapper for you to automate and streamline your bot development. - A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) @@ -75,13 +75,14 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor ## Links -- [Official Documentation](https://sern-handler.js.org) -- [Public Templates](https://github.com/sern-handler/templates) -- [Support Server](https://discord.com/invite/Yvb7DnqjXX) +- **[Official Documentation](https://sern-handler.js.org)** +- **[Public Templates](https://github.com/sern-handler/templates)** +- **[Discord Server](https://discord.com/invite/Yvb7DnqjXX)** ## Contribute -- Pull up on [issues](https://github.com/sern-handler/Sern/issues) and tell us, if there are bugs +- Read our contribution [guidelines](https://github.com/sern-handler/handler) carefully +- Pull up on [issues](https://github.com/sern-handler/handler/issues) and tell us, if there are bugs - All kinds of contributions are welcomed! ## Roadmap ![link](https://img.shields.io/badge/Coming-Soon-purple) From 2bcadb1c7d7abc22a2601fa49e0669b5846f593b Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:44:00 +0300 Subject: [PATCH 012/128] chore: Added CONTRIBUTING.md --- .github/CONTRIBUTING.md | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/CONTRIBUTING.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..685cb74c --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,49 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish to make via issue, +email, or any other method with the owners of this repository before making a change. + +Please note we have a [code of conduct](https://github.com/sern-handler/handler/blob/main/CODE_OF_CONDUCT.md), please follow it in all your interactions with the project. + +## Pull Request Process + +1. Ensure any install or build dependencies are removed before the end of the layer when doing a + build. +2. Update the README.md with details of changes to the interface, this includes new environment + variables, exposed ports, useful file locations and container parameters. +3. Increase the version numbers in any examples files and the README.md to the new version that this + Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). +4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you + do not have permission to do that, you may request the second reviewer to merge it for you. + +### Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. +### Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [INSERT EMAIL ADDRESS]. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +### Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file From 9c75dddd47eb2872123dafe4039f59464b760b61 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:49:14 +0300 Subject: [PATCH 013/128] docs(README.md): Removed old repo link and it's line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 50ecc498..e141f306 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,6 @@ A discord.js wrapper for you to automate and streamline your bot development. -- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) ## Installation From b76a89460dc1f97a48c08bab73229fed4fa60485 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:53:01 +0300 Subject: [PATCH 014/128] docs(README): Updated Intents to djs v14 Co-authored-by: EvolutionX <85353424+EvolutionX-10@users.noreply.github.com> --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e141f306..2463aa3a 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ const { prefix, token } = require('./config.json'); const client = new Client({ intents: [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MEMBERS - ], + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages + ] }); new Sern.Handler({ From 9c61ecd3cea447c5a7c699127d0a1650b6989a42 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:54:02 +0300 Subject: [PATCH 015/128] docs: Updated README example to djs v14 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e141f306..96745901 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ pnpm add @sern/handler #### ` index.js (CommonJS)` ```js -const { Client, Intents } = require('discord.js'); +const { Client, GatewayIntentBits } = require('discord.js'); const { Sern } = require('sern-handler'); const { prefix, token } = require('./config.json'); From 35663b034ae5bf4de4c4e8043541b6fd700496e2 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:55:14 +0300 Subject: [PATCH 016/128] docs: Formatted README examples --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 97d891a2..ab86ea2a 100644 --- a/README.md +++ b/README.md @@ -31,10 +31,10 @@ const { prefix, token } = require('./config.json'); const client = new Client({ intents: [ - GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMembers, - GatewayIntentBits.GuildMessages - ] + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages + ] }); new Sern.Handler({ From 1df38ef85f262ea60308513f166d18a29c1f3a5f Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 2 May 2022 10:47:01 +0300 Subject: [PATCH 017/128] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ab86ea2a..77126969 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,6 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor - Pull up on [issues](https://github.com/sern-handler/handler/issues) and tell us, if there are bugs - All kinds of contributions are welcomed! -## Roadmap ![link](https://img.shields.io/badge/Coming-Soon-purple) +## Roadmap -You can check our roadmap to see what's going to be added in the future. +You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or fixed in the future. From 01634b1bfacc50292afc66a2e0cf60cc0126db88 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 2 May 2022 22:58:06 +0300 Subject: [PATCH 018/128] docs: Updated organization description --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 77126969..6460c794 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ NPM version NPM downloads Builds Passing -A discord.js wrapper for you to automate and streamline your bot development. +A customizable, batteries-included, powerful discord.js framework to automate and streamline your bot development. ## Installation From 5df192990c69eba6368964698d922c7114e4fe68 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 4 May 2022 21:31:02 +0300 Subject: [PATCH 019/128] docs(README): Rename 'fixed' to 'patched' --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6460c794..1ae90a0f 100644 --- a/README.md +++ b/README.md @@ -86,4 +86,4 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor ## Roadmap -You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or fixed in the future. +You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or patched in the future. From 83ce42d235663b0327da9c84dcdb1fdba079e1ac Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 08:32:18 +0300 Subject: [PATCH 020/128] chore: Updated LICENSE --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 921e84f8..ff8067c0 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. A discord.js wrapper to make easier to use discord.js - Copyright (C) 2022 SernHandler, Inc. + Copyright (C) 2022 Sern, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 3d3c8c29a46998cd4f0c12998f205ddd278faca7 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 08:40:35 +0300 Subject: [PATCH 021/128] chore: Updated LICNESE --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index ff8067c0..c62d772d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. A discord.js wrapper to make easier to use discord.js - Copyright (C) 2022 Sern, Inc. + Copyright (C) 2022 Sern. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From fa7ddf077d7125d319bf48cc85b436c5930d8145 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 11:35:38 +0300 Subject: [PATCH 022/128] chore: Changed license to MIT --- LICENSE.md | 340 +---------------------------------------------------- 1 file changed, 5 insertions(+), 335 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index c62d772d..72d26a38 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,339 +1,9 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 +Copyright (C) 2022 Sern - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - Preamble +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - A discord.js wrapper to make easier to use discord.js - Copyright (C) 2022 Sern. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. +End license text. From 2e655317922da860f81915eb1e5667eda2693f0b Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 11:42:18 +0300 Subject: [PATCH 023/128] Delete LICENSE.md --- LICENSE.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 72d26a38..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -Copyright (C) 2022 Sern - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -End license text. From 9745ab0aad48f1931abda42cd59d2f42cd9c2d73 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 11:45:39 +0300 Subject: [PATCH 024/128] chore: Recreated LICENSE --- LICENSE.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..18f6a203 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +**Copyright (C) 2022 Sern** + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +End license text. From b7878626ddcce21db032a650e3338543b78af236 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 14:16:15 +0300 Subject: [PATCH 025/128] chore: First License boilerplate preview --- src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/index.ts b/src/index.ts index 791cb53d..f1923c21 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,10 @@ +/* + * Batteries-included, yet powerful discord.is framework + * Copyright (C) 2021 Xx-Mohit-xX + * This software is licensed under MIT LICENSE + * For more information, see README.md and LICENSE.md +*/ + export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; From 61645367ad24bdb1e3cba8ea4766e21354dc0934 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 14:18:10 +0300 Subject: [PATCH 026/128] style(index.ts): Added a space --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index f1923c21..fb7c38c5 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ * Copyright (C) 2021 Xx-Mohit-xX * This software is licensed under MIT LICENSE * For more information, see README.md and LICENSE.md -*/ + */ export * as Sern from './handler/sern'; export * from './types/handler'; From ff960db2c60aaa5fd39e8cc34cc0b0fa35a9e24a Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 14:36:03 +0300 Subject: [PATCH 027/128] chore(index.ts): First license boilerplate preview --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index fb7c38c5..5fbefe1c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ /* * Batteries-included, yet powerful discord.is framework - * Copyright (C) 2021 Xx-Mohit-xX + * Copyright (C) 2022 Sern * This software is licensed under MIT LICENSE * For more information, see README.md and LICENSE.md */ From 2e310a1ba725d7473684f3a63ea7a7561887e742 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 17:25:05 +0300 Subject: [PATCH 028/128] chore(PRETTIER): Re-updated the tab width --- .prettierrc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.prettierrc b/.prettierrc index 0c670739..2f316681 100644 --- a/.prettierrc +++ b/.prettierrc @@ -3,5 +3,5 @@ "trailingComma": "all", "singleQuote": true, "printWidth": 120, - "tabWidth": 2 + "tabWidth": 4 } From 474e7810138858126e7b54c6943dc2d60177076b Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 17:36:59 +0300 Subject: [PATCH 029/128] chore(SECURITY): Updated security.md file --- .github/SECURITY.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 8081eaec..45d71847 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -2,12 +2,14 @@ ## Supported Versions -Project is currently in development and is not yet ready to be used. +Project is currently under heavy development but you can try out our [npm package](https://npmjs.com/package/@sern/handler) | Version | Supported | | ------- | ------------------ | | 0.1.0 @ dev | :white_check_mark: | +* Dev versions might include bugs, use it with your own risk. + ## Reporting a Vulnerability You can report a vulnerability by opening an issue on the [project's GitHub](https://github.com/SernHandler/Sern/issues) repository. From 95c26e928f6278af13033a8c69709b860be09919 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 13 May 2022 21:32:31 +0300 Subject: [PATCH 030/128] docs(README): Improved readability --- README.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1ae90a0f..169c4897 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,6 @@ -# Sern Handler - - -NPM version NPM downloads Builds Passing +# SernHandler NPM version +NPM downloads +[![License: MIT](https://img.shields.io/badge/License-MIT-blavk.svg)](https://opensource.org/licenses/MIT) A customizable, batteries-included, powerful discord.js framework to automate and streamline your bot development. @@ -70,7 +69,11 @@ module.exports = { }; ``` -See [documentation](https://sern-handler.js.org) for TypeScript examples and more +See out [templates](https://github.com/sern-handler/tenplated) for TypeScript examples and more + +## CLI + +We are providing a [command line interface](https://github.com/sern-handler/cli) for better & easier bot developement. Don't forget to view it. ## Links @@ -82,7 +85,7 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor - Read our contribution [guidelines](https://github.com/sern-handler/handler) carefully - Pull up on [issues](https://github.com/sern-handler/handler/issues) and tell us, if there are bugs -- All kinds of contributions are welcomed! +- All kinds of contributions are welcomed. ## Roadmap From 0568f3a8e15cf7c242e6d945344f0e8729559eff Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 07:52:57 +0300 Subject: [PATCH 031/128] fix(README): Fixed typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 169c4897..918bedf7 100644 --- a/README.md +++ b/README.md @@ -69,7 +69,7 @@ module.exports = { }; ``` -See out [templates](https://github.com/sern-handler/tenplated) for TypeScript examples and more +See our [templates](https://github.com/sern-handler/tenplated) for TypeScript examples and more ## CLI From 54518c19b9cfcf102cef3d5280255379afdd4773 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:30:25 +0300 Subject: [PATCH 032/128] style: Updated license boilerplate --- src/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 5fbefe1c..06deef91 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,12 @@ -/* - * Batteries-included, yet powerful discord.is framework - * Copyright (C) 2022 Sern - * This software is licensed under MIT LICENSE - * For more information, see README.md and LICENSE.md +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- */ + export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; From 834b15678ad3b1d18a821ee5a65e58cf2667d291 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:43:40 +0300 Subject: [PATCH 033/128] style(*): Updated license boilerplate --- src/handler/sern.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/handler/sern.ts b/src/handler/sern.ts index c9ed8ad7..27b12677 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -1,3 +1,11 @@ +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- + */ + import type { DiscordEvent, } from '../types/handler'; From cb3def0b6017fe154f8d7c06d8703969938c67cd Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:44:56 +0300 Subject: [PATCH 034/128] style: Updated license boilerplate --- src/handler/logger.ts | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/handler/logger.ts b/src/handler/logger.ts index aff768d1..970342c7 100644 --- a/src/handler/logger.ts +++ b/src/handler/logger.ts @@ -1,11 +1,18 @@ +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- + */ export enum sEvent { - GLOBAL_SLASH, - LOCAL_SLASH, - MISUSE_CMD, - DM, - CRASH, - TEXT_CMD, + GLOBAL_SLASH, + LOCAL_SLASH, + MISUSE_CMD, + DM, + CRASH, + TEXT_CMD, } export default class Logger { From e2bb0f32f59754e4df6477856249d708f5c0b445 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:47:21 +0300 Subject: [PATCH 035/128] style: Updated license boilerplate --- src/handler/utilities/readFile.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index f933feb0..deed23d2 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -1,9 +1,16 @@ +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- + */ + import { readdirSync, statSync } from 'fs'; import { join } from 'path'; import type { Module } from '../structures/modules/commands/module'; import { SernError } from '../structures/errors'; -//We can look into lazily loading modules once everything is set export const ContextMenuUser = new Map(); export const ContextMenuMsg = new Map(); export const Commands = new Map(); @@ -11,8 +18,7 @@ export const Alias = new Map(); export const Buttons = new Map(); export const SelectMenus = new Map(); - -// Courtesy @Townsy45 +// Thanks to @Townsy45 function readPath(dir: string, arrayOfFiles: string[] = []): string[] { try { const files = readdirSync(dir); From 4921e5a292ba59e68af1da76f512682a88fe74ac Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:50:41 +0300 Subject: [PATCH 036/128] style: Updated license boilerplate --- src/handler/structures/structxports.ts | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index 1ae69979..3102e81c 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -1,12 +1,20 @@ +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- + */ + import Context from './context'; import type { SlashCommand, TextCommand, BothCommand, Module } from '../structures/modules/commands/module'; import type Wrapper from './wrapper'; export { - Context, - SlashCommand, - TextCommand, - BothCommand, - Module, - Wrapper + Context, + SlashCommand, + TextCommand, + BothCommand, + Module, + Wrapper }; From d26a2f63c8c271256d0953d5e7aaf381a85b3f07 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:55:51 +0300 Subject: [PATCH 037/128] style: Updated License boilerplate --- src/handler/structures/errors.ts | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index c29128ea..cba8b28e 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -1,7 +1,15 @@ +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- + */ + export enum SernError { - RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.', - NO_ALIAS = 'You cannot provide an array with elements to a slash command.', - NOT_VALID_MOD_TYPE = 'Detected an unknown module type', - UNDEFINED_MODULE = `A module could not be detected at`, - MISMATCH_MODULE_TYPE = `A module type mismatched with event emitted!` + RESERVED_EVENT = 'Cannot register the reserved ready event. Please use the init property.', + NO_ALIAS = 'You cannot provide an array with elements to a slash command.', + NOT_VALID_MOD_TYPE = 'Detected an unknown module type', + UNDEFINED_MODULE = `A module could not be detected at`, + MISMATCH_MODULE_TYPE = `A module type mismatched with event emitted!` } From 8b126fe0c124e864be8bbaca922eae48b601ba46 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:56:48 +0300 Subject: [PATCH 038/128] style: Updated License boilerplate --- src/handler/events/readyEvent.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index b389f944..1a952008 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -1,3 +1,11 @@ +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- + */ + import { first, from, fromEvent } from 'rxjs'; import { basename } from 'path'; import * as Files from '../utilities/readFile'; From 0dd34f90ab0ec980a228a1c8ae1dea03578d9722 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 16 May 2022 09:21:46 +0300 Subject: [PATCH 039/128] docs(README): Added stats --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 918bedf7..b9787750 100644 --- a/README.md +++ b/README.md @@ -90,3 +90,8 @@ We are providing a [command line interface](https://github.com/sern-handler/cli) ## Roadmap You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or patched in the future. + +## Stats + +![Alt](https://repobeats.axiom.co/api/embed/db7210a5cae806c7e54c0c5942b6be25e63ca5e4.svg "Feel free to contribute") + From db8fcea4f055466162939d5fb66ef04d668efcdf Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 16 May 2022 09:27:17 +0300 Subject: [PATCH 040/128] docs(README): Temporarily or permanently removed stats --- README.md | 5 ----- 1 file changed, 5 deletions(-) diff --git a/README.md b/README.md index b9787750..918bedf7 100644 --- a/README.md +++ b/README.md @@ -90,8 +90,3 @@ We are providing a [command line interface](https://github.com/sern-handler/cli) ## Roadmap You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or patched in the future. - -## Stats - -![Alt](https://repobeats.axiom.co/api/embed/db7210a5cae806c7e54c0c5942b6be25e63ca5e4.svg "Feel free to contribute") - From 972928b6a3b8ee70622f2c55f13ab9f0b222089f Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Mon, 16 May 2022 20:55:44 -0500 Subject: [PATCH 041/128] refactor: DRY Principles --- src/handler/events/interactionCreate.ts | 78 +++++++++++++++--------- src/handler/events/observableHandling.ts | 2 +- src/handler/plugins/plugin.ts | 3 - src/handler/structures/module.ts | 2 +- src/handler/utilities/predicates.ts | 11 +++- 5 files changed, 59 insertions(+), 37 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 713ba610..79773ec5 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,55 +1,75 @@ -import type { - CommandInteraction, - Interaction, - MessageComponentInteraction, - MessageContextMenuCommandInteraction as MessageCtxInt, - UserContextMenuCommandInteraction as UserCtxInt, -} from 'discord.js'; -import type { SelectMenuInteraction } from 'discord.js'; -import { concatMap, fromEvent, Observable, of, throwError } from 'rxjs'; +import type { CommandInteraction, Interaction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; +import { concatMap, from, fromEvent, map, Observable, of, throwError } from 'rxjs'; import type Wrapper from '../structures/wrapper'; import * as Files from '../utilities/readFile'; -import { match, P } from 'ts-pattern'; +import { match } from 'ts-pattern'; import { SernError } from '../structures/errors'; import Context from '../structures/context'; import type { Result } from 'ts-results'; import { CommandType, controller } from '../sern'; -import type { Args, UnionToTuple } from '../../types/handler'; import type { Module } from '../structures/module'; import type { EventPlugin } from '../plugins/plugin'; -import { isButton, isChatInputCommand, isSelectMenu } from '../utilities/predicates'; - +import { + isButton, + isChatInputCommand, + isMessageCtxMenuCmd, + isSelectMenu, + isUserContextMenuCmd, +} from '../utilities/predicates'; +import { filterCorrectModule } from './observableHandling'; +//TODO : atm, i have to cast for every interaction. is there a way to not cast? +// maybe pass it through an observable function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { if (mod === undefined) { return throwError(() => SernError.UndefinedModule); } + const mod$ = (cmdTy : T) => of(mod).pipe( + filterCorrectModule(cmdTy) + ); const eventPlugins = mod.onEvent; return match(interaction) .when(isChatInputCommand, i => { - const ctx = Context.wrap(i); - const res = eventPlugins.map(e => { - return (>e).execute( - [ctx, ['slash', i.options]] - , controller); - }) as Awaited>[]; - //Possible unsafe cast - // could result in the promises not being resolved - return of({ type: CommandType.Slash, res, mod, ctx }); + return mod$(CommandType.Slash).pipe( + concatMap(m => { + const ctx = Context.wrap(i); + return from(m.onEvent.map(e => e.execute( + [ctx, ['slash', i.options]], + controller + ))); + }), + map( res => ({ mod, res })) + ); }, ) - .when( - () => P._, - (ctx: UserCtxInt | MessageCtxInt) => { - //Kinda hackish - const res = eventPlugins.map(e => { - return e.execute( - [ctx] as UnionToTuple + //Todo: refactor so that we dont have to have two separate branches. They're near identical!! + .when(isMessageCtxMenuCmd, ctx => { + return mod$(CommandType.MenuMsg).pipe( + concatMap(m => { + return from(m.onEvent.map(e => e.execute( + [ctx], + controller + ))); + }), + map( res => ({ mod, res })) + ); + const res = eventPlugins.map(e => { + return (>e).execute([ctx] , controller); }) as Awaited>[]; + //Possible unsafe cast + // could result in the promises not being resolved return of({ type: mod.type, res, mod, ctx }); }, ) + .when(isUserContextMenuCmd, ctx => { + const res = eventPlugins.map( e=> (>e).execute([ctx] + , controller) + ) as Awaited>[]; + //Possible unsafe cast + // could result in the promises not being resolved + return of({ type: mod.type, res, mod, ctx }); + }) .run(); } diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index e61b3314..787d6c8c 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -6,7 +6,7 @@ import type { Module, ModuleDefs } from '../structures/module'; import { correctModuleType } from '../utilities/predicates'; export function filterCorrectModule(cmdType: T) { - return (src: Observable) => + return (src: Observable) => new Observable(subscriber => { return src.subscribe({ next(mod) { diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index c387b391..93ef4899 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -50,9 +50,6 @@ export type EventPlugin = { { execute: (event: Parameters, controller: Controller) => Awaitable>; }>; -export type EventPluginType = { - [K in CommandType] : EventPlugin -} export function plugins(...plug: CommandPlugin[]): CommandPlugin[]; export function plugins(...plug: EventPlugin[]): EventPlugin[]; diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index edcce537..26f932b1 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -49,7 +49,7 @@ export type ContextMenuUser = { export type ContextMenuMsg = { type: CommandType.MenuMsg; - onEvent: EventPlugin[]; + onEvent: EventPlugin[]; plugins: CommandPlugin[]; } & Override Awaitable }>; diff --git a/src/handler/utilities/predicates.ts b/src/handler/utilities/predicates.ts index a868a7b0..6157606e 100644 --- a/src/handler/utilities/predicates.ts +++ b/src/handler/utilities/predicates.ts @@ -1,9 +1,7 @@ import type { Module, ModuleDefs } from '../structures/module'; import type { ChatInputCommandInteraction, CommandInteraction } from 'discord.js'; -import type { EventPlugin } from '../../../dist'; -import { CommandType } from '../sern'; -import type { EventPluginType } from '../plugins/plugin'; import type { ButtonInteraction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; +import type { MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js'; export function correctModuleType( @@ -22,4 +20,11 @@ export function isButton(i : MessageComponentInteraction) : i is ButtonInteracti } export function isSelectMenu(i : MessageComponentInteraction) : i is SelectMenuInteraction { return i.isSelectMenu(); +} +export function isMessageCtxMenuCmd(i : CommandInteraction) : i is MessageContextMenuCommandInteraction { + return i.isMessageContextMenuCommand(); +} + +export function isUserContextMenuCmd(i : CommandInteraction) : i is UserContextMenuCommandInteraction { + return i.isUserContextMenuCommand(); } \ No newline at end of file From 97907b746fc94d6e8b65e2fec1cce4b0c3160491 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 02:03:05 -0500 Subject: [PATCH 042/128] feat: finished interactionCreate.ts handling? (need test) --- src/handler/events/interactionCreate.ts | 94 +++++++++++++----------- src/handler/events/observableHandling.ts | 3 - 2 files changed, 51 insertions(+), 46 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 79773ec5..b2282da8 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,5 +1,5 @@ import type { CommandInteraction, Interaction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; -import { concatMap, from, fromEvent, map, Observable, of, throwError } from 'rxjs'; +import { concatMap, fromEvent, map, Observable, of, throwError } from 'rxjs'; import type Wrapper from '../structures/wrapper'; import * as Files from '../utilities/readFile'; import { match } from 'ts-pattern'; @@ -7,7 +7,7 @@ import { SernError } from '../structures/errors'; import Context from '../structures/context'; import type { Result } from 'ts-results'; import { CommandType, controller } from '../sern'; -import type { Module } from '../structures/module'; +import type { Module, ModuleDefs} from '../structures/module'; import type { EventPlugin } from '../plugins/plugin'; import { isButton, @@ -27,48 +27,42 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command const mod$ = (cmdTy : T) => of(mod).pipe( filterCorrectModule(cmdTy) ); - const eventPlugins = mod.onEvent; + return match(interaction) .when(isChatInputCommand, i => { - return mod$(CommandType.Slash).pipe( - concatMap(m => { - const ctx = Context.wrap(i); - return from(m.onEvent.map(e => e.execute( - [ctx, ['slash', i.options]], - controller - ))); - }), - map( res => ({ mod, res })) - ); + const ctx = Context.wrap(i); + return mod$(CommandType.Slash).pipe( + concatMap(m => { + return of(m.onEvent.map(e => e.execute( + [ctx, ['slash', i.options]], + controller + ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx, ['slash', i.options]); } }) )); + }), + ); }, ) //Todo: refactor so that we dont have to have two separate branches. They're near identical!! + //Only thing that differs is type of interaction .when(isMessageCtxMenuCmd, ctx => { return mod$(CommandType.MenuMsg).pipe( concatMap(m => { - return from(m.onEvent.map(e => e.execute( + return of(m.onEvent.map(e => e.execute( [ctx], controller - ))); + ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); }), - map( res => ({ mod, res })) ); - const res = eventPlugins.map(e => { - return (>e).execute([ctx] - , controller); - }) as Awaited>[]; - //Possible unsafe cast - // could result in the promises not being resolved - return of({ type: mod.type, res, mod, ctx }); }, ) .when(isUserContextMenuCmd, ctx => { - const res = eventPlugins.map( e=> (>e).execute([ctx] - , controller) - ) as Awaited>[]; - //Possible unsafe cast - // could result in the promises not being resolved - return of({ type: mod.type, res, mod, ctx }); + return mod$(CommandType.MenuUser).pipe( + concatMap(m => { + return of(m.onEvent.map(e => e.execute( + [ctx], + controller + ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); + }), + ); }) .run(); } @@ -80,24 +74,34 @@ function messageComponentInteractionHandler( if (mod === undefined) { return throwError(() => SernError.UndefinedModule); } - const eventPlugins = mod.onEvent; + const mod$ = (ty : T) => of(mod).pipe( filterCorrectModule(ty)); + //Todo: refactor so that we dont have to have two separate branches. They're near identical!! + //Only thing that differs is type of interaction return match(interaction) .when(isButton, ctx => { - const res = eventPlugins.map(e => { - return (>e).execute([ctx], controller); - }) as Awaited>[]; - return of({ type: mod.type, res, mod, ctx }); + return mod$(CommandType.Button).pipe( + concatMap(m => { + return of(m.onEvent.map(e => e.execute( + [ctx], + controller + ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); + }), + ); }) .when(isSelectMenu, (ctx: SelectMenuInteraction) => { - const res = eventPlugins.map(e => { - return (>e).execute([ctx], controller); - }) as Awaited>[]; - return of({ type: mod.type, res, mod, ctx }); + return mod$(CommandType.MenuSelect).pipe( + concatMap(m => { + return of(m.onEvent.map(e => e.execute( + [ctx], + controller + ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); + }), + ); }) .otherwise(() => throwError(() => SernError.NotSupportedInteraction)); } -export const onInteractionCreate = (wrapper: Wrapper) => { +export function onInteractionCreate (wrapper: Wrapper) { const { client } = wrapper; const interactionEvent$ = >fromEvent(client, 'interactionCreate'); @@ -119,10 +123,14 @@ export const onInteractionCreate = (wrapper: Wrapper) => { return messageComponentInteractionHandler(modul, interaction); } else return throwError(() => SernError.NotSupportedInteraction); }), - ) - .subscribe(m => { - m; + ).subscribe({ + next({m, res, execute}) { + // execute(); + }, + error(err) { + return; + } }); -}; +} diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index 787d6c8c..ffcf42c8 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -13,9 +13,6 @@ export function filterCorrectModule(cmdType: T) { if (correctModuleType(mod, cmdType)) { subscriber.next(mod); } else { - if (mod === undefined) { - return throwError(() => SernError.UndefinedModule); - } return throwError(() => SernError.MismatchModule); } }, From 89ef2aaeb15e96c652b37002b00fe2b68c5f1f8f Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 10:39:19 +0300 Subject: [PATCH 043/128] chore: Updated CONTRIBUTING.md file --- .github/CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 685cb74c..8e8bdaee 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -30,7 +30,7 @@ threatening, offensive, or harmful. ### Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at [INSERT EMAIL ADDRESS]. All +reported by contacting the project team at our [discord server](https://discord.com/invite/QgnfxWzrcj). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. @@ -42,8 +42,8 @@ members of the project's leadership. ### Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +This contributing guidelines is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file +[version]: http://contributor-covenant.org/version/1/4/ From 6c1130dcc20d5a856e4b9be44c1875b324caecdc Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 12:44:57 +0300 Subject: [PATCH 044/128] chore: Updated credits --- src/types/handler.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/types/handler.ts b/src/types/handler.ts index 422f525a..eb0ef6d7 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -4,13 +4,14 @@ import type { MessagePayload, MessageOptions, ClientEvents, - Awaitable, + Awaitable } from 'discord.js'; // Anything that can be sent in a `#send` or `#reply` export type possibleOutput = T | (MessagePayload & MessageOptions); export type Nullish = T | undefined | null; -// Thanks @cursorsdottsx + +// Thanks to @kelsny export type ParseType = { [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never; }[keyof T]; @@ -23,6 +24,6 @@ export type DiscordEvent = export type SlashOptions = Omit; -//https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l +// Source: https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l export type Override = Omit & T2; From ea9554cf48b9761dd51ef05f7bbf6a1e43ae5700 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 16:37:35 +0300 Subject: [PATCH 045/128] chore(NPM): Prepared package.json for release --- package.json | 55 +++++++++++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 22 deletions(-) diff --git a/package.json b/package.json index 5033a4d6..16838e3b 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,9 @@ { - "name": "sern-handler", - "version": "0.1.0", - "description": "", + "name": "@sern/handler", + "version": "1.0.0", + "description": "Powerful DiscordJS framework for better & easier bot development.", "main": "dist/index.js", - "scripts": { + "scripts": { "compile": "tsc", "watch": "tsc -w", "lint": "eslint src/**/*.ts", @@ -11,31 +11,42 @@ "release": "standard-version && git push --follow-tags", "test": "jest --coverage --verbose", "commit": "cz", - "docs": "typedoc src/index.ts --out .typedoc" + "docs" : "typedoc src/index.ts --out docs", + "format": "prettier --check ./src ./tests ./README.md" }, - "keywords": [], - "author": "", - "license": "ISC", + "keywords": [ + "sern-handler", + "sern", + "handler", + "sern handler", + "wrapper", + "discord.js", + "framework" + ], + "author": "SernDevs", + "license": "MIT", "dependencies": { "@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/parser": "^5.10.2", - "discord.js": "^14.0.0-dev.1647259751.2297c2b", - "eslint": "^8.8.0", - "prettier": "^2.5.1", - "rxjs": "^7.5.5", + "dayjs": "^1.10.7", + "discord.js": "^13.6.0", "ts-results": "^3.3.0" }, "devDependencies": { - "@babel/core": "^7.17.2", - "@babel/preset-env": "^7.16.11", - "@babel/preset-typescript": "^7.16.7", - "@types/jest": "^27.4.0", - "babel-jest": "^27.5.1", - "cz-conventional-changelog": "^3.0.1", - "jest": "^27.5.1", - "standard-version": "^9.3.2", - "typedoc": "^0.22.11", - "typescript": "^4.5.5" + "eslint": "8.15.0", + "@typescript-eslint/parser": "5.24.0", + "@typescript-eslint/eslint-plugin": "5.24.0", + "@babel/core": "7.17.12", + "@babel/preset-env": "7.17.12", + "@babel/preset-typescript": "7.17.12", + "@types/jest": "27.5.1", + "babel-jest": "27.5.1", + "cz-conventional-changelog": "3.3.0", + "jest": "27.5.1", + "prettier": "2.6.2", + "standard-version": "9.5.0", + "typedoc": "0.22.15", + "typescript": "4.6.4" }, "config": { "commitizen": { From 35de450e304681bd58013c917d46bf473ffdeea1 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 18:17:42 +0300 Subject: [PATCH 046/128] revert: Some changes --- LICENSE.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 18f6a203..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -**Copyright (C) 2022 Sern** - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -End license text. From 55bb5ebd38f2714d95580849cee52b7760c776e8 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 18:23:06 +0300 Subject: [PATCH 047/128] revert: Revert back to MIT LICENSE (#50) --- LICENSE.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..a668bd1c --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,23 @@ +MIT License + +**Copyright (c) 2022 Sern** + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +End license text. From e5d9b02b005dba24d6dffe402e87cd271e0dc2ae Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 18:25:45 +0300 Subject: [PATCH 048/128] chore: Updated LICENSE boilerplate --- src/types/handler.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/types/handler.ts b/src/types/handler.ts index eb0ef6d7..b2fb8033 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -1,3 +1,10 @@ +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- + */ import type { CommandInteractionOptionResolver, From effe0667f3efbfc139ccc63db27cbd7cdf9b00e2 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 18:31:54 +0300 Subject: [PATCH 049/128] style: Improved comments --- .../modules/commands/moduleHandler.ts | 32 +++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/src/handler/structures/modules/commands/moduleHandler.ts b/src/handler/structures/modules/commands/moduleHandler.ts index caf1e018..2a1d263d 100644 --- a/src/handler/structures/modules/commands/moduleHandler.ts +++ b/src/handler/structures/modules/commands/moduleHandler.ts @@ -1,24 +1,36 @@ import { CommandType } from '../../../sern'; -import type { TextCommand, BothCommand, ButtonCommand, SlashCommand, ContextMenuMsg, ContextMenuUser, SelectMenuCommand } from './module'; -//https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union +import type { + TextCommand, + BothCommand, + ButtonCommand, + SlashCommand, + ContextMenuMsg, + ContextMenuUser, + SelectMenuCommand +} from './module'; + +// Source: https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union // Explicit Module Definitions for mapping export type ModuleDefs = { - [CommandType.TEXT] : TextCommand, - [CommandType.SLASH] : SlashCommand, - [CommandType.BOTH] : BothCommand, - [CommandType.MENU_MSG] : ContextMenuMsg, - [CommandType.MENU_USER] : ContextMenuUser, - [CommandType.BUTTON] : ButtonCommand, + [CommandType.TEXT] : TextCommand, + [CommandType.SLASH] : SlashCommand, + [CommandType.BOTH] : BothCommand, + [CommandType.MENU_MSG] : ContextMenuMsg, + [CommandType.MENU_USER] : ContextMenuUser, + [CommandType.BUTTON] : ButtonCommand, [CommandType.MENU_SELECT] : SelectMenuCommand } -//Keys of ModuleDefs +// Keys of ModuleDefs export type ModuleType = keyof ModuleDefs; + // The keys mapped to a constructed union with its type export type ModuleStates = { [ K in ModuleType ] : { type : K } & ModuleDefs[K] }; + // A handler callback that is called on each ModuleDef export type HandlerCallback = ( params : ModuleStates[K] ) => unknown; -//An object that acts as the mapped object to handler + +// An object that acts as the mapped object to handler export type ModuleHandlers = { [K in ModuleType] : HandlerCallback }; From 3f1f93c7d56503b3021d1821532b2d709acebbaf Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 18:32:54 +0300 Subject: [PATCH 050/128] style: Updated comments --- src/handler/structures/modules/commands/module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/structures/modules/commands/module.ts b/src/handler/structures/modules/commands/module.ts index 33147845..f479839c 100644 --- a/src/handler/structures/modules/commands/module.ts +++ b/src/handler/structures/modules/commands/module.ts @@ -3,7 +3,7 @@ import type { Override } from '../../../../types/handler'; import type { CommandType } from '../../../sern'; import type { BaseModule } from '../module'; -//possible refactoring to interfaces and not types +// TODO: Possible refactoring to interfaces and not types export type TextCommand = { type : CommandType.TEXT; alias : string[] | [], From b26650818e2c193c326356359b38412117ea6186 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 11:31:35 -0500 Subject: [PATCH 051/128] fix: Non-exhaustiveness led to commands not registering readyEvent.ts --- src/handler/events/interactionCreate.ts | 22 +++++++++------------- src/handler/events/messageEvent.ts | 4 ++-- src/handler/events/observableHandling.ts | 5 ++++- src/handler/events/readyEvent.ts | 21 +++++++++++++++++---- src/handler/utilities/predicates.ts | 7 ++++++- 5 files changed, 38 insertions(+), 21 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index b2282da8..f91f883e 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -21,9 +21,6 @@ import { filterCorrectModule } from './observableHandling'; //TODO : atm, i have to cast for every interaction. is there a way to not cast? // maybe pass it through an observable function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { - if (mod === undefined) { - return throwError(() => SernError.UndefinedModule); - } const mod$ = (cmdTy : T) => of(mod).pipe( filterCorrectModule(cmdTy) ); @@ -33,10 +30,11 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command const ctx = Context.wrap(i); return mod$(CommandType.Slash).pipe( concatMap(m => { + console.log(m); return of(m.onEvent.map(e => e.execute( [ctx, ['slash', i.options]], controller - ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx, ['slash', i.options]); } }) )); + ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx, ['slash', i.options]); } }) )); }), ); }, @@ -49,7 +47,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command return of(m.onEvent.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); + ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }, @@ -60,7 +58,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command return of(m.onEvent.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); + ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }) @@ -71,9 +69,7 @@ function messageComponentInteractionHandler( mod: Module | undefined, interaction: MessageComponentInteraction, ) { - if (mod === undefined) { - return throwError(() => SernError.UndefinedModule); - } + const mod$ = (ty : T) => of(mod).pipe( filterCorrectModule(ty)); //Todo: refactor so that we dont have to have two separate branches. They're near identical!! //Only thing that differs is type of interaction @@ -84,7 +80,7 @@ function messageComponentInteractionHandler( return of(m.onEvent.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); + ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }) @@ -94,7 +90,7 @@ function messageComponentInteractionHandler( return of(m.onEvent.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { m.execute(ctx); } }) )); + ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }) @@ -125,10 +121,10 @@ export function onInteractionCreate (wrapper: Wrapper) { }), ).subscribe({ next({m, res, execute}) { - // execute(); + console.log(res); }, error(err) { - return; + console.log(err); } }); diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index bac6f12b..4671c90d 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -1,5 +1,5 @@ import type { Message } from 'discord.js'; -import { concatMap, from, fromEvent, map, Observable, of } from 'rxjs'; +import { concatMap, filter, from, fromEvent, map, Observable, of } from 'rxjs'; import { Err } from 'ts-results'; import type { Args } from '../..'; import { CommandType, controller } from '../sern'; @@ -32,7 +32,7 @@ export const onMessageCreate = (wrapper: Wrapper) => { concatMap(payload => of(payload.mod).pipe( filterCorrectModule(CommandType.Text), // fix for BothCommand - map(textCommand => ({ ...payload, mod: textCommand })), + map(mod => ({ ...payload, mod })), ), ), ); diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index ffcf42c8..7866a7d0 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -6,10 +6,13 @@ import type { Module, ModuleDefs } from '../structures/module'; import { correctModuleType } from '../utilities/predicates'; export function filterCorrectModule(cmdType: T) { - return (src: Observable) => + return (src: Observable) => new Observable(subscriber => { return src.subscribe({ next(mod) { + if (mod === undefined) { + return throwError(() => SernError.UndefinedModule); + } if (correctModuleType(mod, cmdType)) { subscriber.next(mod); } else { diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index d1d43798..fe8d6a3c 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -9,6 +9,8 @@ import type { Awaitable } from 'discord.js'; import type { Module } from '../structures/module'; import { match } from 'ts-pattern'; import { ApplicationCommandType, ComponentType } from 'discord.js'; +import { Err, Ok } from 'ts-results'; +import { SernError } from '../structures/errors'; export const onReady = (wrapper: Wrapper) => { const { client, commands } = wrapper; @@ -56,7 +58,10 @@ export const onReady = (wrapper: Wrapper) => { .subscribe(({ mod, cmdPluginsRes }) => { const loadedPluginsCorrectly = cmdPluginsRes.every(res => res.execute.ok); if (loadedPluginsCorrectly) { - registerModule(mod); + const res = registerModule(mod); + if(res.err) { + throw Error(SernError.NonValidModuleType); + } } else { console.log(`Failed to load command ${mod.name!}`); console.log(mod); @@ -64,30 +69,38 @@ export const onReady = (wrapper: Wrapper) => { }); }; -function registerModule(mod: Module) { +function registerModule(mod: Module) : Result { const name = mod.name!; - match(mod) + return match(mod) .with({ type: CommandType.Text }, mod => { mod.alias.forEach(a => Files.TextCommands.aliases.set(a, mod)); Files.TextCommands.text.set(name, mod); + return Ok.EMPTY; }) .with({ type: CommandType.Slash }, mod => { Files.ApplicationCommands[ApplicationCommandType.ChatInput].set(name, mod); + return Ok.EMPTY; }) .with({ type: CommandType.Both }, mod => { Files.BothCommands.set(name, mod); mod.alias.forEach(a => Files.TextCommands.aliases.set(a, mod)); + return Ok.EMPTY; }) .with({ type: CommandType.MenuUser }, mod => { Files.ApplicationCommands[ApplicationCommandType.User].set(name, mod); + return Ok.EMPTY; }) .with({ type: CommandType.MenuMsg }, mod => { Files.ApplicationCommands[ApplicationCommandType.Message].set(name, mod); + return Ok.EMPTY; }) .with({ type: CommandType.Button }, mod => { Files.ApplicationCommands[ComponentType.Button].set(name, mod); + return Ok.EMPTY; }) .with({ type: CommandType.MenuSelect }, mod => { Files.MessageCompCommands[ComponentType.SelectMenu].set(name, mod); - }); + return Ok.EMPTY; + }) + .otherwise(() => Err.EMPTY); } diff --git a/src/handler/utilities/predicates.ts b/src/handler/utilities/predicates.ts index 6157606e..d4fd3c6f 100644 --- a/src/handler/utilities/predicates.ts +++ b/src/handler/utilities/predicates.ts @@ -1,5 +1,5 @@ import type { Module, ModuleDefs } from '../structures/module'; -import type { ChatInputCommandInteraction, CommandInteraction } from 'discord.js'; +import type { Awaitable, ChatInputCommandInteraction, CommandInteraction } from 'discord.js'; import type { ButtonInteraction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; import type { MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js'; @@ -27,4 +27,9 @@ export function isMessageCtxMenuCmd(i : CommandInteraction) : i is MessageContex export function isUserContextMenuCmd(i : CommandInteraction) : i is UserContextMenuCommandInteraction { return i.isUserContextMenuCommand(); +} + +function isPromise(promiseLike : Awaitable) : promiseLike is Promise { + const keys = new Set(Object.keys(promiseLike)); + return keys.has('then') && keys.has('catch'); } \ No newline at end of file From c8c0c841db2423e29d69bbc1a3ab590bfebb5d5b Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 12:11:00 -0500 Subject: [PATCH 052/128] feat: Add DefinetlyDefined type, more todo statements --- src/handler/events/interactionCreate.ts | 4 +--- src/handler/events/messageEvent.ts | 3 ++- src/handler/events/readyEvent.ts | 7 ++++--- src/types/handler.ts | 4 +++- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index f91f883e..557ec7b2 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -18,8 +18,6 @@ import { } from '../utilities/predicates'; import { filterCorrectModule } from './observableHandling'; -//TODO : atm, i have to cast for every interaction. is there a way to not cast? -// maybe pass it through an observable function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { const mod$ = (cmdTy : T) => of(mod).pipe( filterCorrectModule(cmdTy) @@ -28,9 +26,9 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command return match(interaction) .when(isChatInputCommand, i => { const ctx = Context.wrap(i); + //SUPPORT COMMANDTYPE.BOTH return mod$(CommandType.Slash).pipe( concatMap(m => { - console.log(m); return of(m.onEvent.map(e => e.execute( [ctx, ['slash', i.options]], controller diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 4671c90d..6a0b4765 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -31,7 +31,8 @@ export const onMessageCreate = (wrapper: Wrapper) => { const ensureModuleType$ = processMessage$.pipe( concatMap(payload => of(payload.mod).pipe( - filterCorrectModule(CommandType.Text), // fix for BothCommand + //SUPPORT COMMANDTYPE.BOTH + filterCorrectModule(CommandType.Text), map(mod => ({ ...payload, mod })), ), ), diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index fe8d6a3c..61217c80 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -11,6 +11,7 @@ import { match } from 'ts-pattern'; import { ApplicationCommandType, ComponentType } from 'discord.js'; import { Err, Ok } from 'ts-results'; import { SernError } from '../structures/errors'; +import type { DefinetlyDefined, Override } from '../../types/handler'; export const onReady = (wrapper: Wrapper) => { const { client, commands } = wrapper; @@ -39,7 +40,7 @@ export const onReady = (wrapper: Wrapper) => { ( concat(ready$, processPlugins$) as Observable<{ - mod: Module; + mod: DefinetlyDefined; cmdPluginsRes: { execute: Awaitable>; type: PluginType.Command; @@ -69,8 +70,8 @@ export const onReady = (wrapper: Wrapper) => { }); }; -function registerModule(mod: Module) : Result { - const name = mod.name!; +function registerModule(mod: DefinetlyDefined) : Result { + const name = mod.name; return match(mod) .with({ type: CommandType.Text }, mod => { mod.alias.forEach(a => Files.TextCommands.aliases.set(a, mod)); diff --git a/src/types/handler.ts b/src/types/handler.ts index bf94fbe0..487d5900 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -29,4 +29,6 @@ export type UnionToTuple = T extends readonly [infer V, infer S] ? [V, S] : [V] : never - : never; \ No newline at end of file + : never; + +export type DefinetlyDefined = T & Override \ No newline at end of file From 430315ad02060121e75604aee40c246c71a7e8d2 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 13:16:27 -0500 Subject: [PATCH 053/128] feat: Aliases optional --- src/handler/events/readyEvent.ts | 10 +++++----- src/handler/structures/module.ts | 4 ++-- src/types/handler.ts | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 61217c80..c1bb14ca 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -11,7 +11,7 @@ import { match } from 'ts-pattern'; import { ApplicationCommandType, ComponentType } from 'discord.js'; import { Err, Ok } from 'ts-results'; import { SernError } from '../structures/errors'; -import type { DefinetlyDefined, Override } from '../../types/handler'; +import type { DefinitelyDefined } from '../../types/handler'; export const onReady = (wrapper: Wrapper) => { const { client, commands } = wrapper; @@ -40,7 +40,7 @@ export const onReady = (wrapper: Wrapper) => { ( concat(ready$, processPlugins$) as Observable<{ - mod: DefinetlyDefined; + mod: DefinitelyDefined; cmdPluginsRes: { execute: Awaitable>; type: PluginType.Command; @@ -70,11 +70,11 @@ export const onReady = (wrapper: Wrapper) => { }); }; -function registerModule(mod: DefinetlyDefined) : Result { +function registerModule(mod: DefinitelyDefined) : Result { const name = mod.name; return match(mod) .with({ type: CommandType.Text }, mod => { - mod.alias.forEach(a => Files.TextCommands.aliases.set(a, mod)); + mod.alias?.forEach(a => Files.TextCommands.aliases.set(a, mod)); Files.TextCommands.text.set(name, mod); return Ok.EMPTY; }) @@ -84,7 +84,7 @@ function registerModule(mod: DefinetlyDefined) : Resul }) .with({ type: CommandType.Both }, mod => { Files.BothCommands.set(name, mod); - mod.alias.forEach(a => Files.TextCommands.aliases.set(a, mod)); + mod.alias?.forEach(a => Files.TextCommands.aliases.set(a, mod)); return Ok.EMPTY; }) .with({ type: CommandType.MenuUser }, mod => { diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 26f932b1..ac846119 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -23,7 +23,7 @@ export type TextCommand = { type: CommandType.Text; onEvent: EventPlugin[]; plugins: CommandPlugin[]; - alias: string[] | []; + alias?: string[]; } & BaseModule; export type SlashCommand = { @@ -37,7 +37,7 @@ export type BothCommand = { type: CommandType.Both; onEvent: EventPlugin[] plugins: CommandPlugin[] - alias: string[] | []; + alias?: string[]; options: ApplicationCommandOptionData[] | []; } & BaseModule; diff --git a/src/types/handler.ts b/src/types/handler.ts index 487d5900..893386dd 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -31,4 +31,4 @@ export type UnionToTuple = T extends readonly [infer V, infer S] : never : never; -export type DefinetlyDefined = T & Override \ No newline at end of file +export type DefinitelyDefined = T & Override \ No newline at end of file From 2b81d53503209a738b70d238512c82542d3d88e8 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 13:59:21 -0500 Subject: [PATCH 054/128] feat: Optional plugins to reduce bloat --- src/handler/events/interactionCreate.ts | 20 +++++++++--------- src/handler/events/messageEvent.ts | 4 ++-- src/handler/events/readyEvent.ts | 4 ++-- src/handler/plugins/plugin.ts | 8 +++++-- src/handler/structures/module.ts | 28 ++++++++++++------------- src/handler/utilities/predicates.ts | 14 ++++++++++--- 6 files changed, 45 insertions(+), 33 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 557ec7b2..8e4fb46c 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -29,10 +29,10 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command //SUPPORT COMMANDTYPE.BOTH return mod$(CommandType.Slash).pipe( concatMap(m => { - return of(m.onEvent.map(e => e.execute( + return of(m.onEvent?.map(e => e.execute( [ctx, ['slash', i.options]], controller - ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx, ['slash', i.options]); } }) )); + )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx, ['slash', i.options]); } }) )); }), ); }, @@ -42,10 +42,10 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command .when(isMessageCtxMenuCmd, ctx => { return mod$(CommandType.MenuMsg).pipe( concatMap(m => { - return of(m.onEvent.map(e => e.execute( + return of(m.onEvent?.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }, @@ -53,10 +53,10 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command .when(isUserContextMenuCmd, ctx => { return mod$(CommandType.MenuUser).pipe( concatMap(m => { - return of(m.onEvent.map(e => e.execute( + return of(m.onEvent?.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }) @@ -75,20 +75,20 @@ function messageComponentInteractionHandler( .when(isButton, ctx => { return mod$(CommandType.Button).pipe( concatMap(m => { - return of(m.onEvent.map(e => e.execute( + return of(m.onEvent?.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }) .when(isSelectMenu, (ctx: SelectMenuInteraction) => { return mod$(CommandType.MenuSelect).pipe( concatMap(m => { - return of(m.onEvent.map(e => e.execute( + return of(m.onEvent?.map(e => e.execute( [ctx], controller - ))).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); }), ); }) diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 6a0b4765..ce2d079d 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -41,12 +41,12 @@ export const onMessageCreate = (wrapper: Wrapper) => { const processEventPlugins$ = ensureModuleType$.pipe( concatMap(({ ctx, args, mod }) => { const res = Promise.all( - mod.onEvent.map(ePlug => { + mod.onEvent?.map(ePlug => { if ((ePlug.modType & mod.type) === 0) { return Err.EMPTY; } return ePlug.execute([ctx, args], controller); - }), + }) ?? [], ); return from(res).pipe(map(res => ({ mod, ctx, args, res }))); }), diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index c1bb14ca..0f0c1b31 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -27,13 +27,13 @@ export const onReady = (wrapper: Wrapper) => { ); const processPlugins$ = processCommandFiles$.pipe( concatMap((mod) => { - const cmdPluginsRes = mod.plugins.map(plug => { + const cmdPluginsRes = mod.plugins?.map(plug => { return { ...plug, name: plug?.name ?? 'Unnamed Plugin', execute: plug.execute(client, mod, controller), }; - }); + }) ?? []; return of({ mod, cmdPluginsRes }); }), ); diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 93ef4899..52ed9a9c 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -58,6 +58,10 @@ export function plugins(...plug: CommandPlugin[] | EventP return plug; } -export function sernModule(mod: ModuleDefs[T]): Module { - return mod; +export function sernModule(plugins : CommandPlugin[], onEvent: EventPlugin[], mod: Omit) { + // return { + // plugins, + // onEvent, + // ...mod, + // }; } diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index ac846119..fbc9dbc3 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -21,48 +21,48 @@ export interface BaseModule { //possible refactoring types into interfaces and not types export type TextCommand = { type: CommandType.Text; - onEvent: EventPlugin[]; - plugins: CommandPlugin[]; + onEvent?: EventPlugin[] + plugins?: CommandPlugin[]; alias?: string[]; } & BaseModule; export type SlashCommand = { type: CommandType.Slash; - onEvent: EventPlugin[]; - plugins: CommandPlugin[]; + onEvent?: EventPlugin[] + plugins?: (CommandPlugin)[]; options: ApplicationCommandOptionData[] | []; } & BaseModule; export type BothCommand = { type: CommandType.Both; - onEvent: EventPlugin[] - plugins: CommandPlugin[] + onEvent?: EventPlugin[] + plugins?: (CommandPlugin)[] alias?: string[]; options: ApplicationCommandOptionData[] | []; } & BaseModule; export type ContextMenuUser = { type: CommandType.MenuUser; - onEvent: EventPlugin[]; - plugins: CommandPlugin[]; + onEvent?: EventPlugin[]; + plugins?: (CommandPlugin)[]; } & Override Awaitable }>; export type ContextMenuMsg = { type: CommandType.MenuMsg; - onEvent: EventPlugin[]; - plugins: CommandPlugin[]; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; } & Override Awaitable }>; export type ButtonCommand = { type: CommandType.Button; - onEvent: EventPlugin[]; - plugins: CommandPlugin[]; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; } & Override Awaitable }>; export type SelectMenuCommand = { type: CommandType.MenuSelect; - onEvent: EventPlugin[]; - plugins: CommandPlugin[]; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; } & Override Awaitable }>; export type Module = diff --git a/src/handler/utilities/predicates.ts b/src/handler/utilities/predicates.ts index d4fd3c6f..359c3611 100644 --- a/src/handler/utilities/predicates.ts +++ b/src/handler/utilities/predicates.ts @@ -1,7 +1,15 @@ import type { Module, ModuleDefs } from '../structures/module'; -import type { Awaitable, ChatInputCommandInteraction, CommandInteraction } from 'discord.js'; -import type { ButtonInteraction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; -import type { MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js'; +import type { + Awaitable, + ButtonInteraction, + ChatInputCommandInteraction, + CommandInteraction, + MessageComponentInteraction, + MessageContextMenuCommandInteraction, + SelectMenuInteraction, + UserContextMenuCommandInteraction, +} from 'discord.js'; + export function correctModuleType( From 53bc080a290fd5064993aa0d98497d4b239ac8f3 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 14:49:18 -0500 Subject: [PATCH 055/128] feat: better looking typings for modules --- src/handler/events/interactionCreate.ts | 4 +-- src/handler/structures/module.ts | 36 +++++++++++++++---------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 8e4fb46c..acf4b099 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -5,10 +5,8 @@ import * as Files from '../utilities/readFile'; import { match } from 'ts-pattern'; import { SernError } from '../structures/errors'; import Context from '../structures/context'; -import type { Result } from 'ts-results'; import { CommandType, controller } from '../sern'; -import type { Module, ModuleDefs} from '../structures/module'; -import type { EventPlugin } from '../plugins/plugin'; +import type { Module } from '../structures/module'; import { isButton, isChatInputCommand, diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index fbc9dbc3..9684142c 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -11,59 +11,67 @@ import type { Args } from '../../types/handler'; import type { CommandType } from '../sern'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; +import { Base } from 'discord.js'; +import type { PluginType } from '../plugins/plugin'; export interface BaseModule { + type : CommandType | PluginType name?: string; description: string; execute: (ctx: Context, args: Args) => Awaitable; } //possible refactoring types into interfaces and not types -export type TextCommand = { +export type TextCommand = Override[] plugins?: CommandPlugin[]; alias?: string[]; -} & BaseModule; +}>; -export type SlashCommand = { +export type SlashCommand = Override[] plugins?: (CommandPlugin)[]; options: ApplicationCommandOptionData[] | []; -} & BaseModule; -export type BothCommand = { +}>; + +export type BothCommand = Override[] plugins?: (CommandPlugin)[] alias?: string[]; options: ApplicationCommandOptionData[] | []; -} & BaseModule; +}>; -export type ContextMenuUser = { +export type ContextMenuUser = Override[]; plugins?: (CommandPlugin)[]; -} & Override Awaitable }>; + execute: (ctx: UserContextMenuCommandInteraction) => Awaitable +}> -export type ContextMenuMsg = { +export type ContextMenuMsg = Override[]; plugins?: CommandPlugin[]; -} & Override Awaitable }>; + execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable +}>; -export type ButtonCommand = { +export type ButtonCommand = Override[]; plugins?: CommandPlugin[]; -} & Override Awaitable }>; + execute: (ctx: ButtonInteraction) => Awaitable +}>; -export type SelectMenuCommand = { +export type SelectMenuCommand = Override[]; plugins?: CommandPlugin[]; -} & Override Awaitable }>; + execute: (ctx: SelectMenuInteraction) => Awaitable +}>; export type Module = | TextCommand From c40b75d333700f2158eb9f22c08bac90fbf6a4e8 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 16:05:35 -0500 Subject: [PATCH 056/128] refactor: Simplify sernModule handler signature --- src/handler/plugins/plugin.ts | 47 ++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 23 deletions(-) diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 52ed9a9c..3abaec4a 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -28,40 +28,41 @@ export enum PluginType { Event = 0b10, } -type executeCmdPlugin = { execute: (wrapper: Wrapper, controller: Controller) => Result }; +type executeCmdPlugin = (controller: Controller) => Result ; -interface BasePlugin extends Override { - type: PluginType; -} +type BasePlugin = Override; -export type CommandPlugin = { +export type CommandPlugin = Override Awaitable>; - }>; + execute: (wrapper: Client, module: Module, controller: Controller) => Awaitable>; +}>; //TODO: rn adding the modType check a little hackish. Find better way to determine the // module type of the event plugin -export type EventPlugin = { +export type EventPlugin = Override, controller: Controller) => Awaitable>; - }>; + execute: (event: Parameters, controller: Controller) => Awaitable>; +}>; -export function plugins(...plug: CommandPlugin[]): CommandPlugin[]; -export function plugins(...plug: EventPlugin[]): EventPlugin[]; -export function plugins(...plug: CommandPlugin[] | EventPlugin[]) { +export function plugins(...plug: (CommandPlugin | EventPlugin)[]) { return plug; } -export function sernModule(plugins : CommandPlugin[], onEvent: EventPlugin[], mod: Omit) { - // return { - // plugins, - // onEvent, - // ...mod, - // }; +export function sernModule( + plugs: (CommandPlugin | EventPlugin)[], mod : ModuleDefs[T] +) : ModuleDefs[T] { + //mod.plugins if defined, warn user to use first parameter + //mod.onEvent if defined, warn user to use first parameter + const plugins = plugs.filter(el => el.type === PluginType.Command); + const onEvent = plugs.filter(el => el.type === PluginType.Event); + return { + plugins, + onEvent, + ...mod + } as unknown as ModuleDefs[T]; } From 5556b2aa0afcb492717fe4f5e09cbf7d9a977058 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 16:14:47 -0500 Subject: [PATCH 057/128] refactor: make ApplicationCommandOptions optional --- src/handler/structures/module.ts | 6 ++---- src/types/handler.ts | 12 +++--------- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 9684142c..9f33d6ca 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -11,7 +11,6 @@ import type { Args } from '../../types/handler'; import type { CommandType } from '../sern'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; -import { Base } from 'discord.js'; import type { PluginType } from '../plugins/plugin'; export interface BaseModule { @@ -33,8 +32,7 @@ export type SlashCommand = Override[] plugins?: (CommandPlugin)[]; - options: ApplicationCommandOptionData[] | []; - + options?: ApplicationCommandOptionData[]; }>; export type BothCommand = Override[] plugins?: (CommandPlugin)[] alias?: string[]; - options: ApplicationCommandOptionData[] | []; + options?: ApplicationCommandOptionData[]; }>; export type ContextMenuUser = Override = Omit & T2; -export type UnionToTuple = T extends readonly [infer V, infer S] - ? V extends V - ? S extends S - ? [V, S] - : [V] - : never - : never; - -export type DefinitelyDefined = T & Override \ No newline at end of file +export type DefinitelyDefined = T & Override; + + From f8987499f605c9cf6a47b328dea3ef2d26959ca3 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 16:18:14 -0500 Subject: [PATCH 058/128] refactor: make description optional --- src/handler/structures/module.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 9f33d6ca..66e205b3 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -47,6 +47,7 @@ export type ContextMenuUser = Override[]; plugins?: (CommandPlugin)[]; + description? : string; execute: (ctx: UserContextMenuCommandInteraction) => Awaitable }> @@ -54,6 +55,7 @@ export type ContextMenuMsg = Override[]; plugins?: CommandPlugin[]; + description? : string; execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable }>; From 82f1bad8fffbb91f6084511b34b9541caa0a4733 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 17:10:01 -0500 Subject: [PATCH 059/128] refactor: Bring CommandType and PluginType to top level --- src/handler/events/interactionCreate.ts | 3 ++- src/handler/events/messageEvent.ts | 3 ++- src/handler/events/readyEvent.ts | 4 ++-- src/handler/plugins/plugin.ts | 14 ++++---------- src/handler/sern.ts | 14 +------------- src/handler/structures/enums.ts | 19 +++++++++++++++++++ src/handler/structures/module.ts | 5 +---- src/handler/structures/structxports.ts | 2 +- 8 files changed, 32 insertions(+), 32 deletions(-) create mode 100644 src/handler/structures/enums.ts diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index acf4b099..a7a5fad6 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -5,7 +5,7 @@ import * as Files from '../utilities/readFile'; import { match } from 'ts-pattern'; import { SernError } from '../structures/errors'; import Context from '../structures/context'; -import { CommandType, controller } from '../sern'; +import { controller } from '../sern'; import type { Module } from '../structures/module'; import { isButton, @@ -15,6 +15,7 @@ import { isUserContextMenuCmd, } from '../utilities/predicates'; import { filterCorrectModule } from './observableHandling'; +import { CommandType } from '../structures/enums'; function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { const mod$ = (cmdTy : T) => of(mod).pipe( diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index ce2d079d..b0948225 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -2,12 +2,13 @@ import type { Message } from 'discord.js'; import { concatMap, filter, from, fromEvent, map, Observable, of } from 'rxjs'; import { Err } from 'ts-results'; import type { Args } from '../..'; -import { CommandType, controller } from '../sern'; +import { controller } from '../sern'; import Context from '../structures/context'; import type Wrapper from '../structures/wrapper'; import { fmt } from '../utilities/messageHelpers'; import * as Files from '../utilities/readFile'; import { filterCorrectModule, ignoreNonBot } from './observableHandling'; +import { CommandType } from '../structures/enums'; export const onMessageCreate = (wrapper: Wrapper) => { const { client, defaultPrefix } = wrapper; diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 0f0c1b31..1ef83198 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -2,8 +2,7 @@ import { concat, concatMap, from, fromEvent, map, Observable, of, skip, take } f import { basename } from 'path'; import * as Files from '../utilities/readFile'; import type Wrapper from '../structures/wrapper'; -import { CommandType, controller } from '../sern'; -import type { PluginType } from '../plugins/plugin'; +import { controller } from '../sern'; import type { Result } from 'ts-results'; import type { Awaitable } from 'discord.js'; import type { Module } from '../structures/module'; @@ -12,6 +11,7 @@ import { ApplicationCommandType, ComponentType } from 'discord.js'; import { Err, Ok } from 'ts-results'; import { SernError } from '../structures/errors'; import type { DefinitelyDefined } from '../../types/handler'; +import { CommandType, PluginType } from '../structures/enums'; export const onReady = (wrapper: Wrapper) => { const { client, commands } = wrapper; diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 3abaec4a..19f6d223 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -13,9 +13,10 @@ import type { Awaitable, Client } from 'discord.js'; import type { Err, Ok, Result } from 'ts-results'; -import type { Module, Override, Wrapper } from '../..'; -import type { CommandType } from '../sern'; +import type { Module, Override } from '../..'; import type { BaseModule, ModuleDefs } from '../structures/module'; +import type { CommandType } from '../structures/enums'; +import { PluginType } from '../structures/enums'; export interface Controller { @@ -23,11 +24,6 @@ export interface Controller { stop: () => Err; } -export enum PluginType { - Command = 0b01, - Event = 0b10, -} - type executeCmdPlugin = (controller: Controller) => Result ; type BasePlugin = Override(...plug: (CommandPlugin | EventPl export function sernModule( plugs: (CommandPlugin | EventPlugin)[], mod : ModuleDefs[T] ) : ModuleDefs[T] { - //mod.plugins if defined, warn user to use first parameter - //mod.onEvent if defined, warn user to use first parameter const plugins = plugs.filter(el => el.type === PluginType.Command); const onEvent = plugs.filter(el => el.type === PluginType.Event); return { plugins, onEvent, ...mod - } as unknown as ModuleDefs[T]; + }; } diff --git a/src/handler/sern.ts b/src/handler/sern.ts index c143fe81..67e02fd1 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -10,6 +10,7 @@ import { onMessageCreate } from './events/messageEvent'; import { onInteractionCreate } from './events/interactionCreate'; import { match, P } from 'ts-pattern'; import { Err, Ok } from 'ts-results'; +import { CommandType } from './structures/enums'; export function init(wrapper: Wrapper) { const { events, client } = wrapper; @@ -27,19 +28,6 @@ function eventObserver(client: Client, events: DiscordEvent[]) { }); } -/** - * @enum { number }; - */ -export enum CommandType { - Text = 0b0000001, - Slash = 0b0000010, - MenuUser = 0b0000100, - MenuMsg = 0b0001000, - Button = 0b0010000, - MenuSelect = 0b0100000, - Both = 0b0000011, -} - export function cmdTypeToDjs(ty: CommandType) { return match(ty) .with(CommandType.Slash, () => ApplicationCommandType.ChatInput) diff --git a/src/handler/structures/enums.ts b/src/handler/structures/enums.ts new file mode 100644 index 00000000..b0d25037 --- /dev/null +++ b/src/handler/structures/enums.ts @@ -0,0 +1,19 @@ +/** + * @enum { number }; + */ +enum CommandType { + Text = 0b0000001, + Slash = 0b0000010, + MenuUser = 0b0000100, + MenuMsg = 0b0001000, + Button = 0b0010000, + MenuSelect = 0b0100000, + Both = 0b0000011, +} + +enum PluginType { + Command = 0b01, + Event = 0b10, +} + +export { CommandType, PluginType }; \ No newline at end of file diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 66e205b3..cd208ee4 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -8,10 +8,9 @@ import type { } from 'discord.js'; import type { Override } from '../../types/handler'; import type { Args } from '../../types/handler'; -import type { CommandType } from '../sern'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; -import type { PluginType } from '../plugins/plugin'; +import { CommandType, PluginType } from './enums'; export interface BaseModule { type : CommandType | PluginType @@ -47,7 +46,6 @@ export type ContextMenuUser = Override[]; plugins?: (CommandPlugin)[]; - description? : string; execute: (ctx: UserContextMenuCommandInteraction) => Awaitable }> @@ -55,7 +53,6 @@ export type ContextMenuMsg = Override[]; plugins?: CommandPlugin[]; - description? : string; execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable }>; diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index 5cc9686f..dcf827c0 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -1,5 +1,5 @@ import Context from './context'; import type { BothCommand, Module, SlashCommand, TextCommand } from './module'; import type Wrapper from './wrapper'; - +export * from './enums'; export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper }; From cf85a5db6413e2b8b42143f70964f7a19789e1ff Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 18:57:01 -0500 Subject: [PATCH 060/128] fix: Fix return type of sernModule --- src/handler/plugins/plugin.ts | 27 ++++++++++++--------------- src/handler/structures/module.ts | 6 +++--- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 19f6d223..15d75e93 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -15,8 +15,8 @@ import type { Awaitable, Client } from 'discord.js'; import type { Err, Ok, Result } from 'ts-results'; import type { Module, Override } from '../..'; import type { BaseModule, ModuleDefs } from '../structures/module'; -import type { CommandType } from '../structures/enums'; -import { PluginType } from '../structures/enums'; +import type { PluginType } from '../structures/enums'; +import type { ValueOf } from 'ts-pattern/dist/types/helpers'; export interface Controller { @@ -24,11 +24,8 @@ export interface Controller { stop: () => Err; } -type executeCmdPlugin = (controller: Controller) => Result ; - type BasePlugin = Override; export type CommandPlugin = Override = Override = Override, controller: Controller) => Awaitable>; }>; - -export function plugins(...plug: (CommandPlugin | EventPlugin)[]) { +export function plugins(...plug: CommandPlugin[]) { return plug; } -export function sernModule( - plugs: (CommandPlugin | EventPlugin)[], mod : ModuleDefs[T] -) : ModuleDefs[T] { - const plugins = plugs.filter(el => el.type === PluginType.Command); - const onEvent = plugs.filter(el => el.type === PluginType.Event); +type ModuleNoPlugins = ValueOf<{ + [T in keyof ModuleDefs] : Omit +}> + +export function sernModule( + plugins: (CommandPlugin)[], mod : ModuleNoPlugins +) : Module { return { plugins, - onEvent, ...mod }; } diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index cd208ee4..ec1194a1 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -30,14 +30,14 @@ export type TextCommand = Override[] - plugins?: (CommandPlugin)[]; + plugins?: CommandPlugin[]; options?: ApplicationCommandOptionData[]; }>; export type BothCommand = Override[] - plugins?: (CommandPlugin)[] + plugins?: CommandPlugin[] alias?: string[]; options?: ApplicationCommandOptionData[]; }>; @@ -45,7 +45,7 @@ export type BothCommand = Override[]; - plugins?: (CommandPlugin)[]; + plugins?: CommandPlugin[]; execute: (ctx: UserContextMenuCommandInteraction) => Awaitable }> From 464fc05c1c203cc7f33cd4703f622539c8ebce13 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 20:25:57 -0500 Subject: [PATCH 061/128] refactor: Why is that not assignable bruh --- src/handler/plugins/plugin.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 15d75e93..0c8ec513 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -36,7 +36,6 @@ export type CommandPlugin = Override = Override, controller: Controller) => Awaitable>; }>; @@ -48,6 +47,7 @@ export function plugins(...plug: CommandPlugin[]) { type ModuleNoPlugins = ValueOf<{ [T in keyof ModuleDefs] : Omit }> +//TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH export function sernModule( plugins: (CommandPlugin)[], mod : ModuleNoPlugins @@ -56,4 +56,4 @@ export function sernModule( plugins, ...mod }; -} +} \ No newline at end of file From b9b59197df7d9bbeac3df68ebe6f7cea1ce50677 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 17 May 2022 22:30:20 -0500 Subject: [PATCH 062/128] revert: Re-add plugins overload --- src/handler/events/interactionCreate.ts | 2 +- src/handler/events/messageEvent.ts | 3 --- src/handler/plugins/plugin.ts | 5 ++++- src/handler/utilities/predicates.ts | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index a7a5fad6..56444d77 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -118,7 +118,7 @@ export function onInteractionCreate (wrapper: Wrapper) { }), ).subscribe({ next({m, res, execute}) { - console.log(res); + }, error(err) { console.log(err); diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index b0948225..be4fe778 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -43,9 +43,6 @@ export const onMessageCreate = (wrapper: Wrapper) => { concatMap(({ ctx, args, mod }) => { const res = Promise.all( mod.onEvent?.map(ePlug => { - if ((ePlug.modType & mod.type) === 0) { - return Err.EMPTY; - } return ePlug.execute([ctx, args], controller); }) ?? [], ); diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 0c8ec513..86b9eb4c 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -17,6 +17,7 @@ import type { Module, Override } from '../..'; import type { BaseModule, ModuleDefs } from '../structures/module'; import type { PluginType } from '../structures/enums'; import type { ValueOf } from 'ts-pattern/dist/types/helpers'; +import type { CommandType } from '../..'; export interface Controller { @@ -40,7 +41,9 @@ export type EventPlugin = Override, controller: Controller) => Awaitable>; }>; -export function plugins(...plug: CommandPlugin[]) { +export function plugins(...plug: CommandPlugin[]) : CommandPlugin[]; +export function plugins(...plug: EventPlugin[]) : EventPlugin[]; +export function plugins(...plug: EventPlugin[] | CommandPlugin[]) { return plug; } diff --git a/src/handler/utilities/predicates.ts b/src/handler/utilities/predicates.ts index 359c3611..704aa574 100644 --- a/src/handler/utilities/predicates.ts +++ b/src/handler/utilities/predicates.ts @@ -37,7 +37,7 @@ export function isUserContextMenuCmd(i : CommandInteraction) : i is UserContextM return i.isUserContextMenuCommand(); } -function isPromise(promiseLike : Awaitable) : promiseLike is Promise { +export function isPromise(promiseLike : Awaitable) : promiseLike is Promise { const keys = new Set(Object.keys(promiseLike)); return keys.has('then') && keys.has('catch'); } \ No newline at end of file From 32dbaf1fb434ec2258639e7a0ea4e112729d111e Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 18 May 2022 17:00:57 +0300 Subject: [PATCH 063/128] fix(CODE_OF_CONDUCT): Removed unusual dot --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 9aa60006..102875c8 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,5 +1,5 @@ # Code of Conduct -All participants of SernHandler. are expected to abide by our Code of Conduct, both online and during in-person events that are hosted and/or associated with SernHandler. +All participants of SernHandler are expected to abide by our Code of Conduct, both online and during in-person events that are hosted and/or associated with SernHandler. # The Pledge In the interest of fostering an open and welcoming environment, we pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. From 45056ba6a015212d03891f3b97b2ac82b86e131c Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 18 May 2022 17:08:57 +0300 Subject: [PATCH 064/128] Update package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 16838e3b..019d7574 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@typescript-eslint/eslint-plugin": "^5.10.2", "@typescript-eslint/parser": "^5.10.2", "dayjs": "^1.10.7", - "discord.js": "^13.6.0", + "discord.js": "^14.0.0-dev.1647259751.2297c2b", "ts-results": "^3.3.0" }, "devDependencies": { From b12567a3c816a64e5f770fa3852b45ae8a629548 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 18 May 2022 19:11:47 +0300 Subject: [PATCH 065/128] fix: Resolve conflicts --- .gitignore | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 6e1ef477..b044b7a1 100644 --- a/.gitignore +++ b/.gitignore @@ -79,5 +79,7 @@ typings/ # TypeScript build output dist -# VisualStudio config file -.vs \ No newline at end of file +# VisualStudio Config file +.vs + +# IntelliJ IDEA Config file From 6660aa50c942e156fe9efe29472b242cc55600eb Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 18 May 2022 19:12:17 +0300 Subject: [PATCH 066/128] fix: Resolve conflicts --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index b044b7a1..511e2a8a 100644 --- a/.gitignore +++ b/.gitignore @@ -83,3 +83,4 @@ dist .vs # IntelliJ IDEA Config file +.idea From b8cda351e1f549422692c633255ac1d6c7d78a9b Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 12:57:14 -0500 Subject: [PATCH 067/128] feat: should be able to register other nodejs event emitters --- src/handler/sern.ts | 19 ++++++++++++------- src/handler/structures/wrapper.ts | 4 ++-- src/handler/utilities/predicates.ts | 8 +++++++- src/types/handler.ts | 5 ++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/handler/sern.ts b/src/handler/sern.ts index 67e02fd1..cf581ea7 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -1,4 +1,4 @@ -import type { DiscordEvent } from '../types/handler'; +import type { DiscordEvent, EventEmitterRegister } from '../types/handler'; import { ApplicationCommandType, Client } from 'discord.js'; @@ -11,20 +11,25 @@ import { onInteractionCreate } from './events/interactionCreate'; import { match, P } from 'ts-pattern'; import { Err, Ok } from 'ts-results'; import { CommandType } from './structures/enums'; +import { isDiscordEvent } from './utilities/predicates'; export function init(wrapper: Wrapper) { const { events, client } = wrapper; - if (events !== undefined) eventObserver(client, events); + if (events !== undefined) { + eventObserver(client, events); + } onReady(wrapper); onMessageCreate(wrapper); onInteractionCreate(wrapper); } -//TODO : Add event listener for any other generic node js event emitter -function eventObserver(client: Client, events: DiscordEvent[]) { - events.forEach(([event, cb]) => { - if (event === 'ready') throw Error(SernError.ReservedEvent); - fromEvent(client, event, cb).subscribe(); +function eventObserver(client: Client, events: (DiscordEvent | EventEmitterRegister)[]) { + events.forEach((event) => { + if(isDiscordEvent(event)) { + fromEvent(client, event[0], event[1]).subscribe(); + } else { + fromEvent(event[0], event[1], event[2]).subscribe(); + } }); } diff --git a/src/handler/structures/wrapper.ts b/src/handler/structures/wrapper.ts index 4bfc76c3..bdbf2eda 100644 --- a/src/handler/structures/wrapper.ts +++ b/src/handler/structures/wrapper.ts @@ -1,5 +1,5 @@ import type { Client } from 'discord.js'; -import type { DiscordEvent } from '../../types/handler'; +import type { DiscordEvent, EventEmitterRegister } from '../../types/handler'; /** * An object to be passed into Sern.Handler constructor. @@ -14,7 +14,7 @@ interface Wrapper { readonly client: Client; readonly defaultPrefix?: string; readonly commands: string; - readonly events?: DiscordEvent[]; + readonly events?: (DiscordEvent | EventEmitterRegister)[]; } export default Wrapper; diff --git a/src/handler/utilities/predicates.ts b/src/handler/utilities/predicates.ts index 704aa574..4ba76e5f 100644 --- a/src/handler/utilities/predicates.ts +++ b/src/handler/utilities/predicates.ts @@ -9,6 +9,7 @@ import type { SelectMenuInteraction, UserContextMenuCommandInteraction, } from 'discord.js'; +import type { DiscordEvent, EventEmitterRegister } from '../..'; @@ -40,4 +41,9 @@ export function isUserContextMenuCmd(i : CommandInteraction) : i is UserContextM export function isPromise(promiseLike : Awaitable) : promiseLike is Promise { const keys = new Set(Object.keys(promiseLike)); return keys.has('then') && keys.has('catch'); -} \ No newline at end of file +} + +export function isDiscordEvent(el : DiscordEvent | EventEmitterRegister) : el is DiscordEvent { + return el.length === 2; +} + diff --git a/src/types/handler.ts b/src/types/handler.ts index 58d5079b..87cc4b5e 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -5,7 +5,7 @@ import type { MessageOptions, MessagePayload, } from 'discord.js'; - +import type { EventEmitter } from 'events'; // Anything that can be sent in a `#send` or `#reply` export type possibleOutput = T | (MessagePayload & MessageOptions); export type Nullish = T | undefined | null; @@ -17,6 +17,9 @@ export type ParseType = { export type Args = ParseType<{ text: string[]; slash: SlashOptions }>; export type DiscordEvent = ParseType<{ [K in keyof ClientEvents]: (...args: ClientEvents[K]) => Awaitable }>; +export type EventEmitterRegister = [ emitter: EventEmitter, k : string, cb : (...args: unknown[]) => Awaitable]; + + export type SlashOptions = Omit; From 66b9f51fa73cf07a589671d13ca4c65a9c8193a1 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 13:49:31 -0500 Subject: [PATCH 068/128] fix: Standard for of does not resolve promises. Switched to for await --- src/handler/events/interactionCreate.ts | 43 +++++++++++++++++-------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 56444d77..2d1d457d 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,4 +1,10 @@ -import type { CommandInteraction, Interaction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; +import type { + Awaitable, + CommandInteraction, + Interaction, + MessageComponentInteraction, + SelectMenuInteraction, +} from 'discord.js'; import { concatMap, fromEvent, map, Observable, of, throwError } from 'rxjs'; import type Wrapper from '../structures/wrapper'; import * as Files from '../utilities/readFile'; @@ -10,12 +16,13 @@ import type { Module } from '../structures/module'; import { isButton, isChatInputCommand, - isMessageCtxMenuCmd, + isMessageCtxMenuCmd, isPromise, isSelectMenu, isUserContextMenuCmd, } from '../utilities/predicates'; import { filterCorrectModule } from './observableHandling'; import { CommandType } from '../structures/enums'; +import type { Result } from 'ts-results'; function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { const mod$ = (cmdTy : T) => of(mod).pipe( @@ -31,7 +38,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command return of(m.onEvent?.map(e => e.execute( [ctx, ['slash', i.options]], controller - )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx, ['slash', i.options]); } }) )); + )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx, ['slash', i.options]); } }) )); }), ); }, @@ -44,7 +51,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command return of(m.onEvent?.map(e => e.execute( [ctx], controller - )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); }), ); }, @@ -55,7 +62,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command return of(m.onEvent?.map(e => e.execute( [ctx], controller - )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); }), ); }) @@ -77,7 +84,7 @@ function messageComponentInteractionHandler( return of(m.onEvent?.map(e => e.execute( [ctx], controller - )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); }), ); }) @@ -87,7 +94,7 @@ function messageComponentInteractionHandler( return of(m.onEvent?.map(e => e.execute( [ctx], controller - )) ?? []).pipe(map(res => ({ m, res, execute() { return m.execute(ctx); } }) )); + )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); }), ); }) @@ -117,13 +124,23 @@ export function onInteractionCreate (wrapper: Wrapper) { } else return throwError(() => SernError.NotSupportedInteraction); }), ).subscribe({ - next({m, res, execute}) { - - }, + async next({ mod, res : eventPluginRes, execute}) { + const ePlugArr : Result[] = []; + for await ( const res of eventPluginRes) { + if(isPromise(res)) { + ePlugArr.push(res); + } + ePlugArr.push(res as Awaited>); + } + if(ePlugArr.every(e => e.ok)) { + await execute(); + } else { + console.log(ePlugArr); + console.log(mod, 'failed'); + } + }, error(err) { console.log(err); } }); - - -} +} \ No newline at end of file From 115d1a49b52eb45d9b68ba015f8f734b902e9a60 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 22:29:45 -0500 Subject: [PATCH 069/128] feat: Adding sern event listeners, overriding and typing methods --- src/handler/events/interactionCreate.ts | 6 +++--- src/handler/events/observableHandling.ts | 2 +- src/handler/sernEmitter.ts | 25 ++++++++++++++++++++++++ src/handler/structures/errors.ts | 1 + src/handler/structures/wrapper.ts | 3 ++- src/index.ts | 2 +- 6 files changed, 33 insertions(+), 6 deletions(-) create mode 100644 src/handler/sernEmitter.ts diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 2d1d457d..9505238f 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,5 +1,4 @@ import type { - Awaitable, CommandInteraction, Interaction, MessageComponentInteraction, @@ -28,7 +27,6 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command const mod$ = (cmdTy : T) => of(mod).pipe( filterCorrectModule(cmdTy) ); - return match(interaction) .when(isChatInputCommand, i => { const ctx = Context.wrap(i); @@ -133,14 +131,16 @@ export function onInteractionCreate (wrapper: Wrapper) { ePlugArr.push(res as Awaited>); } if(ePlugArr.every(e => e.ok)) { + wrapper.sernEmitter?.emit('sern.command.success', [mod!]); await execute(); } else { + wrapper.sernEmitter?.emit('sern.command.fail', [mod!]); console.log(ePlugArr); console.log(mod, 'failed'); } }, error(err) { - console.log(err); + wrapper.sernEmitter?.emit('sern.error', err); } }); } \ No newline at end of file diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index 7866a7d0..ddc301bd 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -14,7 +14,7 @@ export function filterCorrectModule(cmdType: T) { return throwError(() => SernError.UndefinedModule); } if (correctModuleType(mod, cmdType)) { - subscriber.next(mod); + subscriber.next(mod!); } else { return throwError(() => SernError.MismatchModule); } diff --git a/src/handler/sernEmitter.ts b/src/handler/sernEmitter.ts new file mode 100644 index 00000000..0c894f64 --- /dev/null +++ b/src/handler/sernEmitter.ts @@ -0,0 +1,25 @@ +import { EventEmitter } from 'events'; +import type { Module } from './structures/module'; +import type { Nullish } from '../types/handler'; + +type SernEventsMapping = { + ['sern.command.registered'] : [ Module ]; + ['sern.command.success'] : [ Module ]; + ['sern.command.fail'] : [ Nullish ]; + ['sern.error'] : [ Error ]; +} + +export default class SernEmitter extends EventEmitter { + + public override on(eventName: T, listener: (...args: SernEventsMapping[T][]) => void): this { + return super.on(eventName,listener); + } + public override once(eventName: T, listener: (...args: SernEventsMapping[T][]) => void): this { + return super.once(eventName,listener); + } + public override emit(eventName: T, args : SernEventsMapping[T]): boolean { + return super.emit(eventName, ...args); + } +} + + diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index 1eacdb1c..171a3a1b 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -6,4 +6,5 @@ export enum SernError { MismatchModule = `A module type mismatched with event emitted!`, NotImplemented = 'This feature has not yet been implemented', NotSupportedInteraction = `This interaction is not supported.`, + NotValidEventName = `Supplied a non valid event name`, } diff --git a/src/handler/structures/wrapper.ts b/src/handler/structures/wrapper.ts index bdbf2eda..646ba5c3 100644 --- a/src/handler/structures/wrapper.ts +++ b/src/handler/structures/wrapper.ts @@ -1,5 +1,6 @@ import type { Client } from 'discord.js'; import type { DiscordEvent, EventEmitterRegister } from '../../types/handler'; +import type SernEmitter from '../sernEmitter'; /** * An object to be passed into Sern.Handler constructor. @@ -7,11 +8,11 @@ import type { DiscordEvent, EventEmitterRegister } from '../../types/handler'; * @property {readonly Client} client * @property {readonly string} defaultPrefix * @property {readonly string} commands - * @prop {(handler : Handler) => void)} init * @prop { readonly DiscordEvent[] } events */ interface Wrapper { readonly client: Client; + readonly sernEmitter? : SernEmitter readonly defaultPrefix?: string; readonly commands: string; readonly events?: (DiscordEvent | EventEmitterRegister)[]; diff --git a/src/index.ts b/src/index.ts index 1948fb52..4fd70b99 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; -export * from './handler/plugins/plugin'; \ No newline at end of file +export * from './handler/plugins/plugin'; From 3f64a8aa0a47a09f822d54f2b3f03bc42faa10f7 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 22:52:23 -0500 Subject: [PATCH 070/128] feat: Edited event names for more conciseness, finished basic event emitters --- src/handler/events/interactionCreate.ts | 8 +++----- src/handler/events/messageEvent.ts | 24 ++++++++++++++++-------- src/handler/events/readyEvent.ts | 4 ++-- src/handler/sernEmitter.ts | 15 +++++++++------ src/handler/structures/errors.ts | 1 + 5 files changed, 31 insertions(+), 21 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 9505238f..2f7a4e0e 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -131,16 +131,14 @@ export function onInteractionCreate (wrapper: Wrapper) { ePlugArr.push(res as Awaited>); } if(ePlugArr.every(e => e.ok)) { - wrapper.sernEmitter?.emit('sern.command.success', [mod!]); await execute(); + wrapper.sernEmitter?.emit('module.activate', { success: true, module: mod! }); } else { - wrapper.sernEmitter?.emit('sern.command.fail', [mod!]); - console.log(ePlugArr); - console.log(mod, 'failed'); + wrapper.sernEmitter?.emit('module.activate', { success: false, module: mod!, reason : SernError.PluginFailure }); } }, error(err) { - wrapper.sernEmitter?.emit('sern.error', err); + wrapper.sernEmitter?.emit('error', err); } }); } \ No newline at end of file diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index be4fe778..278e345c 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -9,6 +9,7 @@ import { fmt } from '../utilities/messageHelpers'; import * as Files from '../utilities/readFile'; import { filterCorrectModule, ignoreNonBot } from './observableHandling'; import { CommandType } from '../structures/enums'; +import { SernError } from '../structures/errors'; export const onMessageCreate = (wrapper: Wrapper) => { const { client, defaultPrefix } = wrapper; @@ -50,11 +51,18 @@ export const onMessageCreate = (wrapper: Wrapper) => { }), ); - processEventPlugins$.subscribe(({ mod, ctx, args, res }) => { - if (res.every(pl => pl.ok)) { - Promise.resolve(mod.execute(ctx, args)).then(() => console.log(mod)); - } else { - console.log(mod, 'failed'); - } - }); -}; + processEventPlugins$.subscribe({ + next({ mod, ctx, args, res }) { + if (res.every(pl => pl.ok)) { + Promise.resolve(mod.execute(ctx, args)).then(() => { + wrapper.sernEmitter?.emit('module.activate', { success: true, module: mod! }); + }); + } else { + wrapper.sernEmitter?.emit('module.activate', { success: false, module: mod!, reason: SernError.PluginFailure }); + } + }, + error(e) { + wrapper.sernEmitter?.emit('error', e); + } + }); + }; diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 1ef83198..76d256d4 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -63,9 +63,9 @@ export const onReady = (wrapper: Wrapper) => { if(res.err) { throw Error(SernError.NonValidModuleType); } + wrapper.sernEmitter?.emit('module.register', { success : true, module : mod } ); } else { - console.log(`Failed to load command ${mod.name!}`); - console.log(mod); + wrapper.sernEmitter?.emit('module.register', { success : false, module : mod, reason : SernError.PluginFailure } ); } }); }; diff --git a/src/handler/sernEmitter.ts b/src/handler/sernEmitter.ts index 0c894f64..b482d93e 100644 --- a/src/handler/sernEmitter.ts +++ b/src/handler/sernEmitter.ts @@ -1,12 +1,15 @@ import { EventEmitter } from 'events'; import type { Module } from './structures/module'; -import type { Nullish } from '../types/handler'; +import type { Err } from 'ts-results'; + +type Payload = + { success : true, module : Module } + | { success : false, module: Module | undefined, reason : string | Error } type SernEventsMapping = { - ['sern.command.registered'] : [ Module ]; - ['sern.command.success'] : [ Module ]; - ['sern.command.fail'] : [ Nullish ]; - ['sern.error'] : [ Error ]; + ['module.register'] : [ Payload ]; + ['module.activate'] : [ Payload ]; + ['error'] : [ Error | string ]; } export default class SernEmitter extends EventEmitter { @@ -17,7 +20,7 @@ export default class SernEmitter extends EventEmitter { public override once(eventName: T, listener: (...args: SernEventsMapping[T][]) => void): this { return super.once(eventName,listener); } - public override emit(eventName: T, args : SernEventsMapping[T]): boolean { + public override emit(eventName: T, ...args : SernEventsMapping[T]): boolean { return super.emit(eventName, ...args); } } diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index 171a3a1b..82d2f9ca 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -7,4 +7,5 @@ export enum SernError { NotImplemented = 'This feature has not yet been implemented', NotSupportedInteraction = `This interaction is not supported.`, NotValidEventName = `Supplied a non valid event name`, + PluginFailure = `A plugin failed to call controller.next()`, } From 2d2880095344d33f79b32e8a8187a17aedd295ec Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 22:54:46 -0500 Subject: [PATCH 071/128] style: Run prettier --- src/handler/events/interactionCreate.ts | 126 +++++++++++++---------- src/handler/events/messageEvent.ts | 27 ++--- src/handler/events/observableHandling.ts | 2 +- src/handler/events/readyEvent.ts | 18 ++-- src/handler/plugins/plugin.ts | 16 +-- src/handler/sern.ts | 12 +-- src/handler/sernEmitter.ts | 21 ++-- src/handler/structures/context.ts | 22 ++-- src/handler/structures/module.ts | 7 +- src/handler/structures/structxports.ts | 1 + src/handler/structures/wrapper.ts | 2 +- src/handler/utilities/markup.ts | 8 +- src/handler/utilities/predicates.ts | 15 +-- src/types/handler.ts | 3 +- 14 files changed, 154 insertions(+), 126 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 2f7a4e0e..2a54b901 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,9 +1,4 @@ -import type { - CommandInteraction, - Interaction, - MessageComponentInteraction, - SelectMenuInteraction, -} from 'discord.js'; +import type { CommandInteraction, Interaction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; import { concatMap, fromEvent, map, Observable, of, throwError } from 'rxjs'; import type Wrapper from '../structures/wrapper'; import * as Files from '../utilities/readFile'; @@ -15,7 +10,8 @@ import type { Module } from '../structures/module'; import { isButton, isChatInputCommand, - isMessageCtxMenuCmd, isPromise, + isMessageCtxMenuCmd, + isPromise, isSelectMenu, isUserContextMenuCmd, } from '../utilities/predicates'; @@ -24,34 +20,42 @@ import { CommandType } from '../structures/enums'; import type { Result } from 'ts-results'; function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { - const mod$ = (cmdTy : T) => of(mod).pipe( - filterCorrectModule(cmdTy) + const mod$ = (cmdTy: T) => of(mod).pipe( + filterCorrectModule(cmdTy), ); return match(interaction) .when(isChatInputCommand, i => { - const ctx = Context.wrap(i); - //SUPPORT COMMANDTYPE.BOTH - return mod$(CommandType.Slash).pipe( - concatMap(m => { - return of(m.onEvent?.map(e => e.execute( - [ctx, ['slash', i.options]], - controller - )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx, ['slash', i.options]); } }) )); - }), - ); + const ctx = Context.wrap(i); + //SUPPORT COMMANDTYPE.BOTH + return mod$(CommandType.Slash).pipe( + concatMap(m => { + return of(m.onEvent?.map(e => e.execute( + [ctx, ['slash', i.options]], + controller, + )) ?? []).pipe(map(res => ({ + mod, res, execute() { + return m.execute(ctx, ['slash', i.options]); + }, + }))); + }), + ); }, ) //Todo: refactor so that we dont have to have two separate branches. They're near identical!! //Only thing that differs is type of interaction .when(isMessageCtxMenuCmd, ctx => { - return mod$(CommandType.MenuMsg).pipe( - concatMap(m => { - return of(m.onEvent?.map(e => e.execute( - [ctx], - controller - )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); - }), - ); + return mod$(CommandType.MenuMsg).pipe( + concatMap(m => { + return of(m.onEvent?.map(e => e.execute( + [ctx], + controller, + )) ?? []).pipe(map(res => ({ + mod, res, execute() { + return m.execute(ctx); + }, + }))); + }), + ); }, ) .when(isUserContextMenuCmd, ctx => { @@ -59,8 +63,12 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command concatMap(m => { return of(m.onEvent?.map(e => e.execute( [ctx], - controller - )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); + controller, + )) ?? []).pipe(map(res => ({ + mod, res, execute() { + return m.execute(ctx); + }, + }))); }), ); }) @@ -72,7 +80,7 @@ function messageComponentInteractionHandler( interaction: MessageComponentInteraction, ) { - const mod$ = (ty : T) => of(mod).pipe( filterCorrectModule(ty)); + const mod$ = (ty: T) => of(mod).pipe(filterCorrectModule(ty)); //Todo: refactor so that we dont have to have two separate branches. They're near identical!! //Only thing that differs is type of interaction return match(interaction) @@ -81,25 +89,33 @@ function messageComponentInteractionHandler( concatMap(m => { return of(m.onEvent?.map(e => e.execute( [ctx], - controller - )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); + controller, + )) ?? []).pipe(map(res => ({ + mod, res, execute() { + return m.execute(ctx); + }, + }))); }), ); }) .when(isSelectMenu, (ctx: SelectMenuInteraction) => { - return mod$(CommandType.MenuSelect).pipe( + return mod$(CommandType.MenuSelect).pipe( concatMap(m => { return of(m.onEvent?.map(e => e.execute( [ctx], - controller - )) ?? []).pipe(map(res => ({ mod, res, execute() { return m.execute(ctx); } }) )); + controller, + )) ?? []).pipe(map(res => ({ + mod, res, execute() { + return m.execute(ctx); + }, + }))); }), ); }) .otherwise(() => throwError(() => SernError.NotSupportedInteraction)); } -export function onInteractionCreate (wrapper: Wrapper) { +export function onInteractionCreate(wrapper: Wrapper) { const { client } = wrapper; const interactionEvent$ = >fromEvent(client, 'interactionCreate'); @@ -122,23 +138,27 @@ export function onInteractionCreate (wrapper: Wrapper) { } else return throwError(() => SernError.NotSupportedInteraction); }), ).subscribe({ - async next({ mod, res : eventPluginRes, execute}) { - const ePlugArr : Result[] = []; - for await ( const res of eventPluginRes) { - if(isPromise(res)) { - ePlugArr.push(res); - } - ePlugArr.push(res as Awaited>); + async next({ mod, res: eventPluginRes, execute }) { + const ePlugArr: Result[] = []; + for await (const res of eventPluginRes) { + if (isPromise(res)) { + ePlugArr.push(res); } - if(ePlugArr.every(e => e.ok)) { - await execute(); - wrapper.sernEmitter?.emit('module.activate', { success: true, module: mod! }); - } else { - wrapper.sernEmitter?.emit('module.activate', { success: false, module: mod!, reason : SernError.PluginFailure }); - } - }, - error(err) { - wrapper.sernEmitter?.emit('error', err); + ePlugArr.push(res as Awaited>); + } + if (ePlugArr.every(e => e.ok)) { + await execute(); + wrapper.sernEmitter?.emit('module.activate', { success: true, module: mod! }); + } else { + wrapper.sernEmitter?.emit('module.activate', { + success: false, + module: mod!, + reason: SernError.PluginFailure, + }); } - }); + }, + error(err) { + wrapper.sernEmitter?.emit('error', err); + }, + }); } \ No newline at end of file diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 278e345c..b10505af 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -1,6 +1,5 @@ import type { Message } from 'discord.js'; -import { concatMap, filter, from, fromEvent, map, Observable, of } from 'rxjs'; -import { Err } from 'ts-results'; +import { concatMap, from, fromEvent, map, Observable, of } from 'rxjs'; import type { Args } from '../..'; import { controller } from '../sern'; import Context from '../structures/context'; @@ -52,17 +51,21 @@ export const onMessageCreate = (wrapper: Wrapper) => { ); processEventPlugins$.subscribe({ - next({ mod, ctx, args, res }) { + next({ mod, ctx, args, res }) { if (res.every(pl => pl.ok)) { Promise.resolve(mod.execute(ctx, args)).then(() => { wrapper.sernEmitter?.emit('module.activate', { success: true, module: mod! }); - }); - } else { - wrapper.sernEmitter?.emit('module.activate', { success: false, module: mod!, reason: SernError.PluginFailure }); - } - }, - error(e) { - wrapper.sernEmitter?.emit('error', e); + }); + } else { + wrapper.sernEmitter?.emit('module.activate', { + success: false, + module: mod!, + reason: SernError.PluginFailure, + }); } - }); - }; + }, + error(e) { + wrapper.sernEmitter?.emit('error', e); + }, + }); +}; diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index ddc301bd..afabebc6 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -6,7 +6,7 @@ import type { Module, ModuleDefs } from '../structures/module'; import { correctModuleType } from '../utilities/predicates'; export function filterCorrectModule(cmdType: T) { - return (src: Observable) => + return (src: Observable) => new Observable(subscriber => { return src.subscribe({ next(mod) { diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 76d256d4..1c8e22f0 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -4,11 +4,11 @@ import * as Files from '../utilities/readFile'; import type Wrapper from '../structures/wrapper'; import { controller } from '../sern'; import type { Result } from 'ts-results'; +import { Err, Ok } from 'ts-results'; import type { Awaitable } from 'discord.js'; +import { ApplicationCommandType, ComponentType } from 'discord.js'; import type { Module } from '../structures/module'; import { match } from 'ts-pattern'; -import { ApplicationCommandType, ComponentType } from 'discord.js'; -import { Err, Ok } from 'ts-results'; import { SernError } from '../structures/errors'; import type { DefinitelyDefined } from '../../types/handler'; import { CommandType, PluginType } from '../structures/enums'; @@ -40,7 +40,7 @@ export const onReady = (wrapper: Wrapper) => { ( concat(ready$, processPlugins$) as Observable<{ - mod: DefinitelyDefined; + mod: DefinitelyDefined; cmdPluginsRes: { execute: Awaitable>; type: PluginType.Command; @@ -60,17 +60,21 @@ export const onReady = (wrapper: Wrapper) => { const loadedPluginsCorrectly = cmdPluginsRes.every(res => res.execute.ok); if (loadedPluginsCorrectly) { const res = registerModule(mod); - if(res.err) { + if (res.err) { throw Error(SernError.NonValidModuleType); } - wrapper.sernEmitter?.emit('module.register', { success : true, module : mod } ); + wrapper.sernEmitter?.emit('module.register', { success: true, module: mod }); } else { - wrapper.sernEmitter?.emit('module.register', { success : false, module : mod, reason : SernError.PluginFailure } ); + wrapper.sernEmitter?.emit('module.register', { + success: false, + module: mod, + reason: SernError.PluginFailure, + }); } }); }; -function registerModule(mod: DefinitelyDefined) : Result { +function registerModule(mod: DefinitelyDefined): Result { const name = mod.name; return match(mod) .with({ type: CommandType.Text }, mod => { diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 86b9eb4c..c13ce454 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -17,7 +17,6 @@ import type { Module, Override } from '../..'; import type { BaseModule, ModuleDefs } from '../structures/module'; import type { PluginType } from '../structures/enums'; import type { ValueOf } from 'ts-pattern/dist/types/helpers'; -import type { CommandType } from '../..'; export interface Controller { @@ -26,7 +25,7 @@ export interface Controller { } type BasePlugin = Override; export type CommandPlugin = Override = Override, controller: Controller) => Awaitable>; }>; -export function plugins(...plug: CommandPlugin[]) : CommandPlugin[]; -export function plugins(...plug: EventPlugin[]) : EventPlugin[]; +export function plugins(...plug: CommandPlugin[]): CommandPlugin[]; +export function plugins(...plug: EventPlugin[]): EventPlugin[]; export function plugins(...plug: EventPlugin[] | CommandPlugin[]) { return plug; } type ModuleNoPlugins = ValueOf<{ - [T in keyof ModuleDefs] : Omit + [T in keyof ModuleDefs]: Omit }> + //TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH export function sernModule( - plugins: (CommandPlugin)[], mod : ModuleNoPlugins -) : Module { + plugins: (CommandPlugin)[], mod: ModuleNoPlugins, +): Module { return { plugins, - ...mod + ...mod, }; } \ No newline at end of file diff --git a/src/handler/sern.ts b/src/handler/sern.ts index cf581ea7..bea58df0 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -15,9 +15,9 @@ import { isDiscordEvent } from './utilities/predicates'; export function init(wrapper: Wrapper) { const { events, client } = wrapper; - if (events !== undefined) { - eventObserver(client, events); - } + if (events !== undefined) { + eventObserver(client, events); + } onReady(wrapper); onMessageCreate(wrapper); onInteractionCreate(wrapper); @@ -25,10 +25,10 @@ export function init(wrapper: Wrapper) { function eventObserver(client: Client, events: (DiscordEvent | EventEmitterRegister)[]) { events.forEach((event) => { - if(isDiscordEvent(event)) { - fromEvent(client, event[0], event[1]).subscribe(); + if (isDiscordEvent(event)) { + fromEvent(client, event[0], event[1]).subscribe(); } else { - fromEvent(event[0], event[1], event[2]).subscribe(); + fromEvent(event[0], event[1], event[2]).subscribe(); } }); } diff --git a/src/handler/sernEmitter.ts b/src/handler/sernEmitter.ts index b482d93e..7f81c051 100644 --- a/src/handler/sernEmitter.ts +++ b/src/handler/sernEmitter.ts @@ -1,27 +1,28 @@ import { EventEmitter } from 'events'; import type { Module } from './structures/module'; -import type { Err } from 'ts-results'; type Payload = - { success : true, module : Module } - | { success : false, module: Module | undefined, reason : string | Error } + { success: true, module: Module } + | { success: false, module: Module | undefined, reason: string | Error } type SernEventsMapping = { - ['module.register'] : [ Payload ]; - ['module.activate'] : [ Payload ]; - ['error'] : [ Error | string ]; + ['module.register']: [Payload]; + ['module.activate']: [Payload]; + ['error']: [Error | string]; } export default class SernEmitter extends EventEmitter { public override on(eventName: T, listener: (...args: SernEventsMapping[T][]) => void): this { - return super.on(eventName,listener); + return super.on(eventName, listener); } + public override once(eventName: T, listener: (...args: SernEventsMapping[T][]) => void): this { - return super.once(eventName,listener); + return super.once(eventName, listener); } - public override emit(eventName: T, ...args : SernEventsMapping[T]): boolean { - return super.emit(eventName, ...args); + + public override emit(eventName: T, ...args: SernEventsMapping[T]): boolean { + return super.emit(eventName, ...args); } } diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index 3e6e0229..c9c25123 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -33,17 +33,6 @@ export default class Context { this.oInterac = oInterac; } - static wrap(wrappable: ChatInputCommandInteraction | Message): Context { - if ('token' in wrappable) { - return new Context(None, Some(wrappable)); - } - return new Context(Some(wrappable), None); - } - - public isEmpty() { - return this.oMsg.none && this.oInterac.none; - } - public get message() { return this.oMsg.unwrap(); } @@ -104,6 +93,17 @@ export default class Context { ); } + static wrap(wrappable: ChatInputCommandInteraction | Message): Context { + if ('token' in wrappable) { + return new Context(None, Some(wrappable)); + } + return new Context(Some(wrappable), None); + } + + public isEmpty() { + return this.oMsg.none && this.oInterac.none; + } + /* * Returns the underlying Context but allows for doing other operations */ diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index ec1194a1..070d237d 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -6,14 +6,13 @@ import type { SelectMenuInteraction, UserContextMenuCommandInteraction, } from 'discord.js'; -import type { Override } from '../../types/handler'; -import type { Args } from '../../types/handler'; +import type { Args, Override } from '../../types/handler'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; import { CommandType, PluginType } from './enums'; export interface BaseModule { - type : CommandType | PluginType + type: CommandType | PluginType; name?: string; description: string; execute: (ctx: Context, args: Args) => Awaitable; @@ -56,7 +55,7 @@ export type ContextMenuMsg = Override Awaitable }>; -export type ButtonCommand = Override[]; plugins?: CommandPlugin[]; diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index dcf827c0..a9fed985 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -1,5 +1,6 @@ import Context from './context'; import type { BothCommand, Module, SlashCommand, TextCommand } from './module'; import type Wrapper from './wrapper'; + export * from './enums'; export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper }; diff --git a/src/handler/structures/wrapper.ts b/src/handler/structures/wrapper.ts index 646ba5c3..1e19058c 100644 --- a/src/handler/structures/wrapper.ts +++ b/src/handler/structures/wrapper.ts @@ -12,7 +12,7 @@ import type SernEmitter from '../sernEmitter'; */ interface Wrapper { readonly client: Client; - readonly sernEmitter? : SernEmitter + readonly sernEmitter?: SernEmitter; readonly defaultPrefix?: string; readonly commands: string; readonly events?: (DiscordEvent | EventEmitterRegister)[]; diff --git a/src/handler/utilities/markup.ts b/src/handler/utilities/markup.ts index 233bde24..f41ccb17 100644 --- a/src/handler/utilities/markup.ts +++ b/src/handler/utilities/markup.ts @@ -270,6 +270,10 @@ class FormatInner { this.raw = raw; } + static wrap(raw: string, what: string) { + return `${what}${raw}${what}`; + } + toString() { return this.raw; } @@ -328,10 +332,6 @@ class FormatInner { const ret = this.static.wrap(escaped, Strings[key]); return new this.static(ret); } - - static wrap(raw: string, what: string) { - return `${what}${raw}${what}`; - } } /** diff --git a/src/handler/utilities/predicates.ts b/src/handler/utilities/predicates.ts index 4ba76e5f..6d1c197e 100644 --- a/src/handler/utilities/predicates.ts +++ b/src/handler/utilities/predicates.ts @@ -12,7 +12,6 @@ import type { import type { DiscordEvent, EventEmitterRegister } from '../..'; - export function correctModuleType( plug: Module | undefined, type: T, @@ -24,26 +23,28 @@ export function isChatInputCommand(i: CommandInteraction): i is ChatInputCommand return i.isChatInputCommand(); } -export function isButton(i : MessageComponentInteraction) : i is ButtonInteraction { +export function isButton(i: MessageComponentInteraction): i is ButtonInteraction { return i.isButton(); } -export function isSelectMenu(i : MessageComponentInteraction) : i is SelectMenuInteraction { + +export function isSelectMenu(i: MessageComponentInteraction): i is SelectMenuInteraction { return i.isSelectMenu(); } -export function isMessageCtxMenuCmd(i : CommandInteraction) : i is MessageContextMenuCommandInteraction { + +export function isMessageCtxMenuCmd(i: CommandInteraction): i is MessageContextMenuCommandInteraction { return i.isMessageContextMenuCommand(); } -export function isUserContextMenuCmd(i : CommandInteraction) : i is UserContextMenuCommandInteraction { +export function isUserContextMenuCmd(i: CommandInteraction): i is UserContextMenuCommandInteraction { return i.isUserContextMenuCommand(); } -export function isPromise(promiseLike : Awaitable) : promiseLike is Promise { +export function isPromise(promiseLike: Awaitable): promiseLike is Promise { const keys = new Set(Object.keys(promiseLike)); return keys.has('then') && keys.has('catch'); } -export function isDiscordEvent(el : DiscordEvent | EventEmitterRegister) : el is DiscordEvent { +export function isDiscordEvent(el: DiscordEvent | EventEmitterRegister): el is DiscordEvent { return el.length === 2; } diff --git a/src/types/handler.ts b/src/types/handler.ts index 87cc4b5e..35fd0c68 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -17,8 +17,7 @@ export type ParseType = { export type Args = ParseType<{ text: string[]; slash: SlashOptions }>; export type DiscordEvent = ParseType<{ [K in keyof ClientEvents]: (...args: ClientEvents[K]) => Awaitable }>; -export type EventEmitterRegister = [ emitter: EventEmitter, k : string, cb : (...args: unknown[]) => Awaitable]; - +export type EventEmitterRegister = [emitter: EventEmitter, k: string, cb: (...args: unknown[]) => Awaitable]; export type SlashOptions = Omit; From 6c144defcacd7732e15292f6c3e5eaea7944bc32 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 23:03:39 -0500 Subject: [PATCH 072/128] fix: didn't run prettier, now i am --- src/handler/events/interactionCreate.ts | 180 +++++++++++------------ src/handler/events/messageEvent.ts | 6 +- src/handler/events/observableHandling.ts | 1 - src/handler/events/readyEvent.ts | 17 ++- src/handler/plugins/plugin.ts | 42 +++--- src/handler/sern.ts | 2 +- src/handler/sernEmitter.ts | 19 ++- src/handler/structures/module.ts | 109 ++++++++------ src/handler/utilities/markup.ts | 63 ++++---- src/handler/utilities/predicates.ts | 2 - src/types/handler.ts | 3 - 11 files changed, 236 insertions(+), 208 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 2a54b901..cc9ac940 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -20,66 +20,63 @@ import { CommandType } from '../structures/enums'; import type { Result } from 'ts-results'; function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { - const mod$ = (cmdTy: T) => of(mod).pipe( - filterCorrectModule(cmdTy), - ); - return match(interaction) - .when(isChatInputCommand, i => { + const mod$ = (cmdTy: T) => of(mod).pipe(filterCorrectModule(cmdTy)); + return ( + match(interaction) + .when(isChatInputCommand, i => { const ctx = Context.wrap(i); //SUPPORT COMMANDTYPE.BOTH return mod$(CommandType.Slash).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute( - [ctx, ['slash', i.options]], - controller, - )) ?? []).pipe(map(res => ({ - mod, res, execute() { - return m.execute(ctx, ['slash', i.options]); - }, - }))); + return of(m.onEvent?.map(e => e.execute([ctx, ['slash', i.options]], controller)) ?? []).pipe( + map(res => ({ + mod, + res, + execute() { + return m.execute(ctx, ['slash', i.options]); + }, + })), + ); }), ); - }, - ) - //Todo: refactor so that we dont have to have two separate branches. They're near identical!! - //Only thing that differs is type of interaction - .when(isMessageCtxMenuCmd, ctx => { + }) + //Todo: refactor so that we dont have to have two separate branches. They're near identical!! + //Only thing that differs is type of interaction + .when(isMessageCtxMenuCmd, ctx => { return mod$(CommandType.MenuMsg).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute( - [ctx], - controller, - )) ?? []).pipe(map(res => ({ - mod, res, execute() { - return m.execute(ctx); - }, - }))); + return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + map(res => ({ + mod, + res, + execute() { + return m.execute(ctx); + }, + })), + ); }), ); - }, - ) - .when(isUserContextMenuCmd, ctx => { - return mod$(CommandType.MenuUser).pipe( - concatMap(m => { - return of(m.onEvent?.map(e => e.execute( - [ctx], - controller, - )) ?? []).pipe(map(res => ({ - mod, res, execute() { - return m.execute(ctx); - }, - }))); - }), - ); - }) - .run(); + }) + .when(isUserContextMenuCmd, ctx => { + return mod$(CommandType.MenuUser).pipe( + concatMap(m => { + return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + map(res => ({ + mod, + res, + execute() { + return m.execute(ctx); + }, + })), + ); + }), + ); + }) + .run() + ); } -function messageComponentInteractionHandler( - mod: Module | undefined, - interaction: MessageComponentInteraction, -) { - +function messageComponentInteractionHandler(mod: Module | undefined, interaction: MessageComponentInteraction) { const mod$ = (ty: T) => of(mod).pipe(filterCorrectModule(ty)); //Todo: refactor so that we dont have to have two separate branches. They're near identical!! //Only thing that differs is type of interaction @@ -87,28 +84,30 @@ function messageComponentInteractionHandler( .when(isButton, ctx => { return mod$(CommandType.Button).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute( - [ctx], - controller, - )) ?? []).pipe(map(res => ({ - mod, res, execute() { - return m.execute(ctx); - }, - }))); + return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + map(res => ({ + mod, + res, + execute() { + return m.execute(ctx); + }, + })), + ); }), ); }) .when(isSelectMenu, (ctx: SelectMenuInteraction) => { return mod$(CommandType.MenuSelect).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute( - [ctx], - controller, - )) ?? []).pipe(map(res => ({ - mod, res, execute() { - return m.execute(ctx); - }, - }))); + return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + map(res => ({ + mod, + res, + execute() { + return m.execute(ctx); + }, + })), + ); }), ); }) @@ -131,34 +130,33 @@ export function onInteractionCreate(wrapper: Wrapper) { return applicationCommandHandler(modul, interaction); } if (interaction.isMessageComponent()) { - const modul = Files - .MessageCompCommands[interaction.componentType] - .get(interaction.customId); + const modul = Files.MessageCompCommands[interaction.componentType].get(interaction.customId); return messageComponentInteractionHandler(modul, interaction); } else return throwError(() => SernError.NotSupportedInteraction); }), - ).subscribe({ - async next({ mod, res: eventPluginRes, execute }) { - const ePlugArr: Result[] = []; - for await (const res of eventPluginRes) { - if (isPromise(res)) { - ePlugArr.push(res); + ) + .subscribe({ + async next({ mod, res: eventPluginRes, execute }) { + const ePlugArr: Result[] = []; + for await (const res of eventPluginRes) { + if (isPromise(res)) { + ePlugArr.push(res); + } + ePlugArr.push(res as Awaited>); + } + if (ePlugArr.every(e => e.ok)) { + await execute(); + wrapper.sernEmitter?.emit('module.activate', { success: true, module: mod! }); + } else { + wrapper.sernEmitter?.emit('module.activate', { + success: false, + module: mod!, + reason: SernError.PluginFailure, + }); } - ePlugArr.push(res as Awaited>); - } - if (ePlugArr.every(e => e.ok)) { - await execute(); - wrapper.sernEmitter?.emit('module.activate', { success: true, module: mod! }); - } else { - wrapper.sernEmitter?.emit('module.activate', { - success: false, - module: mod!, - reason: SernError.PluginFailure, - }); - } - }, - error(err) { - wrapper.sernEmitter?.emit('error', err); - }, - }); -} \ No newline at end of file + }, + error(err) { + wrapper.sernEmitter?.emit('error', err); + }, + }); +} diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index b10505af..24753fbf 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -23,16 +23,14 @@ export const onMessageCreate = (wrapper: Wrapper) => { return { ctx: Context.wrap(message), //TODO : check for BothCommand args: ['text', rest], - mod: - Files.BothCommands.get(prefix) ?? - Files.TextCommands.aliases.get(prefix), + mod: Files.BothCommands.get(prefix) ?? Files.TextCommands.aliases.get(prefix), }; }), ); const ensureModuleType$ = processMessage$.pipe( concatMap(payload => of(payload.mod).pipe( - //SUPPORT COMMANDTYPE.BOTH + //SUPPORT COMMAND TYPE.BOTH filterCorrectModule(CommandType.Text), map(mod => ({ ...payload, mod })), ), diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index afabebc6..b9efc357 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -47,4 +47,3 @@ export function ignoreNonBot(prefix: string) { }); }); } - diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 1c8e22f0..a058161d 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -26,14 +26,15 @@ export const onReady = (wrapper: Wrapper) => { }), ); const processPlugins$ = processCommandFiles$.pipe( - concatMap((mod) => { - const cmdPluginsRes = mod.plugins?.map(plug => { - return { - ...plug, - name: plug?.name ?? 'Unnamed Plugin', - execute: plug.execute(client, mod, controller), - }; - }) ?? []; + concatMap(mod => { + const cmdPluginsRes = + mod.plugins?.map(plug => { + return { + ...plug, + name: plug?.name ?? 'Unnamed Plugin', + execute: plug.execute(client, mod, controller), + }; + }) ?? []; return of({ mod, cmdPluginsRes }); }), ); diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index c13ce454..d361fa4b 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -18,27 +18,35 @@ import type { BaseModule, ModuleDefs } from '../structures/module'; import type { PluginType } from '../structures/enums'; import type { ValueOf } from 'ts-pattern/dist/types/helpers'; - export interface Controller { next: () => Ok; stop: () => Err; } -type BasePlugin = Override; +type BasePlugin = Override< + BaseModule, + { + type: PluginType; + } +>; -export type CommandPlugin = Override Awaitable>; -}>; +export type CommandPlugin = Override< + BasePlugin, + { + type: PluginType.Command; + execute: (wrapper: Client, module: Module, controller: Controller) => Awaitable>; + } +>; //TODO: rn adding the modType check a little hackish. Find better way to determine the // module type of the event plugin -export type EventPlugin = Override, controller: Controller) => Awaitable>; -}>; +export type EventPlugin = Override< + BasePlugin, + { + type: PluginType.Event; + execute: (event: Parameters, controller: Controller) => Awaitable>; + } +>; export function plugins(...plug: CommandPlugin[]): CommandPlugin[]; export function plugins(...plug: EventPlugin[]): EventPlugin[]; @@ -47,16 +55,14 @@ export function plugins(...plug: EventPlugin[] | } type ModuleNoPlugins = ValueOf<{ - [T in keyof ModuleDefs]: Omit -}> + [T in keyof ModuleDefs]: Omit; +}>; //TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH -export function sernModule( - plugins: (CommandPlugin)[], mod: ModuleNoPlugins, -): Module { +export function sernModule(plugins: CommandPlugin[], mod: ModuleNoPlugins): Module { return { plugins, ...mod, }; -} \ No newline at end of file +} diff --git a/src/handler/sern.ts b/src/handler/sern.ts index bea58df0..1f49ae6d 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -24,7 +24,7 @@ export function init(wrapper: Wrapper) { } function eventObserver(client: Client, events: (DiscordEvent | EventEmitterRegister)[]) { - events.forEach((event) => { + events.forEach(event => { if (isDiscordEvent(event)) { fromEvent(client, event[0], event[1]).subscribe(); } else { diff --git a/src/handler/sernEmitter.ts b/src/handler/sernEmitter.ts index 7f81c051..26aea139 100644 --- a/src/handler/sernEmitter.ts +++ b/src/handler/sernEmitter.ts @@ -2,22 +2,27 @@ import { EventEmitter } from 'events'; import type { Module } from './structures/module'; type Payload = - { success: true, module: Module } - | { success: false, module: Module | undefined, reason: string | Error } + | { success: true; module: Module } + | { success: false; module: Module | undefined; reason: string | Error }; type SernEventsMapping = { ['module.register']: [Payload]; ['module.activate']: [Payload]; ['error']: [Error | string]; -} +}; export default class SernEmitter extends EventEmitter { - - public override on(eventName: T, listener: (...args: SernEventsMapping[T][]) => void): this { + public override on( + eventName: T, + listener: (...args: SernEventsMapping[T][]) => void, + ): this { return super.on(eventName, listener); } - public override once(eventName: T, listener: (...args: SernEventsMapping[T][]) => void): this { + public override once( + eventName: T, + listener: (...args: SernEventsMapping[T][]) => void, + ): this { return super.once(eventName, listener); } @@ -25,5 +30,3 @@ export default class SernEmitter extends EventEmitter { return super.emit(eventName, ...args); } } - - diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 070d237d..b8a5c499 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -19,55 +19,76 @@ export interface BaseModule { } //possible refactoring types into interfaces and not types -export type TextCommand = Override[] - plugins?: CommandPlugin[]; - alias?: string[]; -}>; +export type TextCommand = Override< + BaseModule, + { + type: CommandType.Text; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + alias?: string[]; + } +>; -export type SlashCommand = Override[] - plugins?: CommandPlugin[]; - options?: ApplicationCommandOptionData[]; -}>; +export type SlashCommand = Override< + BaseModule, + { + type: CommandType.Slash; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + options?: ApplicationCommandOptionData[]; + } +>; -export type BothCommand = Override[] - plugins?: CommandPlugin[] - alias?: string[]; - options?: ApplicationCommandOptionData[]; -}>; +export type BothCommand = Override< + BaseModule, + { + type: CommandType.Both; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + alias?: string[]; + options?: ApplicationCommandOptionData[]; + } +>; -export type ContextMenuUser = Override[]; - plugins?: CommandPlugin[]; - execute: (ctx: UserContextMenuCommandInteraction) => Awaitable -}> +export type ContextMenuUser = Override< + BaseModule, + { + type: CommandType.MenuUser; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + execute: (ctx: UserContextMenuCommandInteraction) => Awaitable; + } +>; -export type ContextMenuMsg = Override[]; - plugins?: CommandPlugin[]; - execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable -}>; +export type ContextMenuMsg = Override< + BaseModule, + { + type: CommandType.MenuMsg; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable; + } +>; -export type ButtonCommand = Override[]; - plugins?: CommandPlugin[]; - execute: (ctx: ButtonInteraction) => Awaitable -}>; +export type ButtonCommand = Override< + BaseModule, + { + type: CommandType.Button; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + execute: (ctx: ButtonInteraction) => Awaitable; + } +>; -export type SelectMenuCommand = Override[]; - plugins?: CommandPlugin[]; - execute: (ctx: SelectMenuInteraction) => Awaitable -}>; +export type SelectMenuCommand = Override< + BaseModule, + { + type: CommandType.MenuSelect; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + execute: (ctx: SelectMenuInteraction) => Awaitable; + } +>; export type Module = | TextCommand @@ -88,4 +109,4 @@ export type ModuleDefs = { [CommandType.MenuUser]: ContextMenuUser; [CommandType.Button]: ButtonCommand; [CommandType.MenuSelect]: SelectMenuCommand; -}; \ No newline at end of file +}; diff --git a/src/handler/utilities/markup.ts b/src/handler/utilities/markup.ts index f41ccb17..daf59715 100644 --- a/src/handler/utilities/markup.ts +++ b/src/handler/utilities/markup.ts @@ -657,37 +657,43 @@ class MatchInner { while ((match = regex.exec(this.raw))) { const result: DiscordRegexMatch = { matched: match[0], species: type }; switch (type) { - case DiscordRegexNames.EMOJI: { - result.name = match[1] as string; - result.id = match[2] as string; - result.animated = this.raw.startsWith('( plug: Module | undefined, type: T, @@ -47,4 +46,3 @@ export function isPromise(promiseLike: Awaitable): promiseLike is Promise< export function isDiscordEvent(el: DiscordEvent | EventEmitterRegister): el is DiscordEvent { return el.length === 2; } - diff --git a/src/types/handler.ts b/src/types/handler.ts index 35fd0c68..e9e393b0 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -19,12 +19,9 @@ export type Args = ParseType<{ text: string[]; slash: SlashOptions }>; export type DiscordEvent = ParseType<{ [K in keyof ClientEvents]: (...args: ClientEvents[K]) => Awaitable }>; export type EventEmitterRegister = [emitter: EventEmitter, k: string, cb: (...args: unknown[]) => Awaitable]; - export type SlashOptions = Omit; //https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l export type Override = Omit & T2; export type DefinitelyDefined = T & Override; - - From dac665d6281a29ec79663adb26a3e5c5243e6ae0 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 23:08:38 -0500 Subject: [PATCH 073/128] fix: linting issue in markup.ts --- src/handler/utilities/markup.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/utilities/markup.ts b/src/handler/utilities/markup.ts index daf59715..f6eb54dc 100644 --- a/src/handler/utilities/markup.ts +++ b/src/handler/utilities/markup.ts @@ -215,7 +215,7 @@ function toTimeString( if (unix === 0n) return '0 milliseconds'; const formatted: Map = new Map(); - const unitList: ObjectEntries = Object.entries(units) as any; + const unitList: ObjectEntries = Object.entries(units) as ObjectEntries; let run = unix; for (const [unit, value] of unitList) { From 571a8044b027afee91466219a841817dd55ef455 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 23:14:05 -0500 Subject: [PATCH 074/128] fix: prettier wants lf line ending --- src/handler/structures/enums.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/handler/structures/enums.ts b/src/handler/structures/enums.ts index b0d25037..70dd882f 100644 --- a/src/handler/structures/enums.ts +++ b/src/handler/structures/enums.ts @@ -16,4 +16,4 @@ enum PluginType { Event = 0b10, } -export { CommandType, PluginType }; \ No newline at end of file +export { CommandType, PluginType }; From d5bb9922dfdb14e4f7e95ad5acd470765b7a90c2 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 23:16:33 -0500 Subject: [PATCH 075/128] fix: prettier changes again --- README.md | 11 ++++++++--- tests/functions.test.ts | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 47b6d47a..0f31c1c8 100644 --- a/README.md +++ b/README.md @@ -1,19 +1,22 @@ # Sern Handler + NPM version NPM downloads Builds Passing Sern can automate and streamline development of your discord bot with new version compatibility and full customization. -- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) +- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) ## Installation ```sh npm install sern-handler ``` + ```sh yarn add sern-handler ``` + ```sh pnpm add sern-handler ``` @@ -21,6 +24,7 @@ pnpm add sern-handler ## Basic Usage #### ` index.js ` + ```js import { Client, Intents } from 'discord.js'; import { Sern } from 'sern-handler'; @@ -54,6 +58,7 @@ client.login(token); ``` #### ` ping.js ` + ```js import { Sern, Types } from 'sern-handler'; import { Ok } from 'ts-results'; @@ -78,8 +83,8 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor ## Contribute -- Pull up on [issues](https://github.com/sern-handler/Sern/issues) and tell us, if there are bugs -- All kinds of contributions are welcomed! +- Pull up on [issues](https://github.com/sern-handler/Sern/issues) and tell us, if there are bugs +- All kinds of contributions are welcomed! ## TODO diff --git a/tests/functions.test.ts b/tests/functions.test.ts index e142bd28..cb57fe21 100644 --- a/tests/functions.test.ts +++ b/tests/functions.test.ts @@ -1,4 +1,5 @@ -import { hasPrefix, fmt, isNotFromBot } from '../src/handler/utilities/messageHelpers'; +import { fmt, hasPrefix, isNotFromBot } from '../src/handler/utilities/messageHelpers'; + describe('FUNCTIONS', () => { test('If hasPrefix is a function', () => { expect(typeof hasPrefix).toBe('function'); @@ -9,5 +10,4 @@ describe('FUNCTIONS', () => { test('if isBot is a function', () => { expect(typeof isNotFromBot).toBe('function'); }); - }); From 7ae5ecf1a64700d667e85420ae4b2eaf31781d85 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Thu, 19 May 2022 23:31:36 -0500 Subject: [PATCH 076/128] feat: add .prettierignore and ignore README.md --- .prettierignore | 1 + README.md | 20 ++++++++++---------- 2 files changed, 11 insertions(+), 10 deletions(-) create mode 100644 .prettierignore diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..42061c01 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +README.md \ No newline at end of file diff --git a/README.md b/README.md index 0f31c1c8..0501c6ed 100644 --- a/README.md +++ b/README.md @@ -39,12 +39,12 @@ const client = new Client({ }); new Sern.Handler({ - client, - prefix, - commands : 'dist/commands', - privateServers : [ + client, + prefix, + commands: 'dist/commands', + privateServers: [ { - test : true, + test: true, id: 'server-id' } ], @@ -63,13 +63,13 @@ client.login(token); import { Sern, Types } from 'sern-handler'; import { Ok } from 'ts-results'; -export default { +export default { alias: [], - desc : 'A ping pong command', - visibility : 'private', - test : false, + desc: 'A ping pong command', + visibility: 'private', + test: false, type: Sern.CommandType.SLASH | Sern.CommandType.TEXT, - execute : async ({ message, interaction }, args) => 'pong!' + execute: async ({ message, interaction }, args) => 'pong!' }; ``` From fc81bfc6d75e4722486766715abe7271ad21cd7f Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 21 May 2022 23:54:27 -0500 Subject: [PATCH 077/128] feat: add externallyUsed.ts and support BothCommands again --- src/handler/structures/context.ts | 89 +++++++++++-------------- src/handler/utilities/externallyUsed.ts | 18 +++++ src/handler/utilities/predicates.ts | 4 +- 3 files changed, 60 insertions(+), 51 deletions(-) create mode 100644 src/handler/utilities/externallyUsed.ts diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index c9c25123..487eef13 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -1,6 +1,5 @@ import type { APIGuildMember } from 'discord-api-types/v9'; import type { - Awaitable, ChatInputCommandInteraction, Guild, GuildMember, @@ -13,6 +12,8 @@ import type { } from 'discord.js'; import { None, Option, Some } from 'ts-results'; import type { Nullish } from '../../types/handler'; +import type { Client } from 'discord.js'; +import { ExternallyUsed } from '../utilities/externallyUsed'; function firstSome(...args: Option[]): Nullish { for (const op of args) { @@ -20,10 +21,12 @@ function firstSome(...args: Option[]): Nullish { } return null; } - -// -//Will need refactoring after applying context in practice -// +//Could I refactor with Either monad? +/** + * The Context class will provide values that are shared between + * Message and ChatInputCommandInteraction + * + */ export default class Context { private constructor( private oMsg: Option = None, @@ -32,50 +35,50 @@ export default class Context { this.oMsg = oMsg; this.oInterac = oInterac; } - + @ExternallyUsed public get message() { return this.oMsg.unwrap(); } - + @ExternallyUsed public get interaction() { return this.oInterac.unwrap(); } - + @ExternallyUsed public get id(): Snowflake { return firstSome( this.oInterac.map(i => i.id), this.oMsg.map(m => m.id), )!; } - + @ExternallyUsed public get channel(): Nullish { return firstSome( this.oMsg.map(m => m.channel), this.oInterac.map(i => i.channel), ); } - + @ExternallyUsed public get user(): User { return firstSome( this.oMsg.map(m => m.author), this.oInterac.map(i => i.user), )!; } - + @ExternallyUsed public get createdTimestamp(): number { return firstSome( this.oMsg.map(m => m.createdTimestamp), this.oInterac.map(i => i.createdTimestamp), )!; } - + @ExternallyUsed public get guild(): Guild { return firstSome( this.oMsg.map(m => m.guild), this.oInterac.map(i => i.guild), )!; } - + @ExternallyUsed public get guildId(): Snowflake { return firstSome( this.oMsg.map(m => m.guildId), @@ -86,6 +89,7 @@ export default class Context { /* * interactions can return APIGuildMember if the guild it is emitted from is not cached */ + @ExternallyUsed public get member(): Nullish { return firstSome( this.oMsg.map(m => m.member), @@ -99,50 +103,35 @@ export default class Context { } return new Context(Some(wrappable), None); } - + @ExternallyUsed public isEmpty() { return this.oMsg.none && this.oInterac.none; } - /* - * Returns the underlying Context but allows for doing other operations - */ - public onInteraction(onInteraction: (interaction: ChatInputCommandInteraction) => Awaitable): Context { - if (this.oInterac.some) { - onInteraction(this.oInterac.val); - return Context.wrap(this.oInterac.val); - } - return this; - } - - public onMessage(onMessage: (message: Message) => Awaitable): Context { - if (this.oMsg.some) { - onMessage(this.oMsg.val); - return Context.wrap(this.oMsg.val); - } - return this; - } - - public takeInteractionValue(extract: (interaction: ChatInputCommandInteraction) => T): Nullish { - if (this.oInterac.none) return null; - return extract(this.oInterac.val); - } - - public takeMessageValue(extract: (message: Message) => T): Nullish { - if (this.oMsg.none) return null; - return extract(this.oMsg.val); - } - - public reply(content: Omit | ReplyMessageOptions): Promise { + //TODO: make this queueable + @ExternallyUsed + public reply(content: Omit | ReplyMessageOptions) { return firstSome( - this.oInterac.map(async i => { - await i.reply(content as InteractionReplyOptions); - return new Context(Some((await i.fetchReply()) as Message), Some(i)); + this.oInterac.map(i => { + return i.reply(content as InteractionReplyOptions).then(() => i.fetchReply()); }), - this.oMsg.map(async m => { - const reply = await m.reply(content as ReplyMessageOptions); - return new Context(Some(reply), this.oInterac); + this.oMsg.map(m => { + return m.reply(content as ReplyMessageOptions); }), )!; } + @ExternallyUsed + public get client(): Client { + return firstSome( + this.oMsg.map(m => m.client), + this.oInterac.map(i => i.client), + )!; + } + @ExternallyUsed + public get inGuild(): boolean { + return firstSome( + this.oMsg.map(m => m.inGuild()), + this.oInterac.map(i => i.inGuild()), + )!; + } } diff --git a/src/handler/utilities/externallyUsed.ts b/src/handler/utilities/externallyUsed.ts new file mode 100644 index 00000000..0f0fe81a --- /dev/null +++ b/src/handler/utilities/externallyUsed.ts @@ -0,0 +1,18 @@ +/** + * This function denotes usage of decorated method is external + * Also, makes method appear 'used' in IDEs + * @param _target + * @param _propertyKey + * @param _descriptor + * @constructor + */ +export function ExternallyUsed( + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _target: unknown, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _propertyKey: string, + // eslint-disable-next-line @typescript-eslint/no-unused-vars + _descriptor: PropertyDescriptor, +) { + return void 0; +} diff --git a/src/handler/utilities/predicates.ts b/src/handler/utilities/predicates.ts index ce400b8f..1c2cdfb6 100644 --- a/src/handler/utilities/predicates.ts +++ b/src/handler/utilities/predicates.ts @@ -15,7 +15,9 @@ export function correctModuleType( plug: Module | undefined, type: T, ): plug is ModuleDefs[T] { - return plug !== undefined && plug.type === type; + // Another way to check if type is equivalent, + // It will check based on flag system instead + return plug !== undefined && (plug.type & type) !== 0; } export function isChatInputCommand(i: CommandInteraction): i is ChatInputCommandInteraction { From a2209494bdd05ca89176aff82f7d3afce0b8de46 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 21 May 2022 23:54:46 -0500 Subject: [PATCH 078/128] feat: remove comments about prev commit --- src/handler/events/interactionCreate.ts | 1 - src/handler/events/messageEvent.ts | 1 - 2 files changed, 2 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index cc9ac940..09603ef3 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -25,7 +25,6 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command match(interaction) .when(isChatInputCommand, i => { const ctx = Context.wrap(i); - //SUPPORT COMMANDTYPE.BOTH return mod$(CommandType.Slash).pipe( concatMap(m => { return of(m.onEvent?.map(e => e.execute([ctx, ['slash', i.options]], controller)) ?? []).pipe( diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 24753fbf..5ef2061e 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -30,7 +30,6 @@ export const onMessageCreate = (wrapper: Wrapper) => { const ensureModuleType$ = processMessage$.pipe( concatMap(payload => of(payload.mod).pipe( - //SUPPORT COMMAND TYPE.BOTH filterCorrectModule(CommandType.Text), map(mod => ({ ...payload, mod })), ), From 26756077ef93391b0aadeada085e31c22058e2c0 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 21 May 2022 23:58:52 -0500 Subject: [PATCH 079/128] style: change prettier print width and reformat --- .prettierrc | 2 +- src/handler/events/interactionCreate.ts | 27 ++++++++--- src/handler/events/readyEvent.ts | 8 ++-- src/handler/plugins/plugin.ts | 11 ++++- src/handler/sernEmitter.ts | 5 +- src/handler/structures/context.ts | 42 +++++++++++------ src/handler/utilities/markup.ts | 63 +++++++++++-------------- src/handler/utilities/predicates.ts | 8 +++- 8 files changed, 101 insertions(+), 65 deletions(-) diff --git a/.prettierrc b/.prettierrc index f0c38cfe..1b53835a 100644 --- a/.prettierrc +++ b/.prettierrc @@ -2,7 +2,7 @@ "semi": true, "trailingComma": "all", "singleQuote": true, - "printWidth": 120, + "printWidth": 100, "tabWidth": 4, "arrowParens": "avoid" } diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 09603ef3..ddf43210 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -1,4 +1,9 @@ -import type { CommandInteraction, Interaction, MessageComponentInteraction, SelectMenuInteraction } from 'discord.js'; +import type { + CommandInteraction, + Interaction, + MessageComponentInteraction, + SelectMenuInteraction, +} from 'discord.js'; import { concatMap, fromEvent, map, Observable, of, throwError } from 'rxjs'; import type Wrapper from '../structures/wrapper'; import * as Files from '../utilities/readFile'; @@ -27,7 +32,11 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command const ctx = Context.wrap(i); return mod$(CommandType.Slash).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute([ctx, ['slash', i.options]], controller)) ?? []).pipe( + return of( + m.onEvent?.map(e => + e.execute([ctx, ['slash', i.options]], controller), + ) ?? [], + ).pipe( map(res => ({ mod, res, @@ -75,7 +84,10 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command ); } -function messageComponentInteractionHandler(mod: Module | undefined, interaction: MessageComponentInteraction) { +function messageComponentInteractionHandler( + mod: Module | undefined, + interaction: MessageComponentInteraction, +) { const mod$ = (ty: T) => of(mod).pipe(filterCorrectModule(ty)); //Todo: refactor so that we dont have to have two separate branches. They're near identical!! //Only thing that differs is type of interaction @@ -124,12 +136,15 @@ export function onInteractionCreate(wrapper: Wrapper) { concatMap(interaction => { if (interaction.isCommand()) { const modul = - Files.ApplicationCommands[interaction.commandType].get(interaction.commandName) ?? - Files.BothCommands.get(interaction.commandName); + Files.ApplicationCommands[interaction.commandType].get( + interaction.commandName, + ) ?? Files.BothCommands.get(interaction.commandName); return applicationCommandHandler(modul, interaction); } if (interaction.isMessageComponent()) { - const modul = Files.MessageCompCommands[interaction.componentType].get(interaction.customId); + const modul = Files.MessageCompCommands[interaction.componentType].get( + interaction.customId, + ); return messageComponentInteractionHandler(modul, interaction); } else return throwError(() => SernError.NotSupportedInteraction); }), diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index a058161d..dbf58a3a 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -52,9 +52,11 @@ export const onReady = (wrapper: Wrapper) => { ) .pipe( concatMap(pl => - from(Promise.all(pl.cmdPluginsRes.map(async e => ({ ...e, execute: await e.execute })))).pipe( - map(res => ({ ...pl, cmdPluginsRes: res })), - ), + from( + Promise.all( + pl.cmdPluginsRes.map(async e => ({ ...e, execute: await e.execute })), + ), + ).pipe(map(res => ({ ...pl, cmdPluginsRes: res }))), ), ) .subscribe(({ mod, cmdPluginsRes }) => { diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index d361fa4b..282e30f1 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -34,7 +34,11 @@ export type CommandPlugin = Override< BasePlugin, { type: PluginType.Command; - execute: (wrapper: Client, module: Module, controller: Controller) => Awaitable>; + execute: ( + wrapper: Client, + module: Module, + controller: Controller, + ) => Awaitable>; } >; @@ -44,7 +48,10 @@ export type EventPlugin = Override< BasePlugin, { type: PluginType.Event; - execute: (event: Parameters, controller: Controller) => Awaitable>; + execute: ( + event: Parameters, + controller: Controller, + ) => Awaitable>; } >; diff --git a/src/handler/sernEmitter.ts b/src/handler/sernEmitter.ts index 26aea139..4beb0f6f 100644 --- a/src/handler/sernEmitter.ts +++ b/src/handler/sernEmitter.ts @@ -26,7 +26,10 @@ export default class SernEmitter extends EventEmitter { return super.once(eventName, listener); } - public override emit(eventName: T, ...args: SernEventsMapping[T]): boolean { + public override emit( + eventName: T, + ...args: SernEventsMapping[T] + ): boolean { return super.emit(eventName, ...args); } } diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index 487eef13..4eb3d1b9 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -1,6 +1,7 @@ import type { APIGuildMember } from 'discord-api-types/v9'; import type { ChatInputCommandInteraction, + Client, Guild, GuildMember, InteractionReplyOptions, @@ -12,7 +13,6 @@ import type { } from 'discord.js'; import { None, Option, Some } from 'ts-results'; import type { Nullish } from '../../types/handler'; -import type { Client } from 'discord.js'; import { ExternallyUsed } from '../utilities/externallyUsed'; function firstSome(...args: Option[]): Nullish { @@ -21,6 +21,7 @@ function firstSome(...args: Option[]): Nullish { } return null; } + //Could I refactor with Either monad? /** * The Context class will provide values that are shared between @@ -35,14 +36,17 @@ export default class Context { this.oMsg = oMsg; this.oInterac = oInterac; } + @ExternallyUsed public get message() { return this.oMsg.unwrap(); } + @ExternallyUsed public get interaction() { return this.oInterac.unwrap(); } + @ExternallyUsed public get id(): Snowflake { return firstSome( @@ -50,6 +54,7 @@ export default class Context { this.oMsg.map(m => m.id), )!; } + @ExternallyUsed public get channel(): Nullish { return firstSome( @@ -57,6 +62,7 @@ export default class Context { this.oInterac.map(i => i.channel), ); } + @ExternallyUsed public get user(): User { return firstSome( @@ -64,6 +70,7 @@ export default class Context { this.oInterac.map(i => i.user), )!; } + @ExternallyUsed public get createdTimestamp(): number { return firstSome( @@ -71,6 +78,7 @@ export default class Context { this.oInterac.map(i => i.createdTimestamp), )!; } + @ExternallyUsed public get guild(): Guild { return firstSome( @@ -78,6 +86,7 @@ export default class Context { this.oInterac.map(i => i.guild), )!; } + @ExternallyUsed public get guildId(): Snowflake { return firstSome( @@ -97,12 +106,29 @@ export default class Context { ); } + @ExternallyUsed + public get client(): Client { + return firstSome( + this.oMsg.map(m => m.client), + this.oInterac.map(i => i.client), + )!; + } + + @ExternallyUsed + public get inGuild(): boolean { + return firstSome( + this.oMsg.map(m => m.inGuild()), + this.oInterac.map(i => i.inGuild()), + )!; + } + static wrap(wrappable: ChatInputCommandInteraction | Message): Context { if ('token' in wrappable) { return new Context(None, Some(wrappable)); } return new Context(Some(wrappable), None); } + @ExternallyUsed public isEmpty() { return this.oMsg.none && this.oInterac.none; @@ -120,18 +146,4 @@ export default class Context { }), )!; } - @ExternallyUsed - public get client(): Client { - return firstSome( - this.oMsg.map(m => m.client), - this.oInterac.map(i => i.client), - )!; - } - @ExternallyUsed - public get inGuild(): boolean { - return firstSome( - this.oMsg.map(m => m.inGuild()), - this.oInterac.map(i => i.inGuild()), - )!; - } } diff --git a/src/handler/utilities/markup.ts b/src/handler/utilities/markup.ts index f6eb54dc..6d0879b6 100644 --- a/src/handler/utilities/markup.ts +++ b/src/handler/utilities/markup.ts @@ -657,43 +657,37 @@ class MatchInner { while ((match = regex.exec(this.raw))) { const result: DiscordRegexMatch = { matched: match[0], species: type }; switch (type) { - case DiscordRegexNames.EMOJI: - { - result.name = match[1] as string; - result.id = match[2] as string; - result.animated = this.raw.startsWith(' Date: Sun, 22 May 2022 02:08:24 -0500 Subject: [PATCH 080/128] feat: adding modal and autocomplete support --- src/handler/events/interactionCreate.ts | 28 ++++++++++++++++++++++++- src/handler/events/readyEvent.ts | 4 ++++ src/handler/structures/enums.ts | 1 + src/handler/structures/module.ts | 16 +++++++++++++- src/handler/utilities/readFile.ts | 3 ++- 5 files changed, 49 insertions(+), 3 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index ddf43210..25ab48b5 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -2,6 +2,7 @@ import type { CommandInteraction, Interaction, MessageComponentInteraction, + ModalSubmitInteraction, SelectMenuInteraction, } from 'discord.js'; import { concatMap, fromEvent, map, Observable, of, throwError } from 'rxjs'; @@ -125,6 +126,23 @@ function messageComponentInteractionHandler( .otherwise(() => throwError(() => SernError.NotSupportedInteraction)); } +function modalHandler(modul : Module|undefined, ctx: ModalSubmitInteraction) { + return of(modul).pipe( + filterCorrectModule(CommandType.Modal), + concatMap(mod => { + return of(mod.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + map(res => ({ + mod, + res, + execute() { + return mod.execute(ctx); + }, + })), + ); + }) + ) +} + export function onInteractionCreate(wrapper: Wrapper) { const { client } = wrapper; @@ -146,7 +164,15 @@ export function onInteractionCreate(wrapper: Wrapper) { interaction.customId, ); return messageComponentInteractionHandler(modul, interaction); - } else return throwError(() => SernError.NotSupportedInteraction); + } + if (interaction.isModalSubmit()) { + const modul = Files.ModalSubmitCommands.get(interaction.customId); + return modalHandler(modul, interaction); + } + if (interaction.isAutocomplete()) { + const modul = Files.ApplicationCommands[1].get(interaction.commandName); + } + return of(); }), ) .subscribe({ diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index dbf58a3a..e04b3f7d 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -110,5 +110,9 @@ function registerModule(mod: DefinitelyDefined): Resul Files.MessageCompCommands[ComponentType.SelectMenu].set(name, mod); return Ok.EMPTY; }) + .with({ type : CommandType.Modal }, mod => { + Files.ModalSubmitCommands.set(name, mod); + return Ok.EMPTY; + }) .otherwise(() => Err.EMPTY); } diff --git a/src/handler/structures/enums.ts b/src/handler/structures/enums.ts index 70dd882f..d81d7cbd 100644 --- a/src/handler/structures/enums.ts +++ b/src/handler/structures/enums.ts @@ -8,6 +8,7 @@ enum CommandType { MenuMsg = 0b0001000, Button = 0b0010000, MenuSelect = 0b0100000, + Modal = 0b1000000, Both = 0b0000011, } diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index b8a5c499..2a82695a 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -3,6 +3,7 @@ import type { Awaitable, ButtonInteraction, MessageContextMenuCommandInteraction, + ModalSubmitInteraction, SelectMenuInteraction, UserContextMenuCommandInteraction, } from 'discord.js'; @@ -90,6 +91,17 @@ export type SelectMenuCommand = Override< } >; +export type ModalSubmitCommand = Override< + BaseModule, + { + type : CommandType.Modal; + onEvent?: EventPlugin[]; + plugins?: CommandPlugin[]; + execute : (ctx: ModalSubmitInteraction) => Awaitable; + } + +>; + export type Module = | TextCommand | SlashCommand @@ -97,7 +109,8 @@ export type Module = | ContextMenuUser | ContextMenuMsg | ButtonCommand - | SelectMenuCommand; + | SelectMenuCommand + | ModalSubmitCommand; //https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union // Explicit Module Definitions for mapping @@ -109,4 +122,5 @@ export type ModuleDefs = { [CommandType.MenuUser]: ContextMenuUser; [CommandType.Button]: ButtonCommand; [CommandType.MenuSelect]: SelectMenuCommand; + [CommandType.Modal] : ModalSubmitCommand; }; diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index 60b92ea0..c41e584a 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -4,6 +4,7 @@ import { join } from 'path'; import { from, Observable } from 'rxjs'; import type { Module } from '../structures/module'; +//Maybe move this? this probably doesnt belong in utlities/ export const BothCommands = new Map(); export const ApplicationCommands = { [ApplicationCommandType.User]: new Map(), @@ -20,7 +21,7 @@ export const TextCommands = { text: new Map(), aliases: new Map(), }; - +export const ModalSubmitCommands = new Map(); // Courtesy @Townsy45 function readPath(dir: string, arrayOfFiles: string[] = []): string[] { try { From d50b8013ee343b2be0ed232938e9f5f91c43b493 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 22 May 2022 18:54:20 -0500 Subject: [PATCH 081/128] feat: Finishing up autocomplete, need to test --- src/handler/events/interactionCreate.ts | 66 +++++++++++++++++++------ src/handler/plugins/plugin.ts | 11 +++-- src/handler/structures/enums.ts | 15 +++--- src/handler/structures/module.ts | 41 ++++++++++++--- 4 files changed, 100 insertions(+), 33 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 25ab48b5..2d25e3fb 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -12,7 +12,7 @@ import { match } from 'ts-pattern'; import { SernError } from '../structures/errors'; import Context from '../structures/context'; import { controller } from '../sern'; -import type { Module } from '../structures/module'; +import type { AutocompleteCommand, Module, SlashCommand } from '../structures/module'; import { isButton, isChatInputCommand, @@ -24,6 +24,7 @@ import { import { filterCorrectModule } from './observableHandling'; import { CommandType } from '../structures/enums'; import type { Result } from 'ts-results'; +import type { AutocompleteInteraction } from 'discord.js'; function applicationCommandHandler(mod: Module | undefined, interaction: CommandInteraction) { const mod$ = (cmdTy: T) => of(mod).pipe(filterCorrectModule(cmdTy)); @@ -126,21 +127,53 @@ function messageComponentInteractionHandler( .otherwise(() => throwError(() => SernError.NotSupportedInteraction)); } -function modalHandler(modul : Module|undefined, ctx: ModalSubmitInteraction) { - return of(modul).pipe( - filterCorrectModule(CommandType.Modal), - concatMap(mod => { - return of(mod.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( - map(res => ({ - mod, - res, - execute() { - return mod.execute(ctx); - }, - })), - ); - }) - ) +function modalHandler(modul: Module | undefined, ctx: ModalSubmitInteraction) { + return of(modul).pipe( + filterCorrectModule(CommandType.Modal), + concatMap(mod => { + return of(mod.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + map(res => ({ + mod, + res, + execute() { + return mod.execute(ctx); + }, + })), + ); + }), + ); +} + +function autoCmpHandler(mod: Module | undefined, interaction: AutocompleteInteraction) { + return of(mod).pipe( + filterCorrectModule(CommandType.Slash), + concatMap(mod => { + const choice = interaction.options.getFocused(true); + const selectedOption = mod.options?.find( + o => o.autocomplete && o.command.name === choice.name, + ); + if (selectedOption !== undefined && selectedOption.autocomplete) { + return of( + selectedOption.command.onEvent?.map(e => + e.execute([interaction], controller), + ) ?? [], + ).pipe( + map(res => ({ + mod, + res, + execute() { + return selectedOption.command.execute(interaction); + }, + })), + ); + } + return throwError( + () => + SernError.NotSupportedInteraction + + ` There is probably no autocomplete tag for this option`, + ); + }), + ); } export function onInteractionCreate(wrapper: Wrapper) { @@ -171,6 +204,7 @@ export function onInteractionCreate(wrapper: Wrapper) { } if (interaction.isAutocomplete()) { const modul = Files.ApplicationCommands[1].get(interaction.commandName); + return autoCmpHandler(modul, interaction); } return of(); }), diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 282e30f1..39752e2e 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -14,6 +14,7 @@ import type { Awaitable, Client } from 'discord.js'; import type { Err, Ok, Result } from 'ts-results'; import type { Module, Override } from '../..'; +import { CommandType } from '../..'; import type { BaseModule, ModuleDefs } from '../structures/module'; import type { PluginType } from '../structures/enums'; import type { ValueOf } from 'ts-pattern/dist/types/helpers'; @@ -68,8 +69,10 @@ type ModuleNoPlugins = ValueOf<{ //TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH export function sernModule(plugins: CommandPlugin[], mod: ModuleNoPlugins): Module { - return { - plugins, - ...mod, - }; + if (mod.type !== CommandType.Autocomplete) + return { + plugins, + ...mod, + }; + else return mod; } diff --git a/src/handler/structures/enums.ts b/src/handler/structures/enums.ts index d81d7cbd..9aefe377 100644 --- a/src/handler/structures/enums.ts +++ b/src/handler/structures/enums.ts @@ -2,13 +2,14 @@ * @enum { number }; */ enum CommandType { - Text = 0b0000001, - Slash = 0b0000010, - MenuUser = 0b0000100, - MenuMsg = 0b0001000, - Button = 0b0010000, - MenuSelect = 0b0100000, - Modal = 0b1000000, + Text = 0b00000001, + Slash = 0b00000010, + MenuUser = 0b00000100, + MenuMsg = 0b00001000, + Button = 0b00010000, + MenuSelect = 0b00100000, + Modal = 0b01000000, + Autocomplete = 0b10000000, Both = 0b0000011, } diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 2a82695a..d4a4c23d 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -1,4 +1,5 @@ import type { + ApplicationCommandAutocompleteOption, ApplicationCommandOptionData, Awaitable, ButtonInteraction, @@ -11,6 +12,8 @@ import type { Args, Override } from '../../types/handler'; import type { CommandPlugin, EventPlugin } from '../plugins/plugin'; import type Context from './context'; import { CommandType, PluginType } from './enums'; +import type { AutocompleteInteraction } from 'discord.js'; +import type { ApplicationCommandOptionType } from 'discord.js'; export interface BaseModule { type: CommandType | PluginType; @@ -36,7 +39,7 @@ export type SlashCommand = Override< type: CommandType.Slash; onEvent?: EventPlugin[]; plugins?: CommandPlugin[]; - options?: ApplicationCommandOptionData[]; + options?: OptionsData[]; } >; @@ -47,7 +50,7 @@ export type BothCommand = Override< onEvent?: EventPlugin[]; plugins?: CommandPlugin[]; alias?: string[]; - options?: ApplicationCommandOptionData[]; + options?: OptionsData[]; } >; @@ -94,12 +97,24 @@ export type SelectMenuCommand = Override< export type ModalSubmitCommand = Override< BaseModule, { - type : CommandType.Modal; + type: CommandType.Modal; onEvent?: EventPlugin[]; plugins?: CommandPlugin[]; - execute : (ctx: ModalSubmitInteraction) => Awaitable; + execute: (ctx: ModalSubmitInteraction) => Awaitable; } +>; +// Autocomplete commands are a little different +// They can't have command plugins as they are +// in conjunction with chat input commands +// TODO: possibly in future, allow Autocmp commands in separate files? +export type AutocompleteCommand = Override< + BaseModule, + { + type: CommandType.Autocomplete; + onEvent?: EventPlugin[]; + execute: (ctx: AutocompleteInteraction) => Awaitable; + } >; export type Module = @@ -110,7 +125,8 @@ export type Module = | ContextMenuMsg | ButtonCommand | SelectMenuCommand - | ModalSubmitCommand; + | ModalSubmitCommand + | AutocompleteCommand; //https://stackoverflow.com/questions/64092736/alternative-to-switch-statement-for-typescript-discriminated-union // Explicit Module Definitions for mapping @@ -122,5 +138,18 @@ export type ModuleDefs = { [CommandType.MenuUser]: ContextMenuUser; [CommandType.Button]: ButtonCommand; [CommandType.MenuSelect]: SelectMenuCommand; - [CommandType.Modal] : ModalSubmitCommand; + [CommandType.Modal]: ModalSubmitCommand; + [CommandType.Autocomplete]: AutocompleteCommand; }; + +type OptionsData = + | Exclude + | { + required?: boolean; + autocomplete: true; + type: + | ApplicationCommandOptionType.String + | ApplicationCommandOptionType.Number + | ApplicationCommandOptionType.Integer; + command: AutocompleteCommand; + }; From ac8a2f4c86a1c426d32e388a5439a8696db52279 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Mon, 23 May 2022 00:54:40 -0500 Subject: [PATCH 082/128] feat: Making name required in auto cmp interactions --- package-lock.json | 358 ++++++++++--------------------- src/handler/events/readyEvent.ts | 5 +- src/handler/structures/module.ts | 1 + 3 files changed, 123 insertions(+), 241 deletions(-) diff --git a/package-lock.json b/package-lock.json index 81891b50..4d7419a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1934,42 +1934,40 @@ } }, "node_modules/@discordjs/builders": { - "version": "0.13.0-dev.1647259738.2297c2b", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.13.0-dev.1647259738.2297c2b.tgz", - "integrity": "sha512-SywFeczvI8p3US9k2gD2Iza4jPgDpKzuwA8ISrhWF9gPyECxUpgndgW5iZ1M8PhNKjtdZ9Gwn+P7mDpWgpGwZA==", + "version": "0.14.0-dev.1653091712-fdeac9d", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.14.0-dev.1653091712-fdeac9d.tgz", + "integrity": "sha512-7/esDI5KkDBI8sxSNFmPYNQXMUTbopD4FkjBAm+nQmp5Xxda1xFjWvi3oJ7QC8l/IVanUAD47xxrb8lhckMRzA==", "dependencies": { - "@sindresorhus/is": "^4.4.0", - "discord-api-types": "^0.27.3", + "@sapphire/shapeshift": "^3.0.0", + "@sindresorhus/is": "^4.6.0", + "discord-api-types": "^0.33.0", "fast-deep-equal": "^3.1.3", - "ts-mixer": "^6.0.0", - "tslib": "^2.3.1", - "zod": "^3.11.6" + "ts-mixer": "^6.0.1", + "tslib": "^2.3.1" }, "engines": { "node": ">=16.9.0" } }, "node_modules/@discordjs/collection": { - "version": "0.6.0-dev.1647259738.2297c2b", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.6.0-dev.1647259738.2297c2b.tgz", - "integrity": "sha512-A+c2qy2HCzVDD3MAoIsL+MKPJhI+jCrcZbIIc6nRZcnCKT544qlI2Sr972sw1bzOj97HD/m4Qd0ElUeQzkHsbQ==", + "version": "0.7.0-dev.1653091708-fdeac9d", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.7.0-dev.1653091708-fdeac9d.tgz", + "integrity": "sha512-21gKkNVlqWMTf5kkZ2uAkfe8kU149w/JXC9Vpu7nNEir6A5AHNPULtd+1FssvXYAfoEnzus7/gZC6pYD5eX/gQ==", "engines": { "node": ">=16.9.0" } }, "node_modules/@discordjs/rest": { - "version": "0.4.0-dev.1647259762.2297c2b", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.4.0-dev.1647259762.2297c2b.tgz", - "integrity": "sha512-Pt1InmNvdDKSO8/vZg7K2VLB05iOdtScM9jHczLd3NsMWd66DDOzNorKQUjc84nL80RkZ7CCELy/eOn0uwrN4A==", - "dependencies": { - "@discordjs/collection": "^0.6.0-dev", - "@sapphire/async-queue": "^1.2.0", - "@sapphire/snowflake": "^3.1.0", - "@types/node-fetch": "^2.5.12", - "discord-api-types": "^0.27.0", - "form-data": "^4.0.0", - "node-fetch": "^2.6.7", - "tslib": "^2.3.1" + "version": "0.5.0-dev.1653091732-fdeac9d", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.5.0-dev.1653091732-fdeac9d.tgz", + "integrity": "sha512-2XIobHE+C0X/LFJC205CSeiHKvt0aBRqYb5dwAoq6VsZAprmvL+Mma0V2bKWInaOCmrr85X+XlEgQf+H22CK+A==", + "dependencies": { + "@discordjs/collection": "^0.7.0-dev", + "@sapphire/async-queue": "^1.3.1", + "@sapphire/snowflake": "^3.2.1", + "discord-api-types": "^0.33.0", + "tslib": "^2.3.1", + "undici": "^5.2.0" }, "engines": { "node": ">=16.9.0" @@ -2460,18 +2458,27 @@ } }, "node_modules/@sapphire/async-queue": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.3.0.tgz", - "integrity": "sha512-z+CDw5X4UgIEpZL8KM+ThVx1i8V60HBg0l/oFewTNbQQeRDJHdVxHyJykv+SF1H+Rc8EkMS81VTWo95jVYgO/g==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.3.1.tgz", + "integrity": "sha512-FFTlPOWZX1kDj9xCAsRzH5xEJfawg1lNoYAA+ecOWJMHOfiZYb1uXOI3ne9U4UILSEPwfE68p3T9wUHwIQfR0g==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" } }, + "node_modules/@sapphire/shapeshift": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.0.0.tgz", + "integrity": "sha512-LTVj/a70UDzjOFaViMGpVzSzKYD2pBk0TmZIHnBf4vnytV7TK/L6XVN6hslq7R+qwRZyL/mzIldu6mAV6r7vzA==", + "engines": { + "node": ">=v15.0.0", + "npm": ">=7.0.0" + } + }, "node_modules/@sapphire/snowflake": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.2.0.tgz", - "integrity": "sha512-tfHzY+6/5bbHdB+uNqsEQ5rhjaZAoFUrqP/l1S5jwxMdKeSCIiGkJjcE99/WGGdzyWGjTNgNVX/dt4Me/FdMlg==", + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.2.2.tgz", + "integrity": "sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ==", "engines": { "node": ">=v14.0.0", "npm": ">=7.0.0" @@ -2644,28 +2651,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.10.tgz", "integrity": "sha512-S/3xB4KzyFxYGCppyDt68yzBU9ysL88lSdIah4D6cptdcltc4NCPCAMc0+PCpg/lLIyC7IPvj2Z52OJWeIUkog==" }, - "node_modules/@types/node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==", - "dependencies": { - "@types/node": "*", - "form-data": "^3.0.0" - } - }, - "node_modules/@types/node-fetch/node_modules/form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/@types/normalize-package-data": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", @@ -3077,7 +3062,8 @@ "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true }, "node_modules/babel-jest": { "version": "27.5.1", @@ -3467,6 +3453,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, "dependencies": { "delayed-stream": "~1.0.0" }, @@ -4147,6 +4134,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true, "engines": { "node": ">=0.4.0" } @@ -4201,24 +4189,25 @@ } }, "node_modules/discord-api-types": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.27.3.tgz", - "integrity": "sha512-HOG64DTpZ7CB5EU9eKbjHD50H5qG1pxKG8pmFfHUMKjKvEWeLBHfw0c9xF1cruiYLnBb3+n7m3jBWxZ3H1hcgQ==" + "version": "0.33.0", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.0.tgz", + "integrity": "sha512-RS1dMM6xuMhdHwQJ0T+XuCD7v1tKnyZ89Eq6q/DbOJWMbIh3ihgAzDhcF70QsFCtk9a5Gn9XU29S7eoEXuwQ5w==" }, "node_modules/discord.js": { - "version": "14.0.0-dev.1647259751.2297c2b", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.0.0-dev.1647259751.2297c2b.tgz", - "integrity": "sha512-3VgjiwAcJEEjzchvqFofClncISEivPawX7zeLT+7Kabqm7GIj+p5tfD8MIBbJPm/chcNDc/k2IN1uL154bKV7g==", - "dependencies": { - "@discordjs/builders": "^0.13.0-dev", - "@discordjs/collection": "^0.6.0-dev", - "@discordjs/rest": "^0.4.0-dev", - "@sapphire/snowflake": "^3.1.0", - "@types/ws": "^8.2.2", - "discord-api-types": "^0.27.3", + "version": "14.0.0-dev.1653091711-fdeac9d", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.0.0-dev.1653091711-fdeac9d.tgz", + "integrity": "sha512-wXx4tuWUcIadzWkfHgB190AUif5YXSA8udZ16F/S1kH37QeKGUsBGlAyn2WRmw/3oP2QA2FUIcJUQCGdcUExPg==", + "dependencies": { + "@discordjs/builders": "^0.14.0-dev", + "@discordjs/collection": "^0.7.0-dev", + "@discordjs/rest": "^0.5.0-dev", + "@sapphire/snowflake": "^3.2.1", + "@types/ws": "^8.5.3", + "discord-api-types": "^0.33.0", "fast-deep-equal": "^3.1.3", "lodash.snakecase": "^4.1.1", - "undici": "^4.14.1", + "tslib": "^2.3.1", + "undici": "^5.2.0", "ws": "^8.5.0" }, "engines": { @@ -4883,19 +4872,6 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", "dev": true }, - "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - }, - "engines": { - "node": ">= 6" - } - }, "node_modules/fs-access": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", @@ -6919,6 +6895,7 @@ "version": "1.51.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "dev": true, "engines": { "node": ">= 0.6" } @@ -6927,6 +6904,7 @@ "version": "2.1.34", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "dev": true, "dependencies": { "mime-db": "1.51.0" }, @@ -7002,25 +6980,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "node_modules/node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "dependencies": { - "whatwg-url": "^5.0.0" - }, - "engines": { - "node": "4.x || >=6.0.0" - }, - "peerDependencies": { - "encoding": "^0.1.0" - }, - "peerDependenciesMeta": { - "encoding": { - "optional": true - } - } - }, "node_modules/node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -8463,11 +8422,6 @@ "node": ">=6" } }, - "node_modules/tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" - }, "node_modules/trim-newlines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", @@ -8658,9 +8612,9 @@ } }, "node_modules/undici": { - "version": "4.15.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-4.15.1.tgz", - "integrity": "sha512-h8LJybhMKD09IyQZoQadNtIR/GmugVhTOVREunJrpV6RStriKBFdSVoFzEzTihwXi/27DIBO+Z0OGF+Mzfi0lA==", + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.2.0.tgz", + "integrity": "sha512-XY6+NS3WH9b3TKOHeNz2CjR+qrVz/k4fO9g3etPpLozRvULoQmZ1+dk9JbIz40ehn27xzFk4jYVU2MU3Nle62A==", "engines": { "node": ">=12.18" } @@ -8817,11 +8771,6 @@ "makeerror": "1.0.12" } }, - "node_modules/webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" - }, "node_modules/whatwg-encoding": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", @@ -8837,15 +8786,6 @@ "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", "dev": true }, - "node_modules/whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", - "dependencies": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -9071,14 +9011,6 @@ "funding": { "url": "https://github.com/sponsors/sindresorhus" } - }, - "node_modules/zod": { - "version": "3.13.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.13.4.tgz", - "integrity": "sha512-LZRucWt4j/ru5azOkJxCfpR87IyFDn8h2UODdqvXzZLb3K7bb9chUrUIGTy3BPsr8XnbQYfQ5Md5Hu2OYIo1mg==", - "funding": { - "url": "https://github.com/sponsors/colinhacks" - } } }, "dependencies": { @@ -10440,36 +10372,34 @@ } }, "@discordjs/builders": { - "version": "0.13.0-dev.1647259738.2297c2b", - "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.13.0-dev.1647259738.2297c2b.tgz", - "integrity": "sha512-SywFeczvI8p3US9k2gD2Iza4jPgDpKzuwA8ISrhWF9gPyECxUpgndgW5iZ1M8PhNKjtdZ9Gwn+P7mDpWgpGwZA==", + "version": "0.14.0-dev.1653091712-fdeac9d", + "resolved": "https://registry.npmjs.org/@discordjs/builders/-/builders-0.14.0-dev.1653091712-fdeac9d.tgz", + "integrity": "sha512-7/esDI5KkDBI8sxSNFmPYNQXMUTbopD4FkjBAm+nQmp5Xxda1xFjWvi3oJ7QC8l/IVanUAD47xxrb8lhckMRzA==", "requires": { - "@sindresorhus/is": "^4.4.0", - "discord-api-types": "^0.27.3", + "@sapphire/shapeshift": "^3.0.0", + "@sindresorhus/is": "^4.6.0", + "discord-api-types": "^0.33.0", "fast-deep-equal": "^3.1.3", - "ts-mixer": "^6.0.0", - "tslib": "^2.3.1", - "zod": "^3.11.6" + "ts-mixer": "^6.0.1", + "tslib": "^2.3.1" } }, "@discordjs/collection": { - "version": "0.6.0-dev.1647259738.2297c2b", - "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.6.0-dev.1647259738.2297c2b.tgz", - "integrity": "sha512-A+c2qy2HCzVDD3MAoIsL+MKPJhI+jCrcZbIIc6nRZcnCKT544qlI2Sr972sw1bzOj97HD/m4Qd0ElUeQzkHsbQ==" + "version": "0.7.0-dev.1653091708-fdeac9d", + "resolved": "https://registry.npmjs.org/@discordjs/collection/-/collection-0.7.0-dev.1653091708-fdeac9d.tgz", + "integrity": "sha512-21gKkNVlqWMTf5kkZ2uAkfe8kU149w/JXC9Vpu7nNEir6A5AHNPULtd+1FssvXYAfoEnzus7/gZC6pYD5eX/gQ==" }, "@discordjs/rest": { - "version": "0.4.0-dev.1647259762.2297c2b", - "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.4.0-dev.1647259762.2297c2b.tgz", - "integrity": "sha512-Pt1InmNvdDKSO8/vZg7K2VLB05iOdtScM9jHczLd3NsMWd66DDOzNorKQUjc84nL80RkZ7CCELy/eOn0uwrN4A==", - "requires": { - "@discordjs/collection": "^0.6.0-dev", - "@sapphire/async-queue": "^1.2.0", - "@sapphire/snowflake": "^3.1.0", - "@types/node-fetch": "^2.5.12", - "discord-api-types": "^0.27.0", - "form-data": "^4.0.0", - "node-fetch": "^2.6.7", - "tslib": "^2.3.1" + "version": "0.5.0-dev.1653091732-fdeac9d", + "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-0.5.0-dev.1653091732-fdeac9d.tgz", + "integrity": "sha512-2XIobHE+C0X/LFJC205CSeiHKvt0aBRqYb5dwAoq6VsZAprmvL+Mma0V2bKWInaOCmrr85X+XlEgQf+H22CK+A==", + "requires": { + "@discordjs/collection": "^0.7.0-dev", + "@sapphire/async-queue": "^1.3.1", + "@sapphire/snowflake": "^3.2.1", + "discord-api-types": "^0.33.0", + "tslib": "^2.3.1", + "undici": "^5.2.0" } }, "@eslint/eslintrc": { @@ -10852,14 +10782,19 @@ } }, "@sapphire/async-queue": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.3.0.tgz", - "integrity": "sha512-z+CDw5X4UgIEpZL8KM+ThVx1i8V60HBg0l/oFewTNbQQeRDJHdVxHyJykv+SF1H+Rc8EkMS81VTWo95jVYgO/g==" + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@sapphire/async-queue/-/async-queue-1.3.1.tgz", + "integrity": "sha512-FFTlPOWZX1kDj9xCAsRzH5xEJfawg1lNoYAA+ecOWJMHOfiZYb1uXOI3ne9U4UILSEPwfE68p3T9wUHwIQfR0g==" + }, + "@sapphire/shapeshift": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@sapphire/shapeshift/-/shapeshift-3.0.0.tgz", + "integrity": "sha512-LTVj/a70UDzjOFaViMGpVzSzKYD2pBk0TmZIHnBf4vnytV7TK/L6XVN6hslq7R+qwRZyL/mzIldu6mAV6r7vzA==" }, "@sapphire/snowflake": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.2.0.tgz", - "integrity": "sha512-tfHzY+6/5bbHdB+uNqsEQ5rhjaZAoFUrqP/l1S5jwxMdKeSCIiGkJjcE99/WGGdzyWGjTNgNVX/dt4Me/FdMlg==" + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/@sapphire/snowflake/-/snowflake-3.2.2.tgz", + "integrity": "sha512-ula2O0kpSZtX9rKXNeQMrHwNd7E4jPDJYUXmEGTFdMRfyfMw+FPyh04oKMjAiDuOi64bYgVkOV3MjK+loImFhQ==" }, "@sindresorhus/is": { "version": "4.6.0", @@ -11019,27 +10954,6 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-17.0.10.tgz", "integrity": "sha512-S/3xB4KzyFxYGCppyDt68yzBU9ysL88lSdIah4D6cptdcltc4NCPCAMc0+PCpg/lLIyC7IPvj2Z52OJWeIUkog==" }, - "@types/node-fetch": { - "version": "2.6.1", - "resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.1.tgz", - "integrity": "sha512-oMqjURCaxoSIsHSr1E47QHzbmzNR5rK8McHuNb11BOM9cHcIK3Avy0s/b2JlXHoQGTYS3NsvWzV1M0iK7l0wbA==", - "requires": { - "@types/node": "*", - "form-data": "^3.0.0" - }, - "dependencies": { - "form-data": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz", - "integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - } - } - }, "@types/normalize-package-data": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/@types/normalize-package-data/-/normalize-package-data-2.4.1.tgz", @@ -11319,7 +11233,8 @@ "asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", - "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=" + "integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k=", + "dev": true }, "babel-jest": { "version": "27.5.1", @@ -11626,6 +11541,7 @@ "version": "1.0.8", "resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz", "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", + "dev": true, "requires": { "delayed-stream": "~1.0.0" } @@ -12167,7 +12083,8 @@ "delayed-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz", - "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=" + "integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk=", + "dev": true }, "detect-indent": { "version": "6.0.0", @@ -12204,24 +12121,25 @@ } }, "discord-api-types": { - "version": "0.27.3", - "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.27.3.tgz", - "integrity": "sha512-HOG64DTpZ7CB5EU9eKbjHD50H5qG1pxKG8pmFfHUMKjKvEWeLBHfw0c9xF1cruiYLnBb3+n7m3jBWxZ3H1hcgQ==" + "version": "0.33.0", + "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.33.0.tgz", + "integrity": "sha512-RS1dMM6xuMhdHwQJ0T+XuCD7v1tKnyZ89Eq6q/DbOJWMbIh3ihgAzDhcF70QsFCtk9a5Gn9XU29S7eoEXuwQ5w==" }, "discord.js": { - "version": "14.0.0-dev.1647259751.2297c2b", - "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.0.0-dev.1647259751.2297c2b.tgz", - "integrity": "sha512-3VgjiwAcJEEjzchvqFofClncISEivPawX7zeLT+7Kabqm7GIj+p5tfD8MIBbJPm/chcNDc/k2IN1uL154bKV7g==", - "requires": { - "@discordjs/builders": "^0.13.0-dev", - "@discordjs/collection": "^0.6.0-dev", - "@discordjs/rest": "^0.4.0-dev", - "@sapphire/snowflake": "^3.1.0", - "@types/ws": "^8.2.2", - "discord-api-types": "^0.27.3", + "version": "14.0.0-dev.1653091711-fdeac9d", + "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.0.0-dev.1653091711-fdeac9d.tgz", + "integrity": "sha512-wXx4tuWUcIadzWkfHgB190AUif5YXSA8udZ16F/S1kH37QeKGUsBGlAyn2WRmw/3oP2QA2FUIcJUQCGdcUExPg==", + "requires": { + "@discordjs/builders": "^0.14.0-dev", + "@discordjs/collection": "^0.7.0-dev", + "@discordjs/rest": "^0.5.0-dev", + "@sapphire/snowflake": "^3.2.1", + "@types/ws": "^8.5.3", + "discord-api-types": "^0.33.0", "fast-deep-equal": "^3.1.3", "lodash.snakecase": "^4.1.1", - "undici": "^4.14.1", + "tslib": "^2.3.1", + "undici": "^5.2.0", "ws": "^8.5.0" } }, @@ -12726,16 +12644,6 @@ "integrity": "sha512-WIWGi2L3DyTUvUrwRKgGi9TwxQMUEqPOPQBVi71R96jZXJdFskXEmf54BoZaS1kknGODoIGASGEzBUYdyMCBJg==", "dev": true }, - "form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "requires": { - "asynckit": "^0.4.0", - "combined-stream": "^1.0.8", - "mime-types": "^2.1.12" - } - }, "fs-access": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/fs-access/-/fs-access-1.0.1.tgz", @@ -14274,12 +14182,14 @@ "mime-db": { "version": "1.51.0", "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.51.0.tgz", - "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==" + "integrity": "sha512-5y8A56jg7XVQx2mbv1lu49NR4dokRnhZYTtL+KGfaa27uq4pSTXkwQkFJl4pkRMyNFz/EtYDSkiiEHx3F7UN6g==", + "dev": true }, "mime-types": { "version": "2.1.34", "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.34.tgz", "integrity": "sha512-6cP692WwGIs9XXdOO4++N+7qjqv0rqxxVvJ3VHPh/Sc9mVZcQP+ZGhkKiTvWMQRr2tbHkJP/Yn7Y0npb3ZBs4A==", + "dev": true, "requires": { "mime-db": "1.51.0" } @@ -14340,14 +14250,6 @@ "integrity": "sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==", "dev": true }, - "node-fetch": { - "version": "2.6.7", - "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", - "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", - "requires": { - "whatwg-url": "^5.0.0" - } - }, "node-int64": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/node-int64/-/node-int64-0.4.0.tgz", @@ -15425,11 +15327,6 @@ "universalify": "^0.1.2" } }, - "tr46": { - "version": "0.0.3", - "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", - "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" - }, "trim-newlines": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/trim-newlines/-/trim-newlines-3.0.1.tgz", @@ -15558,9 +15455,9 @@ "optional": true }, "undici": { - "version": "4.15.1", - "resolved": "https://registry.npmjs.org/undici/-/undici-4.15.1.tgz", - "integrity": "sha512-h8LJybhMKD09IyQZoQadNtIR/GmugVhTOVREunJrpV6RStriKBFdSVoFzEzTihwXi/27DIBO+Z0OGF+Mzfi0lA==" + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/undici/-/undici-5.2.0.tgz", + "integrity": "sha512-XY6+NS3WH9b3TKOHeNz2CjR+qrVz/k4fO9g3etPpLozRvULoQmZ1+dk9JbIz40ehn27xzFk4jYVU2MU3Nle62A==" }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", @@ -15692,11 +15589,6 @@ "makeerror": "1.0.12" } }, - "webidl-conversions": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", - "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" - }, "whatwg-encoding": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/whatwg-encoding/-/whatwg-encoding-1.0.5.tgz", @@ -15712,15 +15604,6 @@ "integrity": "sha512-M4yMwr6mAnQz76TbJm914+gPpB/nCwvZbJU28cUD6dR004SAxDLOOSUaB1JDRqLtaOV/vi0IC5lEAGFgrjGv/g==", "dev": true }, - "whatwg-url": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", - "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", - "requires": { - "tr46": "~0.0.3", - "webidl-conversions": "^3.0.0" - } - }, "which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", @@ -15885,11 +15768,6 @@ "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", "dev": true - }, - "zod": { - "version": "3.13.4", - "resolved": "https://registry.npmjs.org/zod/-/zod-3.13.4.tgz", - "integrity": "sha512-LZRucWt4j/ru5azOkJxCfpR87IyFDn8h2UODdqvXzZLb3K7bb9chUrUIGTy3BPsr8XnbQYfQ5Md5Hu2OYIo1mg==" } } } diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index e04b3f7d..cfc18820 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -1,4 +1,4 @@ -import { concat, concatMap, from, fromEvent, map, Observable, of, skip, take } from 'rxjs'; +import { concat, concatMap, from, fromEvent, map, Observable, of, skip, take, throwError } from 'rxjs'; import { basename } from 'path'; import * as Files from '../utilities/readFile'; import type Wrapper from '../structures/wrapper'; @@ -27,6 +27,9 @@ export const onReady = (wrapper: Wrapper) => { ); const processPlugins$ = processCommandFiles$.pipe( concatMap(mod => { + if(mod.type === CommandType.Autocomplete) { + return throwError(() => SernError.NonValidModuleType + `. You cannot use command plugins and Autocomplete.`); + } const cmdPluginsRes = mod.plugins?.map(plug => { return { diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index d4a4c23d..dfbd116a 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -111,6 +111,7 @@ export type ModalSubmitCommand = Override< export type AutocompleteCommand = Override< BaseModule, { + name : string, type: CommandType.Autocomplete; onEvent?: EventPlugin[]; execute: (ctx: AutocompleteInteraction) => Awaitable; From 93942bd0e7d0ac688d20159cab2c70c3285085f4 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Mon, 23 May 2022 20:55:02 -0500 Subject: [PATCH 083/128] feat: move name and description out of OptionsData[] --- src/handler/events/interactionCreate.ts | 4 +--- src/handler/plugins/plugin.ts | 1 - src/handler/structures/module.ts | 10 ++++++---- src/handler/structures/structxports.ts | 4 ++-- 4 files changed, 9 insertions(+), 10 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 2d25e3fb..a5a07e7e 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -149,9 +149,7 @@ function autoCmpHandler(mod: Module | undefined, interaction: AutocompleteIntera filterCorrectModule(CommandType.Slash), concatMap(mod => { const choice = interaction.options.getFocused(true); - const selectedOption = mod.options?.find( - o => o.autocomplete && o.command.name === choice.name, - ); + const selectedOption = mod.options?.find(o => o.autocomplete && o.name === choice.name); if (selectedOption !== undefined && selectedOption.autocomplete) { return of( selectedOption.command.onEvent?.map(e => diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 39752e2e..4f9bc554 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -67,7 +67,6 @@ type ModuleNoPlugins = ValueOf<{ }>; //TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH - export function sernModule(plugins: CommandPlugin[], mod: ModuleNoPlugins): Module { if (mod.type !== CommandType.Autocomplete) return { diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index dfbd116a..f2165f18 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -111,7 +111,7 @@ export type ModalSubmitCommand = Override< export type AutocompleteCommand = Override< BaseModule, { - name : string, + name: string; type: CommandType.Autocomplete; onEvent?: EventPlugin[]; execute: (ctx: AutocompleteInteraction) => Awaitable; @@ -143,14 +143,16 @@ export type ModuleDefs = { [CommandType.Autocomplete]: AutocompleteCommand; }; -type OptionsData = +export type OptionsData = | Exclude | { - required?: boolean; + name: string; + description: string; autocomplete: true; + required?: boolean; type: | ApplicationCommandOptionType.String | ApplicationCommandOptionType.Number | ApplicationCommandOptionType.Integer; - command: AutocompleteCommand; + command: Omit; }; diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index a9fed985..9e544ec2 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -1,6 +1,6 @@ import Context from './context'; -import type { BothCommand, Module, SlashCommand, TextCommand } from './module'; +import type { BothCommand, Module, SlashCommand, TextCommand, OptionsData } from './module'; import type Wrapper from './wrapper'; export * from './enums'; -export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper }; +export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper, OptionsData }; From b08eebf6850acaee3b56bb1c60aec2a026a5144c Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 24 May 2022 14:44:07 -0500 Subject: [PATCH 084/128] feat: finishing optionData for autocomplete changes, adding class for builder --- src/handler/structures/module.ts | 73 ++++++++++++++++++++----- src/handler/utilities/optionsBuilder.ts | 8 +++ 2 files changed, 66 insertions(+), 15 deletions(-) create mode 100644 src/handler/utilities/optionsBuilder.ts diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index f2165f18..2c7d7071 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -1,7 +1,14 @@ import type { ApplicationCommandAutocompleteOption, + ApplicationCommandChannelOptionData, + ApplicationCommandChoicesData, + ApplicationCommandNonOptionsData, + ApplicationCommandNumericOptionData, ApplicationCommandOptionData, + ApplicationCommandSubCommandData, + ApplicationCommandSubGroupData, Awaitable, + BaseApplicationCommandOptionsData, ButtonInteraction, MessageContextMenuCommandInteraction, ModalSubmitInteraction, @@ -39,7 +46,7 @@ export type SlashCommand = Override< type: CommandType.Slash; onEvent?: EventPlugin[]; plugins?: CommandPlugin[]; - options?: OptionsData[]; + options?: SernOptionsData[]; } >; @@ -50,7 +57,7 @@ export type BothCommand = Override< onEvent?: EventPlugin[]; plugins?: CommandPlugin[]; alias?: string[]; - options?: OptionsData[]; + options?: SernOptionsData[]; } >; @@ -143,16 +150,52 @@ export type ModuleDefs = { [CommandType.Autocomplete]: AutocompleteCommand; }; -export type OptionsData = - | Exclude - | { - name: string; - description: string; - autocomplete: true; - required?: boolean; - type: - | ApplicationCommandOptionType.String - | ApplicationCommandOptionType.Number - | ApplicationCommandOptionType.Integer; - command: Omit; - }; +//TODO: support deeply nested Autocomplete +// objective: construct union of ApplicationCommandOptionData change any Autocomplete data +// into Sern autocomplete data. + +export type SernAutocompleteData = Override< + BaseApplicationCommandOptionsData, + { + autocomplete: true; + type: + | ApplicationCommandOptionType.String + | ApplicationCommandOptionType.Number + | ApplicationCommandOptionType.Integer; + command: Omit; + } +>; + +/** + * Type that just uses SernAutocompleteData and not regular autocomplete + */ +export type BaseOptions = + | ApplicationCommandChoicesData + | ApplicationCommandNonOptionsData + | ApplicationCommandChannelOptionData + | ApplicationCommandAutocompleteOption + | ApplicationCommandNumericOptionData + | SernAutocompleteData; + +export type SernSubCommandData = Override< + Omit, + { + type: ApplicationCommandOptionType.Subcommand; + options?: BaseOptions[]; + } +>; + +export type SernSubCommandGroupData = Override< + Omit, + { + type: ApplicationCommandOptionType.SubcommandGroup; + options?: SernSubCommandData[]; + } +>; + +export type SernOptionsData = + U extends ApplicationCommandSubCommandData + ? SernSubCommandData + : U extends ApplicationCommandSubGroupData + ? SernSubCommandGroupData + : BaseOptions; diff --git a/src/handler/utilities/optionsBuilder.ts b/src/handler/utilities/optionsBuilder.ts new file mode 100644 index 00000000..a99453aa --- /dev/null +++ b/src/handler/utilities/optionsBuilder.ts @@ -0,0 +1,8 @@ +import type { SernOptionsData } from '../structures/module'; +import type { ApplicationCommandOptionData } from 'discord.js'; + +class OptionsBuilder { + public constructor(private options: ApplicationCommandOptionData[] = []) { + this.options = options; + } +} From d63423cfc458cb9ab07b9900a7c4d2f7ea8d71b9 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Wed, 25 May 2022 15:29:28 -0500 Subject: [PATCH 085/128] feat: finishing autocomplete!! --- src/handler/events/interactionCreate.ts | 2 +- src/handler/events/readyEvent.ts | 24 +++++++++++++++++++---- src/handler/structures/module.ts | 4 ++-- src/handler/structures/structxports.ts | 26 +++++++++++++++++++++++-- src/handler/utilities/optionsBuilder.ts | 8 -------- src/types/handler.ts | 26 +++++++++++++++---------- 6 files changed, 63 insertions(+), 27 deletions(-) delete mode 100644 src/handler/utilities/optionsBuilder.ts diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index a5a07e7e..e4cf8acf 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -201,7 +201,7 @@ export function onInteractionCreate(wrapper: Wrapper) { return modalHandler(modul, interaction); } if (interaction.isAutocomplete()) { - const modul = Files.ApplicationCommands[1].get(interaction.commandName); + const modul = Files.ApplicationCommands['1'].get(interaction.commandName); return autoCmpHandler(modul, interaction); } return of(); diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index cfc18820..d1eeb296 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -1,4 +1,15 @@ -import { concat, concatMap, from, fromEvent, map, Observable, of, skip, take, throwError } from 'rxjs'; +import { + concat, + concatMap, + from, + fromEvent, + map, + Observable, + of, + skip, + take, + throwError, +} from 'rxjs'; import { basename } from 'path'; import * as Files from '../utilities/readFile'; import type Wrapper from '../structures/wrapper'; @@ -27,8 +38,12 @@ export const onReady = (wrapper: Wrapper) => { ); const processPlugins$ = processCommandFiles$.pipe( concatMap(mod => { - if(mod.type === CommandType.Autocomplete) { - return throwError(() => SernError.NonValidModuleType + `. You cannot use command plugins and Autocomplete.`); + if (mod.type === CommandType.Autocomplete) { + return throwError( + () => + SernError.NonValidModuleType + + `. You cannot use command plugins and Autocomplete.`, + ); } const cmdPluginsRes = mod.plugins?.map(plug => { @@ -89,6 +104,7 @@ function registerModule(mod: DefinitelyDefined): Resul return Ok.EMPTY; }) .with({ type: CommandType.Slash }, mod => { + console.log(mod); Files.ApplicationCommands[ApplicationCommandType.ChatInput].set(name, mod); return Ok.EMPTY; }) @@ -113,7 +129,7 @@ function registerModule(mod: DefinitelyDefined): Resul Files.MessageCompCommands[ComponentType.SelectMenu].set(name, mod); return Ok.EMPTY; }) - .with({ type : CommandType.Modal }, mod => { + .with({ type: CommandType.Modal }, mod => { Files.ModalSubmitCommands.set(name, mod); return Ok.EMPTY; }) diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 2c7d7071..20ded25c 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -1,5 +1,5 @@ import type { - ApplicationCommandAutocompleteOption, + ApplicationCommandAttachmentOption, ApplicationCommandChannelOptionData, ApplicationCommandChoicesData, ApplicationCommandNonOptionsData, @@ -173,8 +173,8 @@ export type BaseOptions = | ApplicationCommandChoicesData | ApplicationCommandNonOptionsData | ApplicationCommandChannelOptionData - | ApplicationCommandAutocompleteOption | ApplicationCommandNumericOptionData + | ApplicationCommandAttachmentOption | SernAutocompleteData; export type SernSubCommandData = Override< diff --git a/src/handler/structures/structxports.ts b/src/handler/structures/structxports.ts index 9e544ec2..5396cadd 100644 --- a/src/handler/structures/structxports.ts +++ b/src/handler/structures/structxports.ts @@ -1,6 +1,28 @@ import Context from './context'; -import type { BothCommand, Module, SlashCommand, TextCommand, OptionsData } from './module'; +import type { + BothCommand, + Module, + SlashCommand, + TextCommand, + SernOptionsData, + BaseOptions, + SernAutocompleteData, + SernSubCommandData, + SernSubCommandGroupData, +} from './module'; import type Wrapper from './wrapper'; export * from './enums'; -export { Context, SlashCommand, TextCommand, BothCommand, Module, Wrapper, OptionsData }; +export { + Context, + SlashCommand, + TextCommand, + BothCommand, + Module, + Wrapper, + SernOptionsData, + BaseOptions, + SernAutocompleteData, + SernSubCommandData, + SernSubCommandGroupData, +}; diff --git a/src/handler/utilities/optionsBuilder.ts b/src/handler/utilities/optionsBuilder.ts deleted file mode 100644 index a99453aa..00000000 --- a/src/handler/utilities/optionsBuilder.ts +++ /dev/null @@ -1,8 +0,0 @@ -import type { SernOptionsData } from '../structures/module'; -import type { ApplicationCommandOptionData } from 'discord.js'; - -class OptionsBuilder { - public constructor(private options: ApplicationCommandOptionData[] = []) { - this.options = options; - } -} diff --git a/src/types/handler.ts b/src/types/handler.ts index e9e393b0..dd6eb50f 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -1,13 +1,6 @@ -import type { - Awaitable, - ClientEvents, - CommandInteractionOptionResolver, - MessageOptions, - MessagePayload, -} from 'discord.js'; +import type { Awaitable, ClientEvents, CommandInteractionOptionResolver } from 'discord.js'; import type { EventEmitter } from 'events'; // Anything that can be sent in a `#send` or `#reply` -export type possibleOutput = T | (MessagePayload & MessageOptions); export type Nullish = T | undefined | null; // Thanks @cursorsdottsx export type ParseType = { @@ -16,8 +9,14 @@ export type ParseType = { export type Args = ParseType<{ text: string[]; slash: SlashOptions }>; -export type DiscordEvent = ParseType<{ [K in keyof ClientEvents]: (...args: ClientEvents[K]) => Awaitable }>; -export type EventEmitterRegister = [emitter: EventEmitter, k: string, cb: (...args: unknown[]) => Awaitable]; +export type DiscordEvent = ParseType<{ + [K in keyof ClientEvents]: (...args: ClientEvents[K]) => Awaitable; +}>; +export type EventEmitterRegister = [ + emitter: EventEmitter, + k: string, + cb: (...args: unknown[]) => Awaitable, +]; export type SlashOptions = Omit; @@ -25,3 +24,10 @@ export type SlashOptions = Omit = Omit & T2; export type DefinitelyDefined = T & Override; +export type Expand = T extends object ? { [K in keyof T]: Expand } : T; + +type Reconstruct = T extends Omit ? O & Reconstruct : T; + +type IsOptional = { + [K in keyof T]-?: T[K] extends Required[K] ? false : true; +}; From 9eef9dd318fa40c7fa1807335bee392c1441acba Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Wed, 25 May 2022 15:49:55 -0500 Subject: [PATCH 086/128] refactor: Simplifying logic of message filter --- src/handler/events/interactionCreate.ts | 4 +++- src/handler/events/messageEvent.ts | 5 ++++- src/handler/events/observableHandling.ts | 15 ++++++--------- src/handler/events/readyEvent.ts | 1 - src/handler/sernEmitter.ts | 3 +++ 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index e4cf8acf..22bbeab3 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -201,7 +201,9 @@ export function onInteractionCreate(wrapper: Wrapper) { return modalHandler(modul, interaction); } if (interaction.isAutocomplete()) { - const modul = Files.ApplicationCommands['1'].get(interaction.commandName); + const modul = + Files.ApplicationCommands['1'].get(interaction.commandName) ?? + Files.BothCommands.get(interaction.commandName); return autoCmpHandler(modul, interaction); } return of(); diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 5ef2061e..d21a0e4f 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -23,7 +23,10 @@ export const onMessageCreate = (wrapper: Wrapper) => { return { ctx: Context.wrap(message), //TODO : check for BothCommand args: ['text', rest], - mod: Files.BothCommands.get(prefix) ?? Files.TextCommands.aliases.get(prefix), + mod: + Files.TextCommands.text.get(prefix) ?? + Files.BothCommands.get(prefix) ?? + Files.TextCommands.aliases.get(prefix), }; }), ); diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index b9efc357..eb9b73c6 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -30,15 +30,12 @@ export function ignoreNonBot(prefix: string) { new Observable(subscriber => { return src.subscribe({ next(m) { - const passAll = [ - isNotFromBot, - (m: Message) => - m.content - .slice(0, prefix.length) - .localeCompare(prefix, undefined, { sensitivity: 'accent' }) === 0, - ].every(fn => fn(m)); - - if (passAll) { + const messageFromHumanAndHasPrefix = + !m.author.bot && + m.content + .slice(0, prefix.length) + .localeCompare(prefix, undefined, { sensitivity: 'accent' }) === 0; + if (messageFromHumanAndHasPrefix) { subscriber.next(m); } }, diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index d1eeb296..026fddb4 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -104,7 +104,6 @@ function registerModule(mod: DefinitelyDefined): Resul return Ok.EMPTY; }) .with({ type: CommandType.Slash }, mod => { - console.log(mod); Files.ApplicationCommands[ApplicationCommandType.ChatInput].set(name, mod); return Ok.EMPTY; }) diff --git a/src/handler/sernEmitter.ts b/src/handler/sernEmitter.ts index 4beb0f6f..e4074d58 100644 --- a/src/handler/sernEmitter.ts +++ b/src/handler/sernEmitter.ts @@ -11,6 +11,9 @@ type SernEventsMapping = { ['error']: [Error | string]; }; +/** + * + */ export default class SernEmitter extends EventEmitter { public override on( eventName: T, From 0ae541daba4c5d2aa3e612ab4b78fd6a858717ad Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Wed, 25 May 2022 17:17:55 -0500 Subject: [PATCH 087/128] feat: Adding docs to some data structures, moving to default from export files --- src/handler/events/observableHandling.ts | 1 - src/handler/events/readyEvent.ts | 6 +++++- src/handler/plugins/plugin.ts | 9 +++++---- src/handler/sern.ts | 18 +----------------- src/handler/sernEmitter.ts | 20 +++++++++++++++----- src/handler/structures/context.ts | 14 +++++++++++--- src/handler/utilities/readFile.ts | 2 +- src/types/handler.ts | 1 - 8 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index eb9b73c6..ba3d552c 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -1,7 +1,6 @@ import type { Message } from 'discord.js'; import { Observable, throwError } from 'rxjs'; import { SernError } from '../structures/errors'; -import { isNotFromBot } from '../utilities/messageHelpers'; import type { Module, ModuleDefs } from '../structures/module'; import { correctModuleType } from '../utilities/predicates'; diff --git a/src/handler/events/readyEvent.ts b/src/handler/events/readyEvent.ts index 026fddb4..224a2ae2 100644 --- a/src/handler/events/readyEvent.ts +++ b/src/handler/events/readyEvent.ts @@ -82,7 +82,11 @@ export const onReady = (wrapper: Wrapper) => { if (loadedPluginsCorrectly) { const res = registerModule(mod); if (res.err) { - throw Error(SernError.NonValidModuleType); + throw Error( + SernError.NonValidModuleType + + ', or loading modules was handled incorrectly. ' + + 'Check commands path and command files!', + ); } wrapper.sernEmitter?.emit('module.register', { success: true, module: mod }); } else { diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 4f9bc554..342a7ba2 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -1,8 +1,8 @@ // // Plugins can be inserted on all commands and are emitted // -// 1.) on ready event, where all commands are loaded. -// 2.) on corresponding observable (command triggers) +// 1. on ready event, where all commands are loaded. +// 2. on corresponding observable (command triggers) // // The goal of plugins is to organize commands and // provide extensions to repetitive patterns @@ -68,10 +68,11 @@ type ModuleNoPlugins = ValueOf<{ //TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH export function sernModule(plugins: CommandPlugin[], mod: ModuleNoPlugins): Module { - if (mod.type !== CommandType.Autocomplete) + if (mod.type === CommandType.Autocomplete) { + return mod; + } else return { plugins, ...mod, }; - else return mod; } diff --git a/src/handler/sern.ts b/src/handler/sern.ts index 1f49ae6d..dbe0af9c 100644 --- a/src/handler/sern.ts +++ b/src/handler/sern.ts @@ -1,17 +1,13 @@ import type { DiscordEvent, EventEmitterRegister } from '../types/handler'; -import { ApplicationCommandType, Client } from 'discord.js'; - import type Wrapper from './structures/wrapper'; import { fromEvent } from 'rxjs'; -import { SernError } from './structures/errors'; import { onReady } from './events/readyEvent'; import { onMessageCreate } from './events/messageEvent'; import { onInteractionCreate } from './events/interactionCreate'; -import { match, P } from 'ts-pattern'; import { Err, Ok } from 'ts-results'; -import { CommandType } from './structures/enums'; import { isDiscordEvent } from './utilities/predicates'; +import type { Client } from 'discord.js'; export function init(wrapper: Wrapper) { const { events, client } = wrapper; @@ -33,18 +29,6 @@ function eventObserver(client: Client, events: (DiscordEvent | EventEmitterRegis }); } -export function cmdTypeToDjs(ty: CommandType) { - return match(ty) - .with(CommandType.Slash, () => ApplicationCommandType.ChatInput) - .with(CommandType.MenuUser, () => ApplicationCommandType.User) - .with(CommandType.MenuMsg, () => ApplicationCommandType.Message) - .with(CommandType.Both, () => ApplicationCommandType.ChatInput) - .with(P._, () => { - throw new Error(SernError.NonValidModuleType); - }) - .exhaustive(); -} - export const controller = { next: () => Ok.EMPTY, stop: () => Err.EMPTY, diff --git a/src/handler/sernEmitter.ts b/src/handler/sernEmitter.ts index e4074d58..a6282418 100644 --- a/src/handler/sernEmitter.ts +++ b/src/handler/sernEmitter.ts @@ -11,24 +11,34 @@ type SernEventsMapping = { ['error']: [Error | string]; }; -/** - * - */ export default class SernEmitter extends EventEmitter { + /** + * Listening to sern events with on. This event stays on until a crash or a normal exit + * @param eventName + * @param listener what to do with the data + */ public override on( eventName: T, listener: (...args: SernEventsMapping[T][]) => void, ): this { return super.on(eventName, listener); } - + /** + * Listening to sern events with on. This event stays on until a crash or a normal exit + * @param eventName + * @param listener what to do with the data + */ public override once( eventName: T, listener: (...args: SernEventsMapping[T][]) => void, ): this { return super.once(eventName, listener); } - + /** + * Listening to sern events with on. This event stays on until a crash or a normal exit + * @param eventName + * @param args the arguments for emitting the { eventName } + */ public override emit( eventName: T, ...args: SernEventsMapping[T] diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts index 4eb3d1b9..918c7941 100644 --- a/src/handler/structures/context.ts +++ b/src/handler/structures/context.ts @@ -24,9 +24,8 @@ function firstSome(...args: Option[]): Nullish { //Could I refactor with Either monad? /** - * The Context class will provide values that are shared between + * Provides values shared between * Message and ChatInputCommandInteraction - * */ export default class Context { private constructor( @@ -37,11 +36,20 @@ export default class Context { this.oInterac = oInterac; } + /** + * Getting the Message object. Crashes if module type is + * CommandType.Slash or the event fired in a Both command was + * ChatInputCommandInteraction + */ @ExternallyUsed public get message() { return this.oMsg.unwrap(); } - + /** + * Getting the ChatInputCommandInteraction object. Crashes if module type is + * CommandType.Text or the event fired in a Both command was + * Message + */ @ExternallyUsed public get interaction() { return this.oInterac.unwrap(); diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts index c41e584a..47dbdffb 100644 --- a/src/handler/utilities/readFile.ts +++ b/src/handler/utilities/readFile.ts @@ -52,7 +52,7 @@ export function buildData(commandDir: string): Observable<{ return from( getCommands(commandDir).map(absPath => { // eslint-disable-next-line @typescript-eslint/no-var-requires - const mod = require(absPath).module; + const mod = require(absPath).default; return { mod, absPath }; }), ); diff --git a/src/types/handler.ts b/src/types/handler.ts index dd6eb50f..fb42a53f 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -1,6 +1,5 @@ import type { Awaitable, ClientEvents, CommandInteractionOptionResolver } from 'discord.js'; import type { EventEmitter } from 'events'; -// Anything that can be sent in a `#send` or `#reply` export type Nullish = T | undefined | null; // Thanks @cursorsdottsx export type ParseType = { From e69dae92cda1f22ea09e366d61e091a716eeca7e Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Fri, 27 May 2022 15:06:24 -0500 Subject: [PATCH 088/128] refactor: cleaning up code, removing unuseds --- src/handler/events/interactionCreate.ts | 2 +- src/handler/events/observableHandling.ts | 14 +++++++++++++- src/handler/structures/errors.ts | 4 ---- src/handler/structures/module.ts | 13 +++++++++++++ 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 22bbeab3..bc1421b3 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -206,7 +206,7 @@ export function onInteractionCreate(wrapper: Wrapper) { Files.BothCommands.get(interaction.commandName); return autoCmpHandler(modul, interaction); } - return of(); + return throwError(() => SernError.NotSupportedInteraction); }), ) .subscribe({ diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index ba3d552c..9449f491 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -1,8 +1,9 @@ import type { Message } from 'discord.js'; import { Observable, throwError } from 'rxjs'; import { SernError } from '../structures/errors'; -import type { Module, ModuleDefs } from '../structures/module'; +import type { InteractionDefs, Module, ModuleDefs } from '../structures/module'; import { correctModuleType } from '../utilities/predicates'; +import type { CommandType } from '../structures/enums'; export function filterCorrectModule(cmdType: T) { return (src: Observable) => @@ -43,3 +44,14 @@ export function ignoreNonBot(prefix: string) { }); }); } + +export function processOnEvents(interaction: InteractionDefs[T]) { + return (src: Observable) => + new Observable(subscriber => { + return src.subscribe({ + next(m) {}, + error: e => subscriber.error(e), + complete: () => subscriber.complete(), + }); + }); +} diff --git a/src/handler/structures/errors.ts b/src/handler/structures/errors.ts index 82d2f9ca..f95f2cf7 100644 --- a/src/handler/structures/errors.ts +++ b/src/handler/structures/errors.ts @@ -1,11 +1,7 @@ export enum SernError { - ReservedEvent = 'Cannot register the reserved ready event. Please use the init property.', - NoAlias = 'You cannot provide an array with elements to a slash command.', NonValidModuleType = 'Detected an unknown module type', UndefinedModule = `A module could not be detected at`, MismatchModule = `A module type mismatched with event emitted!`, - NotImplemented = 'This feature has not yet been implemented', NotSupportedInteraction = `This interaction is not supported.`, - NotValidEventName = `Supplied a non valid event name`, PluginFailure = `A plugin failed to call controller.next()`, } diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 20ded25c..d6b862d3 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -21,6 +21,7 @@ import type Context from './context'; import { CommandType, PluginType } from './enums'; import type { AutocompleteInteraction } from 'discord.js'; import type { ApplicationCommandOptionType } from 'discord.js'; +import { ChatInputCommandInteraction, Message } from 'discord.js'; export interface BaseModule { type: CommandType | PluginType; @@ -150,6 +151,18 @@ export type ModuleDefs = { [CommandType.Autocomplete]: AutocompleteCommand; }; +export type InteractionDefs = { + [CommandType.Text]: Context; + [CommandType.Slash]: Context; + [CommandType.Both]: Context; + [CommandType.MenuMsg]: MessageContextMenuCommandInteraction; + [CommandType.MenuUser]: UserContextMenuCommandInteraction; + [CommandType.Button]: ButtonInteraction; + [CommandType.MenuSelect]: SelectMenuInteraction; + [CommandType.Modal]: ModalSubmitInteraction; + [CommandType.Autocomplete]: AutocompleteInteraction; +}; + //TODO: support deeply nested Autocomplete // objective: construct union of ApplicationCommandOptionData change any Autocomplete data // into Sern autocomplete data. From 475b0736d573bb8969b2a0eb9180231aa8618a0e Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 28 May 2022 20:29:23 -0500 Subject: [PATCH 089/128] feat: adding refactoring for repetitive event plugin processing --- src/handler/events/interactionCreate.ts | 2 +- src/handler/events/messageEvent.ts | 2 +- src/handler/events/observableHandling.ts | 33 ++++++++++++++++-------- src/handler/plugins/plugin.ts | 33 +++++++++++++++++------- src/handler/structures/module.ts | 5 ++-- src/index.ts | 4 +++ src/types/handler.ts | 7 ++++- 7 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index bc1421b3..c8bfb467 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -12,7 +12,7 @@ import { match } from 'ts-pattern'; import { SernError } from '../structures/errors'; import Context from '../structures/context'; import { controller } from '../sern'; -import type { AutocompleteCommand, Module, SlashCommand } from '../structures/module'; +import type { Module } from '../structures/module'; import { isButton, isChatInputCommand, diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index d21a0e4f..3b7892bb 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -21,7 +21,7 @@ export const onMessageCreate = (wrapper: Wrapper) => { map(message => { const [prefix, ...rest] = fmt(message, defaultPrefix); return { - ctx: Context.wrap(message), //TODO : check for BothCommand + ctx: Context.wrap(message), args: ['text', rest], mod: Files.TextCommands.text.get(prefix) ?? diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index 9449f491..a5ce95c0 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -1,9 +1,13 @@ -import type { Message } from 'discord.js'; +import type { Awaitable, Message } from 'discord.js'; import { Observable, throwError } from 'rxjs'; import { SernError } from '../structures/errors'; import type { InteractionDefs, Module, ModuleDefs } from '../structures/module'; import { correctModuleType } from '../utilities/predicates'; import type { CommandType } from '../structures/enums'; +import type { UnionToIntersection } from '../../types/handler'; +import { controller } from '../sern'; +import type { Result } from 'ts-results'; +import type { SelectMenuInteraction } from 'discord.js'; export function filterCorrectModule(cmdType: T) { return (src: Observable) => @@ -45,13 +49,20 @@ export function ignoreNonBot(prefix: string) { }); } -export function processOnEvents(interaction: InteractionDefs[T]) { - return (src: Observable) => - new Observable(subscriber => { - return src.subscribe({ - next(m) {}, - error: e => subscriber.error(e), - complete: () => subscriber.complete(), - }); - }); -} +// export function processOnEvents(ty: T, interaction: InteractionDefs[T]) { +// return (src: Observable) => +// new Observable>>(subscriber => { +// return src.subscribe({ +// next(m) { +// subscriber.next(m.onEvent?.map(e => { +// return (>e).execute( +// [interaction as SelectMenuInteraction], //This is just to satisfy compiler +// controller, +// ); +// })) ; +// }, +// error: e => subscriber.error(e), +// complete: () => subscriber.complete(), +// }); +// }); +// } diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index 342a7ba2..ca8227de 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -45,16 +45,29 @@ export type CommandPlugin = Override< //TODO: rn adding the modType check a little hackish. Find better way to determine the // module type of the event plugin -export type EventPlugin = Override< - BasePlugin, - { - type: PluginType.Event; - execute: ( - event: Parameters, - controller: Controller, - ) => Awaitable>; - } ->; +// export type EventPlugin = Override< +// BasePlugin, +// { +// type: PluginType.Event; +// execute: ( +// event: Parameters, +// controller: Controller, +// ) => Awaitable>; +// } +// >; + +export type EventPlugin = { + [K in T]: Override< + BasePlugin, + { + type: PluginType.Event; + execute: ( + event: Parameters, + controller: Controller, + ) => Awaitable>; + } + >; +}[T]; export function plugins(...plug: CommandPlugin[]): CommandPlugin[]; export function plugins(...plug: EventPlugin[]): EventPlugin[]; diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index d6b862d3..42b51d51 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -21,7 +21,7 @@ import type Context from './context'; import { CommandType, PluginType } from './enums'; import type { AutocompleteInteraction } from 'discord.js'; import type { ApplicationCommandOptionType } from 'discord.js'; -import { ChatInputCommandInteraction, Message } from 'discord.js'; +import { ChatInputCommandInteraction, Message, User } from 'discord.js'; export interface BaseModule { type: CommandType | PluginType; @@ -119,8 +119,8 @@ export type ModalSubmitCommand = Override< export type AutocompleteCommand = Override< BaseModule, { - name: string; type: CommandType.Autocomplete; + name: string; onEvent?: EventPlugin[]; execute: (ctx: AutocompleteInteraction) => Awaitable; } @@ -150,7 +150,6 @@ export type ModuleDefs = { [CommandType.Modal]: ModalSubmitCommand; [CommandType.Autocomplete]: AutocompleteCommand; }; - export type InteractionDefs = { [CommandType.Text]: Context; [CommandType.Slash]: Context; diff --git a/src/index.ts b/src/index.ts index 4fd70b99..76c383b6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,8 @@ +import type { UnionToIntersection } from './types/handler'; +import type { Module } from './handler/structures/module'; + export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; export * from './handler/plugins/plugin'; +let p: UnionToIntersection; diff --git a/src/types/handler.ts b/src/types/handler.ts index fb42a53f..e14f8f06 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -23,10 +23,15 @@ export type SlashOptions = Omit = Omit & T2; export type DefinitelyDefined = T & Override; -export type Expand = T extends object ? { [K in keyof T]: Expand } : T; type Reconstruct = T extends Omit ? O & Reconstruct : T; type IsOptional = { [K in keyof T]-?: T[K] extends Required[K] ? false : true; }; + +export type UnionToIntersection = (T extends unknown ? (x: T) => unknown : never) extends ( + x: infer R, +) => unknown + ? R + : never; From 99e2a997edaac1ba880e56bf782ecd1fa5e96b4c Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 29 May 2022 14:30:28 -0500 Subject: [PATCH 090/128] feat: adding better typings, refactoring --- src/handler/events/observableHandling.ts | 28 +------ src/handler/plugins/plugin.ts | 95 ++++++++++++++---------- src/handler/structures/module.ts | 46 +++++------- 3 files changed, 75 insertions(+), 94 deletions(-) diff --git a/src/handler/events/observableHandling.ts b/src/handler/events/observableHandling.ts index a5ce95c0..ca744540 100644 --- a/src/handler/events/observableHandling.ts +++ b/src/handler/events/observableHandling.ts @@ -1,14 +1,8 @@ -import type { Awaitable, Message } from 'discord.js'; +import type { Message } from 'discord.js'; import { Observable, throwError } from 'rxjs'; import { SernError } from '../structures/errors'; -import type { InteractionDefs, Module, ModuleDefs } from '../structures/module'; +import type { Module, ModuleDefs } from '../structures/module'; import { correctModuleType } from '../utilities/predicates'; -import type { CommandType } from '../structures/enums'; -import type { UnionToIntersection } from '../../types/handler'; -import { controller } from '../sern'; -import type { Result } from 'ts-results'; -import type { SelectMenuInteraction } from 'discord.js'; - export function filterCorrectModule(cmdType: T) { return (src: Observable) => new Observable(subscriber => { @@ -48,21 +42,3 @@ export function ignoreNonBot(prefix: string) { }); }); } - -// export function processOnEvents(ty: T, interaction: InteractionDefs[T]) { -// return (src: Observable) => -// new Observable>>(subscriber => { -// return src.subscribe({ -// next(m) { -// subscriber.next(m.onEvent?.map(e => { -// return (>e).execute( -// [interaction as SelectMenuInteraction], //This is just to satisfy compiler -// controller, -// ); -// })) ; -// }, -// error: e => subscriber.error(e), -// complete: () => subscriber.complete(), -// }); -// }); -// } diff --git a/src/handler/plugins/plugin.ts b/src/handler/plugins/plugin.ts index ca8227de..27a815ca 100644 --- a/src/handler/plugins/plugin.ts +++ b/src/handler/plugins/plugin.ts @@ -15,9 +15,8 @@ import type { Awaitable, Client } from 'discord.js'; import type { Err, Ok, Result } from 'ts-results'; import type { Module, Override } from '../..'; import { CommandType } from '../..'; -import type { BaseModule, ModuleDefs } from '../structures/module'; -import type { PluginType } from '../structures/enums'; -import type { ValueOf } from 'ts-pattern/dist/types/helpers'; +import type { AutocompleteCommand, BaseModule, ModuleDefs } from '../structures/module'; +import { PluginType } from '../structures/enums'; export interface Controller { next: () => Ok; @@ -31,31 +30,19 @@ type BasePlugin = Override< } >; -export type CommandPlugin = Override< - BasePlugin, - { - type: PluginType.Command; - execute: ( - wrapper: Client, - module: Module, - controller: Controller, - ) => Awaitable>; - } ->; - -//TODO: rn adding the modType check a little hackish. Find better way to determine the -// module type of the event plugin -// export type EventPlugin = Override< -// BasePlugin, -// { -// type: PluginType.Event; -// execute: ( -// event: Parameters, -// controller: Controller, -// ) => Awaitable>; -// } -// >; - +export type CommandPlugin = { + [K in T]: Override< + BasePlugin, + { + type: PluginType.Command; + execute: ( + wrapper: Client, + module: ModuleDefs[T], + controller: Controller, + ) => Awaitable>; + } + >; +}[T]; export type EventPlugin = { [K in T]: Override< BasePlugin, @@ -69,23 +56,53 @@ export type EventPlugin = { >; }[T]; -export function plugins(...plug: CommandPlugin[]): CommandPlugin[]; -export function plugins(...plug: EventPlugin[]): EventPlugin[]; -export function plugins(...plug: EventPlugin[] | CommandPlugin[]) { - return plug; -} +//Syntactic sugar on hold +// export function plugins( +// ...plug: (EventPlugin | CommandPlugin)[] +// ) { +// return plug; +// } -type ModuleNoPlugins = ValueOf<{ - [T in keyof ModuleDefs]: Omit; -}>; +type ModuleNoPlugins = { + [T in keyof ModuleDefs]: Omit; +}; +function isEventPlugin( + e: CommandPlugin | EventPlugin, +): e is EventPlugin { + return e.type === PluginType.Event; +} +function isCommandPlugin( + e: CommandPlugin | EventPlugin, +): e is CommandPlugin { + return !isEventPlugin(e); +} //TODO: I WANT BETTER TYPINGS AHHHHHHHHHHHHHHH -export function sernModule(plugins: CommandPlugin[], mod: ModuleNoPlugins): Module { +export function sernModule( + plugin: (CommandPlugin | EventPlugin)[], + mod: ModuleNoPlugins[T], +): Module { + const onEvent = plugin.filter(isEventPlugin); + const plugins = plugin.filter(isCommandPlugin); if (mod.type === CommandType.Autocomplete) { - return mod; + throw new Error( + 'You cannot use this function declaration for Autocomplete Interactions! use the raw object for options or' + + 'sernAutoComplete function', + ); } else return { + onEvent, plugins, ...mod, - }; + } as Module; +} + +export function sernAutocomplete( + onEvent: EventPlugin[], + mod: Omit, +): Omit { + return { + onEvent, + ...mod, + }; } diff --git a/src/handler/structures/module.ts b/src/handler/structures/module.ts index 42b51d51..555e21af 100644 --- a/src/handler/structures/module.ts +++ b/src/handler/structures/module.ts @@ -21,7 +21,6 @@ import type Context from './context'; import { CommandType, PluginType } from './enums'; import type { AutocompleteInteraction } from 'discord.js'; import type { ApplicationCommandOptionType } from 'discord.js'; -import { ChatInputCommandInteraction, Message, User } from 'discord.js'; export interface BaseModule { type: CommandType | PluginType; @@ -35,8 +34,8 @@ export type TextCommand = Override< BaseModule, { type: CommandType.Text; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; alias?: string[]; } >; @@ -45,8 +44,8 @@ export type SlashCommand = Override< BaseModule, { type: CommandType.Slash; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; options?: SernOptionsData[]; } >; @@ -55,8 +54,8 @@ export type BothCommand = Override< BaseModule, { type: CommandType.Both; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; alias?: string[]; options?: SernOptionsData[]; } @@ -66,8 +65,8 @@ export type ContextMenuUser = Override< BaseModule, { type: CommandType.MenuUser; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; execute: (ctx: UserContextMenuCommandInteraction) => Awaitable; } >; @@ -76,8 +75,8 @@ export type ContextMenuMsg = Override< BaseModule, { type: CommandType.MenuMsg; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; execute: (ctx: MessageContextMenuCommandInteraction) => Awaitable; } >; @@ -86,8 +85,8 @@ export type ButtonCommand = Override< BaseModule, { type: CommandType.Button; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; execute: (ctx: ButtonInteraction) => Awaitable; } >; @@ -96,8 +95,8 @@ export type SelectMenuCommand = Override< BaseModule, { type: CommandType.MenuSelect; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; execute: (ctx: SelectMenuInteraction) => Awaitable; } >; @@ -106,8 +105,8 @@ export type ModalSubmitCommand = Override< BaseModule, { type: CommandType.Modal; - onEvent?: EventPlugin[]; - plugins?: CommandPlugin[]; + onEvent: EventPlugin[]; + plugins: CommandPlugin[]; execute: (ctx: ModalSubmitInteraction) => Awaitable; } >; @@ -121,7 +120,7 @@ export type AutocompleteCommand = Override< { type: CommandType.Autocomplete; name: string; - onEvent?: EventPlugin[]; + onEvent: EventPlugin[]; execute: (ctx: AutocompleteInteraction) => Awaitable; } >; @@ -150,17 +149,6 @@ export type ModuleDefs = { [CommandType.Modal]: ModalSubmitCommand; [CommandType.Autocomplete]: AutocompleteCommand; }; -export type InteractionDefs = { - [CommandType.Text]: Context; - [CommandType.Slash]: Context; - [CommandType.Both]: Context; - [CommandType.MenuMsg]: MessageContextMenuCommandInteraction; - [CommandType.MenuUser]: UserContextMenuCommandInteraction; - [CommandType.Button]: ButtonInteraction; - [CommandType.MenuSelect]: SelectMenuInteraction; - [CommandType.Modal]: ModalSubmitInteraction; - [CommandType.Autocomplete]: AutocompleteInteraction; -}; //TODO: support deeply nested Autocomplete // objective: construct union of ApplicationCommandOptionData change any Autocomplete data From ae59acadcc1a0989d6ddfab27157f5620d9b06ca Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 29 May 2022 14:38:05 -0500 Subject: [PATCH 091/128] refactor: remove unnecessary nullish short circuit --- src/handler/events/interactionCreate.ts | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index c8bfb467..2c8e5c1b 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -35,9 +35,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command return mod$(CommandType.Slash).pipe( concatMap(m => { return of( - m.onEvent?.map(e => - e.execute([ctx, ['slash', i.options]], controller), - ) ?? [], + m.onEvent.map(e => e.execute([ctx, ['slash', i.options]], controller)), ).pipe( map(res => ({ mod, @@ -55,7 +53,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command .when(isMessageCtxMenuCmd, ctx => { return mod$(CommandType.MenuMsg).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + return of(m.onEvent.map(e => e.execute([ctx], controller))).pipe( map(res => ({ mod, res, @@ -70,7 +68,7 @@ function applicationCommandHandler(mod: Module | undefined, interaction: Command .when(isUserContextMenuCmd, ctx => { return mod$(CommandType.MenuUser).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + return of(m.onEvent.map(e => e.execute([ctx], controller))).pipe( map(res => ({ mod, res, @@ -97,7 +95,7 @@ function messageComponentInteractionHandler( .when(isButton, ctx => { return mod$(CommandType.Button).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + return of(m.onEvent.map(e => e.execute([ctx], controller))).pipe( map(res => ({ mod, res, @@ -112,7 +110,7 @@ function messageComponentInteractionHandler( .when(isSelectMenu, (ctx: SelectMenuInteraction) => { return mod$(CommandType.MenuSelect).pipe( concatMap(m => { - return of(m.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + return of(m.onEvent.map(e => e.execute([ctx], controller))).pipe( map(res => ({ mod, res, @@ -131,7 +129,7 @@ function modalHandler(modul: Module | undefined, ctx: ModalSubmitInteraction) { return of(modul).pipe( filterCorrectModule(CommandType.Modal), concatMap(mod => { - return of(mod.onEvent?.map(e => e.execute([ctx], controller)) ?? []).pipe( + return of(mod.onEvent.map(e => e.execute([ctx], controller))).pipe( map(res => ({ mod, res, @@ -152,9 +150,7 @@ function autoCmpHandler(mod: Module | undefined, interaction: AutocompleteIntera const selectedOption = mod.options?.find(o => o.autocomplete && o.name === choice.name); if (selectedOption !== undefined && selectedOption.autocomplete) { return of( - selectedOption.command.onEvent?.map(e => - e.execute([interaction], controller), - ) ?? [], + selectedOption.command.onEvent.map(e => e.execute([interaction], controller)), ).pipe( map(res => ({ mod, From cfd68b438898304fe0ef84c573094a7be594b5c9 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 29 May 2022 14:39:37 -0500 Subject: [PATCH 092/128] refactor: remove unnecessary nullish short circuit --- src/handler/events/messageEvent.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/handler/events/messageEvent.ts b/src/handler/events/messageEvent.ts index 3b7892bb..9b5d7ccd 100644 --- a/src/handler/events/messageEvent.ts +++ b/src/handler/events/messageEvent.ts @@ -42,9 +42,9 @@ export const onMessageCreate = (wrapper: Wrapper) => { const processEventPlugins$ = ensureModuleType$.pipe( concatMap(({ ctx, args, mod }) => { const res = Promise.all( - mod.onEvent?.map(ePlug => { + mod.onEvent.map(ePlug => { return ePlug.execute([ctx, args], controller); - }) ?? [], + }), ); return from(res).pipe(map(res => ({ mod, ctx, args, res }))); }), From f90342d6b140241f7a6a95dea71c05bf309a7a52 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sun, 29 May 2022 15:01:35 -0500 Subject: [PATCH 093/128] feat: add docs/ to npmignore --- .npmignore | 3 ++- src/index.ts | 4 ---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/.npmignore b/.npmignore index 5c5532a6..506ff152 100644 --- a/.npmignore +++ b/.npmignore @@ -1,2 +1,3 @@ src/ -tsconfig.json \ No newline at end of file +tsconfig.json +docs/ \ No newline at end of file diff --git a/src/index.ts b/src/index.ts index 76c383b6..4fd70b99 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,8 +1,4 @@ -import type { UnionToIntersection } from './types/handler'; -import type { Module } from './handler/structures/module'; - export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; export * from './handler/plugins/plugin'; -let p: UnionToIntersection; From df9e20701c95484aaffef0723a3799d81d92addb Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 7 Apr 2022 22:37:40 +0300 Subject: [PATCH 094/128] style: Formatted 17 files & changes messageHelper util --- package-lock.json | 69 +++++++++++++++++++++++++++++++++++++---------- package.json | 2 +- 2 files changed, 56 insertions(+), 15 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4d7419a2..21dfebaa 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "jest": "^27.5.1", "prettier": "2.6.2", "standard-version": "^9.3.2", - "typedoc": "^0.22.11", + "typedoc": "^0.22.14", "typescript": "^4.5.5" } }, @@ -8564,16 +8564,16 @@ } }, "node_modules/typedoc": { - "version": "0.22.11", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", - "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", + "version": "0.22.14", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", + "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", "dev": true, "dependencies": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.10", - "minimatch": "^3.0.4", - "shiki": "^0.10.0" + "marked": "^4.0.12", + "minimatch": "^5.0.1", + "shiki": "^0.10.1" }, "bin": { "typedoc": "bin/typedoc" @@ -8582,7 +8582,28 @@ "node": ">= 12.10.0" }, "peerDependencies": { - "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x" + "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x" + } + }, + "node_modules/typedoc/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/typedoc/node_modules/minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" } }, "node_modules/typescript": { @@ -15429,16 +15450,36 @@ } }, "typedoc": { - "version": "0.22.11", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", - "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", + "version": "0.22.14", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", + "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", "dev": true, "requires": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.10", - "minimatch": "^3.0.4", - "shiki": "^0.10.0" + "marked": "^4.0.12", + "minimatch": "^5.0.1", + "shiki": "^0.10.1" + }, + "dependencies": { + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "requires": { + "balanced-match": "^1.0.0" + } + }, + "minimatch": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", + "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", + "dev": true, + "requires": { + "brace-expansion": "^2.0.1" + } + } } }, "typescript": { diff --git a/package.json b/package.json index 20e29431..c7d194e7 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "jest": "^27.5.1", "prettier": "2.6.2", "standard-version": "^9.3.2", - "typedoc": "^0.22.11", + "typedoc": "^0.22.14", "typescript": "^4.5.5" }, "config": { From 07c34634aab2d1c0ab17293337e6f6f5f76940e1 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 12 Apr 2022 23:10:18 +0300 Subject: [PATCH 095/128] style: Formatted HTML and CSS files --- docs/assets/highlight.css | 133 ++-- docs/assets/icons.css | 1010 ++++++++++++---------------- docs/classes/Sern.Handler.html | 1021 ++++++++++++++++++++++++++++- docs/enums/Sern.CommandType.html | 205 +++++- docs/index.html | 200 ++++-- docs/interfaces/Sern.Module.html | 567 +++++++++++++++- docs/interfaces/Sern.Wrapper.html | 417 +++++++++++- docs/modules.html | 116 +++- docs/modules/Sern.html | 156 ++++- docs/modules/Types.html | 534 ++++++++++++++- docs/modules/Utils.html | 684 ++++++++++++++++++- 11 files changed, 4298 insertions(+), 745 deletions(-) diff --git a/docs/assets/highlight.css b/docs/assets/highlight.css index 26d41f4c..875f2107 100644 --- a/docs/assets/highlight.css +++ b/docs/assets/highlight.css @@ -1,27 +1,28 @@ :root { - --light-hl-0: #000000; - --dark-hl-0: #D4D4D4; - --light-hl-1: #AF00DB; - --dark-hl-1: #C586C0; - --light-hl-2: #001080; - --dark-hl-2: #9CDCFE; - --light-hl-3: #A31515; - --dark-hl-3: #CE9178; - --light-hl-4: #0000FF; - --dark-hl-4: #569CD6; - --light-hl-5: #0070C1; - --dark-hl-5: #4FC1FF; - --light-hl-6: #795E26; - --dark-hl-6: #DCDCAA; - --light-hl-7: #008000; - --dark-hl-7: #6A9955; - --light-hl-8: #CD3131; - --dark-hl-8: #F44747; - --light-code-background: #F5F5F5; - --dark-code-background: #1E1E1E; + --light-hl-0: #000000; + --dark-hl-0: #d4d4d4; + --light-hl-1: #af00db; + --dark-hl-1: #c586c0; + --light-hl-2: #001080; + --dark-hl-2: #9cdcfe; + --light-hl-3: #a31515; + --dark-hl-3: #ce9178; + --light-hl-4: #0000ff; + --dark-hl-4: #569cd6; + --light-hl-5: #0070c1; + --dark-hl-5: #4fc1ff; + --light-hl-6: #795e26; + --dark-hl-6: #dcdcaa; + --light-hl-7: #008000; + --dark-hl-7: #6a9955; + --light-hl-8: #cd3131; + --dark-hl-8: #f44747; + --light-code-background: #f5f5f5; + --dark-code-background: #1e1e1e; } -@media (prefers-color-scheme: light) { :root { +@media (prefers-color-scheme: light) { + :root { --hl-0: var(--light-hl-0); --hl-1: var(--light-hl-1); --hl-2: var(--light-hl-2); @@ -32,9 +33,11 @@ --hl-7: var(--light-hl-7); --hl-8: var(--light-hl-8); --code-background: var(--light-code-background); -} } + } +} -@media (prefers-color-scheme: dark) { :root { +@media (prefers-color-scheme: dark) { + :root { --hl-0: var(--dark-hl-0); --hl-1: var(--dark-hl-1); --hl-2: var(--dark-hl-2); @@ -45,41 +48,63 @@ --hl-7: var(--dark-hl-7); --hl-8: var(--dark-hl-8); --code-background: var(--dark-code-background); -} } + } +} body.light { - --hl-0: var(--light-hl-0); - --hl-1: var(--light-hl-1); - --hl-2: var(--light-hl-2); - --hl-3: var(--light-hl-3); - --hl-4: var(--light-hl-4); - --hl-5: var(--light-hl-5); - --hl-6: var(--light-hl-6); - --hl-7: var(--light-hl-7); - --hl-8: var(--light-hl-8); - --code-background: var(--light-code-background); + --hl-0: var(--light-hl-0); + --hl-1: var(--light-hl-1); + --hl-2: var(--light-hl-2); + --hl-3: var(--light-hl-3); + --hl-4: var(--light-hl-4); + --hl-5: var(--light-hl-5); + --hl-6: var(--light-hl-6); + --hl-7: var(--light-hl-7); + --hl-8: var(--light-hl-8); + --code-background: var(--light-code-background); } body.dark { - --hl-0: var(--dark-hl-0); - --hl-1: var(--dark-hl-1); - --hl-2: var(--dark-hl-2); - --hl-3: var(--dark-hl-3); - --hl-4: var(--dark-hl-4); - --hl-5: var(--dark-hl-5); - --hl-6: var(--dark-hl-6); - --hl-7: var(--dark-hl-7); - --hl-8: var(--dark-hl-8); - --code-background: var(--dark-code-background); + --hl-0: var(--dark-hl-0); + --hl-1: var(--dark-hl-1); + --hl-2: var(--dark-hl-2); + --hl-3: var(--dark-hl-3); + --hl-4: var(--dark-hl-4); + --hl-5: var(--dark-hl-5); + --hl-6: var(--dark-hl-6); + --hl-7: var(--dark-hl-7); + --hl-8: var(--dark-hl-8); + --code-background: var(--dark-code-background); } -.hl-0 { color: var(--hl-0); } -.hl-1 { color: var(--hl-1); } -.hl-2 { color: var(--hl-2); } -.hl-3 { color: var(--hl-3); } -.hl-4 { color: var(--hl-4); } -.hl-5 { color: var(--hl-5); } -.hl-6 { color: var(--hl-6); } -.hl-7 { color: var(--hl-7); } -.hl-8 { color: var(--hl-8); } -pre, code { background: var(--code-background); } +.hl-0 { + color: var(--hl-0); +} +.hl-1 { + color: var(--hl-1); +} +.hl-2 { + color: var(--hl-2); +} +.hl-3 { + color: var(--hl-3); +} +.hl-4 { + color: var(--hl-4); +} +.hl-5 { + color: var(--hl-5); +} +.hl-6 { + color: var(--hl-6); +} +.hl-7 { + color: var(--hl-7); +} +.hl-8 { + color: var(--hl-8); +} +pre, +code { + background: var(--code-background); +} diff --git a/docs/assets/icons.css b/docs/assets/icons.css index 776a3562..43784345 100644 --- a/docs/assets/icons.css +++ b/docs/assets/icons.css @@ -1,1043 +1,907 @@ .tsd-kind-icon { - display: block; - position: relative; - padding-left: 20px; - text-indent: -20px; + display: block; + position: relative; + padding-left: 20px; + text-indent: -20px; } .tsd-kind-icon:before { - content: ""; - display: inline-block; - vertical-align: middle; - width: 17px; - height: 17px; - margin: 0 3px 2px 0; - background-image: url(./icons.png); + content: ''; + display: inline-block; + vertical-align: middle; + width: 17px; + height: 17px; + margin: 0 3px 2px 0; + background-image: url(./icons.png); } @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { - .tsd-kind-icon:before { - background-image: url(./icons@2x.png); - background-size: 238px 204px; - } + .tsd-kind-icon:before { + background-image: url(./icons@2x.png); + background-size: 238px 204px; + } } .tsd-signature.tsd-kind-icon:before { - background-position: 0 -153px; + background-position: 0 -153px; } .tsd-kind-object-literal > .tsd-kind-icon:before { - background-position: 0px -17px; + background-position: 0px -17px; } .tsd-kind-object-literal.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -17px; + background-position: -17px -17px; } .tsd-kind-object-literal.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -17px; + background-position: -34px -17px; } .tsd-kind-class > .tsd-kind-icon:before { - background-position: 0px -34px; + background-position: 0px -34px; } .tsd-kind-class.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -34px; + background-position: -17px -34px; } .tsd-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -34px; + background-position: -34px -34px; } .tsd-kind-class.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: 0px -51px; + background-position: 0px -51px; } -.tsd-kind-class.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -17px -51px; +.tsd-kind-class.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -17px -51px; } .tsd-kind-class.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -51px; + background-position: -34px -51px; } .tsd-kind-interface > .tsd-kind-icon:before { - background-position: 0px -68px; + background-position: 0px -68px; } .tsd-kind-interface.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -68px; + background-position: -17px -68px; } .tsd-kind-interface.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -68px; + background-position: -34px -68px; } .tsd-kind-interface.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: 0px -85px; + background-position: 0px -85px; } -.tsd-kind-interface.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -17px -85px; +.tsd-kind-interface.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -17px -85px; } -.tsd-kind-interface.tsd-has-type-parameter.tsd-is-private - > .tsd-kind-icon:before { - background-position: -34px -85px; +.tsd-kind-interface.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { + background-position: -34px -85px; } .tsd-kind-namespace > .tsd-kind-icon:before { - background-position: 0px -102px; + background-position: 0px -102px; } .tsd-kind-namespace.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -102px; + background-position: -17px -102px; } .tsd-kind-namespace.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -102px; + background-position: -34px -102px; } .tsd-kind-module > .tsd-kind-icon:before { - background-position: 0px -102px; + background-position: 0px -102px; } .tsd-kind-module.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -102px; + background-position: -17px -102px; } .tsd-kind-module.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -102px; + background-position: -34px -102px; } .tsd-kind-enum > .tsd-kind-icon:before { - background-position: 0px -119px; + background-position: 0px -119px; } .tsd-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -119px; + background-position: -17px -119px; } .tsd-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -119px; + background-position: -34px -119px; } .tsd-kind-enum-member > .tsd-kind-icon:before { - background-position: 0px -136px; + background-position: 0px -136px; } .tsd-kind-enum-member.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -136px; + background-position: -17px -136px; } .tsd-kind-enum-member.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -136px; + background-position: -34px -136px; } .tsd-kind-signature > .tsd-kind-icon:before { - background-position: 0px -153px; + background-position: 0px -153px; } .tsd-kind-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -153px; + background-position: -17px -153px; } .tsd-kind-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -153px; + background-position: -34px -153px; } .tsd-kind-type-alias > .tsd-kind-icon:before { - background-position: 0px -170px; + background-position: 0px -170px; } .tsd-kind-type-alias.tsd-is-protected > .tsd-kind-icon:before { - background-position: -17px -170px; + background-position: -17px -170px; } .tsd-kind-type-alias.tsd-is-private > .tsd-kind-icon:before { - background-position: -34px -170px; + background-position: -34px -170px; } .tsd-kind-type-alias.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: 0px -187px; + background-position: 0px -187px; } -.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -17px -187px; +.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -17px -187px; } -.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-private - > .tsd-kind-icon:before { - background-position: -34px -187px; +.tsd-kind-type-alias.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { + background-position: -34px -187px; } .tsd-kind-variable > .tsd-kind-icon:before { - background-position: -136px -0px; + background-position: -136px -0px; } .tsd-kind-variable.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -0px; + background-position: -153px -0px; } .tsd-kind-variable.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-variable.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -0px; + background-position: -51px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -0px; } -.tsd-kind-variable.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -0px; +.tsd-kind-variable.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -0px; } .tsd-kind-variable.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -0px; + background-position: -170px -0px; } -.tsd-kind-variable.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -0px; +.tsd-kind-variable.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -0px; } .tsd-kind-variable.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-variable.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -0px; + background-position: -204px -0px; } -.tsd-kind-variable.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -0px; +.tsd-kind-variable.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -0px; } .tsd-kind-property > .tsd-kind-icon:before { - background-position: -136px -0px; + background-position: -136px -0px; } .tsd-kind-property.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -0px; + background-position: -153px -0px; } .tsd-kind-property.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-property.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -0px; + background-position: -51px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -0px; } -.tsd-kind-property.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -0px; +.tsd-kind-property.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -0px; } .tsd-kind-property.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -0px; + background-position: -170px -0px; } -.tsd-kind-property.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -0px; +.tsd-kind-property.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -0px; } .tsd-kind-property.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -0px; + background-position: -119px -0px; } .tsd-kind-property.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -0px; + background-position: -204px -0px; } -.tsd-kind-property.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -0px; +.tsd-kind-property.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -0px; } .tsd-kind-get-signature > .tsd-kind-icon:before { - background-position: -136px -17px; + background-position: -136px -17px; } .tsd-kind-get-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -17px; + background-position: -153px -17px; } .tsd-kind-get-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -17px; + background-position: -119px -17px; } .tsd-kind-get-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -17px; + background-position: -51px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -17px; +.tsd-kind-get-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -17px; } .tsd-kind-get-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -17px; + background-position: -170px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -17px; +.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -17px; +.tsd-kind-get-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -17px; } .tsd-kind-get-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -17px; + background-position: -204px -17px; } -.tsd-kind-get-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -17px; +.tsd-kind-get-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -17px; } .tsd-kind-set-signature > .tsd-kind-icon:before { - background-position: -136px -34px; + background-position: -136px -34px; } .tsd-kind-set-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -34px; + background-position: -153px -34px; } .tsd-kind-set-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -34px; + background-position: -119px -34px; } .tsd-kind-set-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -34px; + background-position: -51px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -34px; +.tsd-kind-set-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -34px; } .tsd-kind-set-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -34px; + background-position: -170px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -34px; +.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -34px; +.tsd-kind-set-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -34px; } .tsd-kind-set-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -34px; + background-position: -204px -34px; } -.tsd-kind-set-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -34px; +.tsd-kind-set-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -34px; } .tsd-kind-accessor > .tsd-kind-icon:before { - background-position: -136px -51px; + background-position: -136px -51px; } .tsd-kind-accessor.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -51px; + background-position: -153px -51px; } .tsd-kind-accessor.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -51px; + background-position: -119px -51px; } .tsd-kind-accessor.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -51px; + background-position: -51px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -51px; } -.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -51px; +.tsd-kind-accessor.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -51px; } .tsd-kind-accessor.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -51px; + background-position: -170px -51px; } -.tsd-kind-accessor.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -51px; +.tsd-kind-accessor.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -51px; } .tsd-kind-accessor.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -51px; + background-position: -119px -51px; } .tsd-kind-accessor.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -51px; + background-position: -204px -51px; } -.tsd-kind-accessor.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -51px; +.tsd-kind-accessor.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -51px; } .tsd-kind-function > .tsd-kind-icon:before { - background-position: -136px -68px; + background-position: -136px -68px; } .tsd-kind-function.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -68px; + background-position: -153px -68px; } .tsd-kind-function.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-function.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -68px; + background-position: -51px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -68px; } -.tsd-kind-function.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -68px; +.tsd-kind-function.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -68px; } .tsd-kind-function.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -68px; + background-position: -170px -68px; } -.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -68px; +.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -68px; } .tsd-kind-function.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-function.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -68px; + background-position: -204px -68px; } -.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -68px; +.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -68px; } .tsd-kind-method > .tsd-kind-icon:before { - background-position: -136px -68px; + background-position: -136px -68px; } .tsd-kind-method.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -68px; + background-position: -153px -68px; } .tsd-kind-method.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-method.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -68px; + background-position: -51px -68px; } -.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -68px; +.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -68px; } -.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -68px; +.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -68px; } -.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -68px; +.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -68px; } .tsd-kind-method.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-method.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -68px; + background-position: -170px -68px; } .tsd-kind-method.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -187px -68px; + background-position: -187px -68px; } .tsd-kind-method.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-method.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -68px; + background-position: -204px -68px; } -.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -68px; +.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -68px; } .tsd-kind-call-signature > .tsd-kind-icon:before { - background-position: -136px -68px; + background-position: -136px -68px; } .tsd-kind-call-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -68px; + background-position: -153px -68px; } .tsd-kind-call-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -68px; + background-position: -119px -68px; } .tsd-kind-call-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -68px; + background-position: -51px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -68px; +.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -68px; } .tsd-kind-call-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -68px; + background-position: -170px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -68px; +.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -68px; +.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -68px; } .tsd-kind-call-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -68px; + background-position: -204px -68px; } -.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -68px; +.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -68px; } .tsd-kind-function.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: -136px -85px; + background-position: -136px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -153px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -153px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class - > .tsd-kind-icon:before { - background-position: -51px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class > .tsd-kind-icon:before { + background-position: -51px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -85px; } .tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -85px; + > .tsd-kind-icon:before { + background-position: -102px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum - > .tsd-kind-icon:before { - background-position: -170px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum > .tsd-kind-icon:before { + background-position: -170px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -85px; } -.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -85px; +.tsd-kind-function.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -85px; } .tsd-kind-method.tsd-has-type-parameter > .tsd-kind-icon:before { - background-position: -136px -85px; + background-position: -136px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -153px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-is-protected > .tsd-kind-icon:before { + background-position: -153px -85px; } .tsd-kind-method.tsd-has-type-parameter.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -85px; + background-position: -119px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class - > .tsd-kind-icon:before { - background-position: -51px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class > .tsd-kind-icon:before { + background-position: -51px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -85px; } .tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -85px; + > .tsd-kind-icon:before { + background-position: -102px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum - > .tsd-kind-icon:before { - background-position: -170px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum > .tsd-kind-icon:before { + background-position: -170px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -85px; } -.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -85px; +.tsd-kind-method.tsd-has-type-parameter.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -85px; } .tsd-kind-constructor > .tsd-kind-icon:before { - background-position: -136px -102px; + background-position: -136px -102px; } .tsd-kind-constructor.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -102px; + background-position: -153px -102px; } .tsd-kind-constructor.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -102px; + background-position: -119px -102px; } .tsd-kind-constructor.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -102px; + background-position: -51px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -102px; } -.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } .tsd-kind-constructor.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -102px; + background-position: -170px -102px; } -.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -102px; +.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -102px; } -.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } .tsd-kind-constructor.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -102px; + background-position: -204px -102px; } -.tsd-kind-constructor.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -102px; +.tsd-kind-constructor.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -102px; } .tsd-kind-constructor-signature > .tsd-kind-icon:before { - background-position: -136px -102px; + background-position: -136px -102px; } .tsd-kind-constructor-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -102px; + background-position: -153px -102px; } .tsd-kind-constructor-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -102px; + background-position: -119px -102px; } .tsd-kind-constructor-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -102px; + background-position: -51px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } .tsd-kind-constructor-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -102px; + background-position: -170px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -102px; } -.tsd-kind-constructor-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -102px; +.tsd-kind-constructor-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -102px; } .tsd-kind-index-signature > .tsd-kind-icon:before { - background-position: -136px -119px; + background-position: -136px -119px; } .tsd-kind-index-signature.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -119px; + background-position: -153px -119px; } .tsd-kind-index-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -119px; + background-position: -119px -119px; } .tsd-kind-index-signature.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -119px; + background-position: -51px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -119px; +.tsd-kind-index-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -119px; } .tsd-kind-index-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -119px; + background-position: -170px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -119px; +.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -119px; +.tsd-kind-index-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -119px; } .tsd-kind-index-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -119px; + background-position: -204px -119px; } -.tsd-kind-index-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -119px; +.tsd-kind-index-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -119px; } .tsd-kind-event > .tsd-kind-icon:before { - background-position: -136px -136px; + background-position: -136px -136px; } .tsd-kind-event.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -136px; + background-position: -153px -136px; } .tsd-kind-event.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -136px; + background-position: -119px -136px; } .tsd-kind-event.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -136px; + background-position: -51px -136px; } .tsd-kind-event.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { - background-position: -68px -136px; + background-position: -68px -136px; } .tsd-kind-event.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { - background-position: -85px -136px; + background-position: -85px -136px; } -.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -136px; +.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -136px; } .tsd-kind-event.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -136px; + background-position: -119px -136px; } .tsd-kind-event.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -136px; + background-position: -170px -136px; } .tsd-kind-event.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -187px -136px; + background-position: -187px -136px; } .tsd-kind-event.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -136px; + background-position: -119px -136px; } .tsd-kind-event.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -136px; + background-position: -204px -136px; } -.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -136px; +.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -136px; } .tsd-is-static > .tsd-kind-icon:before { - background-position: -136px -153px; + background-position: -136px -153px; } .tsd-is-static.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -153px; + background-position: -153px -153px; } .tsd-is-static.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -153px; + background-position: -119px -153px; } .tsd-is-static.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -153px; + background-position: -51px -153px; } .tsd-is-static.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { - background-position: -68px -153px; + background-position: -68px -153px; } .tsd-is-static.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { - background-position: -85px -153px; + background-position: -85px -153px; } -.tsd-is-static.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -153px; +.tsd-is-static.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -153px; } .tsd-is-static.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -153px; + background-position: -119px -153px; } .tsd-is-static.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -153px; + background-position: -170px -153px; } .tsd-is-static.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { - background-position: -187px -153px; + background-position: -187px -153px; } .tsd-is-static.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -153px; + background-position: -119px -153px; } .tsd-is-static.tsd-parent-kind-interface > .tsd-kind-icon:before { - background-position: -204px -153px; + background-position: -204px -153px; } -.tsd-is-static.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -153px; +.tsd-is-static.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -153px; } .tsd-is-static.tsd-kind-function > .tsd-kind-icon:before { - background-position: -136px -170px; + background-position: -136px -170px; } .tsd-is-static.tsd-kind-function.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -170px; + background-position: -153px -170px; } .tsd-is-static.tsd-kind-function.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -170px; + background-position: -119px -170px; } .tsd-is-static.tsd-kind-function.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -170px; + background-position: -51px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } .tsd-is-static.tsd-kind-function.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -170px; + background-position: -170px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -170px; } -.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -170px; +.tsd-is-static.tsd-kind-function.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -170px; } .tsd-is-static.tsd-kind-method > .tsd-kind-icon:before { - background-position: -136px -170px; + background-position: -136px -170px; } .tsd-is-static.tsd-kind-method.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -170px; + background-position: -153px -170px; } .tsd-is-static.tsd-kind-method.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -170px; + background-position: -119px -170px; } .tsd-is-static.tsd-kind-method.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -170px; + background-position: -51px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } .tsd-is-static.tsd-kind-method.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -170px; + background-position: -170px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -170px; } -.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -170px; +.tsd-is-static.tsd-kind-method.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -170px; } .tsd-is-static.tsd-kind-call-signature > .tsd-kind-icon:before { - background-position: -136px -170px; + background-position: -136px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -153px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-is-protected > .tsd-kind-icon:before { + background-position: -153px -170px; } .tsd-is-static.tsd-kind-call-signature.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -170px; + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class - > .tsd-kind-icon:before { - background-position: -51px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class > .tsd-kind-icon:before { + background-position: -51px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum - > .tsd-kind-icon:before { - background-position: -170px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum > .tsd-kind-icon:before { + background-position: -170px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -170px; } -.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -170px; +.tsd-is-static.tsd-kind-call-signature.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -170px; } .tsd-is-static.tsd-kind-event > .tsd-kind-icon:before { - background-position: -136px -187px; + background-position: -136px -187px; } .tsd-is-static.tsd-kind-event.tsd-is-protected > .tsd-kind-icon:before { - background-position: -153px -187px; + background-position: -153px -187px; } .tsd-is-static.tsd-kind-event.tsd-is-private > .tsd-kind-icon:before { - background-position: -119px -187px; + background-position: -119px -187px; } .tsd-is-static.tsd-kind-event.tsd-parent-kind-class > .tsd-kind-icon:before { - background-position: -51px -187px; + background-position: -51px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -68px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -68px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -85px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected > .tsd-kind-icon:before { + background-position: -85px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -102px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-protected.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -102px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-class.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -187px; } .tsd-is-static.tsd-kind-event.tsd-parent-kind-enum > .tsd-kind-icon:before { - background-position: -170px -187px; + background-position: -170px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-protected - > .tsd-kind-icon:before { - background-position: -187px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-protected > .tsd-kind-icon:before { + background-position: -187px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-private - > .tsd-kind-icon:before { - background-position: -119px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-enum.tsd-is-private > .tsd-kind-icon:before { + background-position: -119px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface - > .tsd-kind-icon:before { - background-position: -204px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface > .tsd-kind-icon:before { + background-position: -204px -187px; } -.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited - > .tsd-kind-icon:before { - background-position: -221px -187px; +.tsd-is-static.tsd-kind-event.tsd-parent-kind-interface.tsd-is-inherited > .tsd-kind-icon:before { + background-position: -221px -187px; } diff --git a/docs/classes/Sern.Handler.html b/docs/classes/Sern.Handler.html index 1f7c5633..1ce9aded 100644 --- a/docs/classes/Sern.Handler.html +++ b/docs/classes/Sern.Handler.html @@ -1,29 +1,992 @@ -Handler | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • Handler

Index

Constructors

Properties

wrapper: Wrapper

Accessors

  • get client(): Client<boolean>
  • readonly

    Returns Client<boolean>

    the discord.js client (DiscordJS#Client));

    -
  • get commandDir(): string
  • get prefix(): string
  • get privateServers(): { id: string; test: boolean }[]
  • readonly

    Returns { id: string; test: boolean }[]

    []} Private server ID for testing or personal use

    -

Methods

  • commandResult(module: CommandVal, message: Message<boolean>): Promise<undefined | possibleOutput<string>>
  • Parameters

    • module: CommandVal
      -

      Command file information

      -
    • message: Message<boolean>
      -

      The message object

      -

    Returns Promise<undefined | possibleOutput<string>>

    Takes return value and replies it, if possible input

    -
  • findModuleFrom<T>(ctx: T): undefined | CommandVal
  • Type parameters

    • T: CommandInteraction<CacheType> | Message<boolean>

    Parameters

    • ctx: T
      -

      name of possible command

      -

    Returns undefined | CommandVal

  • interactionResult(module: CommandVal, interaction: CommandInteraction<CacheType>): Promise<undefined | possibleOutput<string>>
  • Parameters

    • module: CommandVal
      -

      Command file information

      -
    • interaction: CommandInteraction<CacheType>
      -

      The Discord.js command interaction (DiscordJS#CommandInteraction))

      -

    Returns Promise<undefined | possibleOutput<string>>

    Takes return value and replies it, if possible input

    -
  • registerModules(modArr: { absPath: string; mod: Module<unknown>; name: string }[]): Promise<void>
  • -

    This function chains Files.buildData

    -

    Parameters

    • modArr: { absPath: string; mod: Module<unknown>; name: string }[]
      -

      module information

      -

    Returns Promise<void>

  • reloadSlash(cmdName: string, description: string, options: ApplicationCommandOptionData[]): Promise<void>
  • Parameters

    • cmdName: string
      -

      name of command

      -
    • description: string
      -

      description of command

      -
    • options: ApplicationCommandOptionData[]
      -

      any options for the slash command

      -

    Returns Promise<void>

Legend

  • Private property
  • Private method
  • Constructor

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Handler - SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Class Handler

+
+
+
+
+
+
+
+

Hierarchy

+
    +
  • Handler
  • +
+
+
+

Index

+
+
+
+

Constructors

+ +
+
+

Properties

+ +
+
+

Accessors

+ +
+
+

Methods

+ +
+
+
+
+
+

Constructors

+
+ + + +
    +
  • + +

    Parameters

    +
      +
    • +
      + wrapper: + Wrapper +
      +
      +
      +

      The data that is required to run sern handler

      +
      +
      +
    • +
    +

    + Returns Handler +

    +
  • +
+
+
+
+

Properties

+
+ + +
+ wrapper: + Wrapper +
+ +
+
+
+

Accessors

+
+ + +
    +
  • + get client(): Client<boolean> +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    + Returns Client<boolean> +

    +

    the discord.js client (DiscordJS#Client));

    +
  • +
+
+
+ + +
    +
  • + get commandDir(): string +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    Returns string

    +

    Directory of the commands folder

    +
  • +
+
+
+ + +
    +
  • + get prefix(): string +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    Returns string

    +

    The prefix used for legacy commands

    +
  • +
+
+
+ + +
    +
  • + get privateServers(): { id: string; test: boolean }[] +
  • +
+
    +
  • + +
    +
    +
    readonly
    +
    +
    +
    +

    + Returns { id: string; test: boolean }[] +

    +

    []} Private server ID for testing or personal use

    +
  • +
+
+
+
+

Methods

+
+ + +
    +
  • + commandResult(module: CommandVal, message: Message<boolean>): Promise<undefined | possibleOutput<string>> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      module: CommandVal
      +
      +
      +

      Command file information

      +
      +
      +
    • +
    • +
      + message: Message<boolean> +
      +
      +
      +

      The message object

      +
      +
      +
    • +
    +

    + Returns Promise<undefined | possibleOutput<string>> +

    +

    Takes return value and replies it, if possible input

    +
  • +
+
+
+ + +
    +
  • + findModuleFrom<T>(ctx: T): undefined | CommandVal +
  • +
+
    +
  • + +

    Type parameters

    +
      +
    • +

      + T: CommandInteraction<CacheType> | Message<boolean> +

      +
    • +
    +

    Parameters

    +
      +
    • +
      ctx: T
      +
      +
      +

      name of possible command

      +
      +
      +
    • +
    +

    + Returns undefined | CommandVal +

    +
    +
  • +
+
+
+ + +
    +
  • + interactionResult(module: CommandVal, interaction: CommandInteraction<CacheType>): Promise<undefined | possibleOutput<string>> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      module: CommandVal
      +
      +
      +

      Command file information

      +
      +
      +
    • +
    • +
      + interaction: CommandInteraction<CacheType> +
      +
      +
      +

      The Discord.js command interaction (DiscordJS#CommandInteraction))

      +
      +
      +
    • +
    +

    + Returns Promise<undefined | possibleOutput<string>> +

    +

    Takes return value and replies it, if possible input

    +
  • +
+
+
+ + +
    +
  • + registerModules(modArr: { absPath: string; mod: Module<unknown>; name: string }[]): Promise<void> +
  • +
+
    +
  • + +
    +
    +

    This function chains Files.buildData

    +
    +
    +

    Parameters

    +
      +
    • +
      + modArr: { absPath: string; mod: Module<unknown>; name: string }[] +
      +
      +
      +

      module information

      +
      +
      +
    • +
    +

    + Returns Promise<void> +

    +
  • +
+
+
+ + +
    +
  • + reloadSlash(cmdName: string, description: string, options: ApplicationCommandOptionData[]): Promise<void> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      cmdName: string
      +
      +
      +

      name of command

      +
      +
      +
    • +
    • +
      description: string
      +
      +
      +

      description of command

      +
      +
      +
    • +
    • +
      + options: ApplicationCommandOptionData[] +
      +
      +
      +

      any options for the slash command

      +
      +
      +
    • +
    +

    + Returns Promise<void> +

    +
  • +
+
+
+
+ +
+
+
+
+

Legend

+
+
    +
  • + Private property +
  • +
  • + Private method +
  • +
+
    +
  • Constructor
  • +
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/enums/Sern.CommandType.html b/docs/enums/Sern.CommandType.html index 47542977..4f09714a 100644 --- a/docs/enums/Sern.CommandType.html +++ b/docs/enums/Sern.CommandType.html @@ -1 +1,204 @@ -CommandType | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Enumeration CommandType

Index

Enumeration members

Enumeration members

SLASH = 2
TEXT = 1

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + CommandType - SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Enumeration CommandType

+
+
+
+
+
+
+
+

Index

+
+
+
+

Enumeration members

+ +
+
+
+
+
+

Enumeration members

+
+ + +
SLASH = 2
+ +
+
+ + +
TEXT = 1
+ +
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/index.html b/docs/index.html index 8c881568..88639543 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1,56 +1,168 @@ -sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

sern-handler

- -

Sern Handler

-
- -NPM version NPM downloads Builds Passing + + + + + + SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+

sern-handler

+
+
+
+
+
+
+ +

Sern Handler

+
+ + NPM version + NPM downloads + Builds Passing -

Sern can automate and streamline development of your discord bot with new version compatibility and full customization.

- +

+ Sern can automate and streamline development of your discord bot with new version compatibility and full + customization. +

+ - -

Installation

-
-
npm install sern-handler
+            
+              

Installation

+
+
npm install sern-handler
 
-
yarn add sern-handler
+            
yarn add sern-handler
 
-
pnpm add sern-handler
+            
pnpm add sern-handler
 
- -

Basic Usage

-
+ +

Basic Usage

+
- -

index.js

-
-
import { Client, Intents } from 'discord.js';
import { Sern } from 'sern-handler';
import { prefix, token } from '../src/secrets.json';

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS
]
});

new Sern.Handler({
client,
prefix,
commands : 'dist/commands',
privateServers : [
{
test : true,
id: 'server-id'
}
],
init: async (handler) => {
// Optional function to initialize anything else on bot startup
},
});


client.login(token); + +

index.js

+
+
import { Client, Intents } from 'discord.js';
import { Sern } from 'sern-handler';
import { prefix, token } from '../src/secrets.json';

const client = new Client({
intents: [
Intents.FLAGS.GUILDS,
Intents.FLAGS.GUILD_MESSAGES,
Intents.FLAGS.GUILD_MEMBERS
]
});

new Sern.Handler({
client,
prefix,
commands : 'dist/commands',
privateServers : [
{
test : true,
id: 'server-id'
}
],
init: async (handler) => {
// Optional function to initialize anything else on bot startup
},
});


client.login(token);
- -

ping.js

-
-
import { Sern, Types } from 'sern-handler';
import { Ok } from 'ts-results';

export default {
alias: [],
desc : 'A ping pong command',
visibility : 'private',
test : false,
type: Sern.CommandType.SLASH | Sern.CommandType.TEXT,
execute : async ({ message, interaction }, args) => {
interaction.reply({ content: 'Pong! });
}
}; + +

ping.js

+
+
import { Sern, Types } from 'sern-handler';
import { Ok } from 'ts-results';

export default {
alias: [],
desc : 'A ping pong command',
visibility : 'private',
test : false,
type: Sern.CommandType.SLASH | Sern.CommandType.TEXT,
execute : async ({ message, interaction }, args) => {
interaction.reply({ content: 'Pong! });
}
};
-

See documentation for TypeScript examples and more

+

See documentation for TypeScript examples and more

- -

Links link

-
- + +

Links link

+
+ - -

Contribute

-
-
    -
  • Pull up on issues and tell me if there are bugs
  • -
  • All kinds of contributions are welcomed!
  • -
-

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + +

Contribute

+
+
    +
  • + Pull up on issues and tell me if there are bugs +
  • +
  • All kinds of contributions are welcomed!
  • +
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/interfaces/Sern.Module.html b/docs/interfaces/Sern.Module.html index 71934dad..2f2e2b74 100644 --- a/docs/interfaces/Sern.Module.html +++ b/docs/interfaces/Sern.Module.html @@ -1,8 +1,559 @@ -Module | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Module<T>

-

An object that gets imported and acts as a command.

-
property

{string} desc

-
property

{Visibility} visibility

-
property

{CommandType} type

-
property

{(eventParams : Context, args : Ok<T=string>) => Awaitable<possibleOutput | void>)} execute

-
prop

{(ctx: Context, args: Arg) => Utils.ArgType} parse

-

Type parameters

  • T = string

Hierarchy

  • Module

Index

Properties

alias: string[]
desc: string
test: boolean
visibility: Visibility

Methods

Legend

  • Property
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Module | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Interface Module<T>

+
+
+
+
+
+
+
+
+
+

An object that gets imported and acts as a command.

+
+
+
property
+

{string} desc

+
property
+

{Visibility} visibility

+
property
+

{CommandType} type

+
property
+
+

+ {(eventParams : Context, args : Ok<T=string>) => Awaitable<possibleOutput | void>} + execute +

+
+
prop
+
+
+
+
+
+

Type parameters

+
    +
  • +

    T = string

    +
  • +
+
+
+

Hierarchy

+
    +
  • Module
  • +
+
+
+

Index

+
+
+
+

Properties

+ +
+
+

Methods

+ +
+
+
+
+
+

Properties

+
+ + +
+ alias: string[] +
+ +
+
+ + +
+ desc: string +
+ +
+
+ + +
+ test: boolean +
+ +
+
+ + +
+ type: + CommandType +
+ +
+
+ + +
+ visibility: + Visibility +
+ +
+
+
+

Methods

+
+ + + + +
+
+ + + + +
+
+
+ +
+
+
+
+

Legend

+
+
    +
  • Property
  • +
  • Method
  • +
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/interfaces/Sern.Wrapper.html b/docs/interfaces/Sern.Wrapper.html index 01312d3d..7fe8f9d3 100644 --- a/docs/interfaces/Sern.Wrapper.html +++ b/docs/interfaces/Sern.Wrapper.html @@ -1,8 +1,409 @@ -Wrapper | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Wrapper

-

An object to be passed into Sern.Handler constructor.

-
property

{readonly Client} client

-
property

{readonly string} prefix

-
property

{readonly string} commands

-
prop

{(handler : Handler) => void)} init

-
property

{readonly {test: boolean, id: string}[]} privateServers

-

Hierarchy

  • Wrapper

Index

Properties

client: Client<boolean>
commands: string
prefix: string
privateServers: { id: string; test: boolean }[]

Methods

Legend

  • Property
  • Method

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Wrapper | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Interface Wrapper

+
+
+
+
+
+
+
+
+
+

An object to be passed into Sern.Handler constructor.

+
+
+
property
+

{readonly Client} client

+
property
+

{readonly string} prefix

+
property
+

{readonly string} commands

+
prop
+

{(handler : Handler) => void)} init

+
property
+

{readonly {test: boolean, id: string}[]} privateServers

+
+
+
+
+

Hierarchy

+
    +
  • Wrapper
  • +
+
+
+

Index

+
+
+
+

Properties

+ +
+
+

Methods

+ +
+
+
+
+
+

Properties

+
+ + +
+ client: Client<boolean> +
+ +
+
+ + +
+ commands: string +
+ +
+
+ + +
+ prefix: string +
+ +
+
+ + +
+ privateServers: + { id: string; test: boolean }[] +
+ +
+
+
+

Methods

+
+ + +
    +
  • + init(handler: Handler): void +
  • +
+ +
+
+
+ +
+
+
+
+

Legend

+
+
    +
  • Property
  • +
  • Method
  • +
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules.html b/docs/modules.html index 3d28a777..44bf4f6b 100644 --- a/docs/modules.html +++ b/docs/modules.html @@ -1 +1,115 @@ -sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

sern-handler

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + SernHandler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+

sern-handler

+
+
+
+
+
+
+

Index

+
+
+
+

Namespaces

+ +
+
+
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules/Sern.html b/docs/modules/Sern.html index 98d3b902..ac7c905b 100644 --- a/docs/modules/Sern.html +++ b/docs/modules/Sern.html @@ -1 +1,155 @@ -Sern | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Sern

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Sern | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Namespace Sern

+
+
+
+
+
+
+
+

Index

+
+
+
+

Enumerations

+ +
+
+

Classes

+ +
+
+

Interfaces

+ +
+
+
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules/Types.html b/docs/modules/Types.html index 00e931cb..2ae10487 100644 --- a/docs/modules/Types.html +++ b/docs/modules/Types.html @@ -1 +1,533 @@ -Types | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Types

Index

Type aliases

Arg: ParseType<{ slash: SlashOptions; text: string }>
Context: { interaction: Option<CommandInteraction>; message: Option<Message> }

Type declaration

  • interaction: Option<CommandInteraction>
  • message: Option<Message>
Nullable<T>: T | null

Type parameters

  • T

ParseType<T>: { [ K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never }[keyof T]

Type parameters

  • T

SlashOptions: Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused">
Visibility: "private" | "public"
execute: Module<unknown>["execute"]
possibleOutput<T>: T | (MessagePayload & MessageOptions)

Type parameters

  • T = string

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Types | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Namespace Types

+
+
+
+
+
+
+
+

Index

+
+
+
+

Type aliases

+ +
+
+
+
+
+

Type aliases

+
+ + +
+ Arg: + ParseType<{ slash: SlashOptions; text: string }> +
+ +
+
+ + +
+ Context: + { interaction: Option<CommandInteraction>; message: Option<Message> } +
+ +
+

Type declaration

+
    +
  • +
    + interaction: Option<CommandInteraction> +
    +
  • +
  • +
    + message: Option<Message> +
    +
  • +
+
+
+
+ + +
+ Nullable<T>: + T | null +
+ +

Type parameters

+
    +
  • T

  • +
+
+
+ + +
+ ParseType<T>: + { [ K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never + }[keyof T] +
+ +

Type parameters

+
    +
  • T

  • +
+
+
+ + +
+ SlashOptions: + Omit<CommandInteractionOptionResolver, "getMessage" | "getFocused"> +
+ +
+
+ + +
+ Visibility: + "private" | "public" +
+ +
+
+ + +
+ execute: + Module<unknown>["execute"] +
+ +
+
+ + +
+ possibleOutput<T>: + T | (MessagePayload & MessageOptions) +
+ +

Type parameters

+
    +
  • +

    T = string

    +
  • +
+
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + diff --git a/docs/modules/Utils.html b/docs/modules/Utils.html index b4b76565..74c2dfdb 100644 --- a/docs/modules/Utils.html +++ b/docs/modules/Utils.html @@ -1,25 +1,659 @@ -Utils | sern-handler
Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace Utils

Index

Type aliases

ArgType<T>: Result<T, possibleOutput>
-

Wrapper type taking Ok(T) or Err(possibleOutput) e.g Result<T, possibleOutput

-

Type parameters

  • T

Functions

  • parseBool(arg: string, onFailure?: possibleOutput<string>, regexes?: { noRegex: RegExp; yesRegex: RegExp }): ArgType<boolean>
  • toArr(arg: string, sep?: string): ArgType<string[]>

Settings

Theme

Generated using TypeDoc

\ No newline at end of file + + + + + + Utils | sern-handler + + + + + + + + +
+
+
+
+ +
+
+ Options +
+
+ All +
    +
  • Public
  • +
  • Public/Protected
  • +
  • All
  • +
+
+ +
+
+ Menu +
+
+
+
+
+
+ +

Namespace Utils

+
+
+
+
+
+
+
+

Index

+
+
+
+

Type aliases

+ +
+
+

Functions

+ +
+
+
+
+
+

Type aliases

+
+ + +
+ ArgType<T>: + Result<T, possibleOutput> +
+ +
+
+

+ Wrapper type taking Ok(T) or Err(possibleOutput) e.g + Result<T, possibleOutput +

+
+
+

Type parameters

+
    +
  • T

  • +
+
+
+
+

Functions

+
+ + +
    +
  • + parseBool(arg: string, onFailure?: possibleOutput<string>, regexes?: { noRegex: RegExp; yesRegex: RegExp }): ArgType<boolean> +
  • +
+
    +
  • + +

    Parameters

    +
      +
    • +
      arg: string
      +
      +
      +

      command arguments

      +
      +
      +
    • +
    • +
      + onFailure: + possibleOutput<string> = ... +
      +
      +
      +

      If cannot parse arg into boolean.

      +
      +
      +
    • +
    • +
      + regexes: { noRegex: RegExp; yesRegex: RegExp } = ... +
      +
        +
      • +
        + noRegex: RegExp +
        +
      • +
      • +
        + yesRegex: RegExp +
        +
      • +
      +
    • +
    +

    + Returns + ArgType<boolean> +

    +
    +

    attemps to parse args as a boolean

    +
    +
  • +
+
+
+ + + + +
+
+ + +
    +
  • + toArr(arg: string, sep?: string): ArgType<string[]> +
  • +
+ +
+
+ + + + +
+
+ + + + +
+
+
+ +
+
+
+
+

Settings

+

+ Theme + +

+
+
+
+

Generated using TypeDoc

+
+
+ + + From 4e1ef66a255d562005e07371a6054ad381dce480 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 12 Apr 2022 23:13:37 +0300 Subject: [PATCH 096/128] Revert "style: Formatted 17 files & changes messageHelper util" This reverts commit 988d7fa6d2f07fadd05d1fc5a42c26d4767b0b44. --- package-lock.json | 69 ++++++++++------------------------------------- package.json | 4 +-- 2 files changed, 16 insertions(+), 57 deletions(-) diff --git a/package-lock.json b/package-lock.json index 21dfebaa..4d7419a2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -27,7 +27,7 @@ "jest": "^27.5.1", "prettier": "2.6.2", "standard-version": "^9.3.2", - "typedoc": "^0.22.14", + "typedoc": "^0.22.11", "typescript": "^4.5.5" } }, @@ -8564,16 +8564,16 @@ } }, "node_modules/typedoc": { - "version": "0.22.14", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", - "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", "dev": true, "dependencies": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.12", - "minimatch": "^5.0.1", - "shiki": "^0.10.1" + "marked": "^4.0.10", + "minimatch": "^3.0.4", + "shiki": "^0.10.0" }, "bin": { "typedoc": "bin/typedoc" @@ -8582,28 +8582,7 @@ "node": ">= 12.10.0" }, "peerDependencies": { - "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x || 4.6.x" - } - }, - "node_modules/typedoc/node_modules/brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/typedoc/node_modules/minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", - "dev": true, - "dependencies": { - "brace-expansion": "^2.0.1" - }, - "engines": { - "node": ">=10" + "typescript": "4.0.x || 4.1.x || 4.2.x || 4.3.x || 4.4.x || 4.5.x" } }, "node_modules/typescript": { @@ -15450,36 +15429,16 @@ } }, "typedoc": { - "version": "0.22.14", - "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.14.tgz", - "integrity": "sha512-tlf9wIcsrnQSjetStrnRutuy2RjZkG5PK2umwveZLTkuC2K9VywOZTdu2G19BdOPzGrhZjf9WK7pthXqnFQejg==", + "version": "0.22.11", + "resolved": "https://registry.npmjs.org/typedoc/-/typedoc-0.22.11.tgz", + "integrity": "sha512-pVr3hh6dkS3lPPaZz1fNpvcrqLdtEvXmXayN55czlamSgvEjh+57GUqfhAI1Xsuu/hNHUT1KNSx8LH2wBP/7SA==", "dev": true, "requires": { "glob": "^7.2.0", "lunr": "^2.3.9", - "marked": "^4.0.12", - "minimatch": "^5.0.1", - "shiki": "^0.10.1" - }, - "dependencies": { - "brace-expansion": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", - "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", - "dev": true, - "requires": { - "balanced-match": "^1.0.0" - } - }, - "minimatch": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz", - "integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==", - "dev": true, - "requires": { - "brace-expansion": "^2.0.1" - } - } + "marked": "^4.0.10", + "minimatch": "^3.0.4", + "shiki": "^0.10.0" } }, "typescript": { diff --git a/package.json b/package.json index c7d194e7..0f282e03 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.0.1", "description": "", "main": "dist/index.js", - "scripts": { + "scripts": { "compile": "tsc", "watch": "tsc -w", "lint": "eslint src/**/*.ts", @@ -35,7 +35,7 @@ "jest": "^27.5.1", "prettier": "2.6.2", "standard-version": "^9.3.2", - "typedoc": "^0.22.14", + "typedoc": "^0.22.11", "typescript": "^4.5.5" }, "config": { From e51e388b05c50117868dbf5e68bde568910fcc30 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 12 Apr 2022 23:16:14 +0300 Subject: [PATCH 097/128] style(style.css): Formatted main style file with tabwidth 2 --- docs/assets/style.css | 1558 ++++++++++++++++++++--------------------- 1 file changed, 779 insertions(+), 779 deletions(-) diff --git a/docs/assets/style.css b/docs/assets/style.css index a16ed029..0e048966 100644 --- a/docs/assets/style.css +++ b/docs/assets/style.css @@ -1,110 +1,55 @@ -@import url("./icons.css"); +@import url('./icons.css'); :root { - /* Light */ - --light-color-background: #fcfcfc; - --light-color-secondary-background: #fff; - --light-color-text: #222; - --light-color-text-aside: #707070; - --light-color-link: #4da6ff; - --light-color-menu-divider: #eee; - --light-color-menu-divider-focus: #000; - --light-color-menu-label: #707070; - --light-color-panel: var(--light-color-secondary-background); - --light-color-panel-divider: #eee; - --light-color-comment-tag: #707070; - --light-color-comment-tag-text: #fff; - --light-color-ts: #9600ff; - --light-color-ts-interface: #647f1b; - --light-color-ts-enum: #937210; - --light-color-ts-class: #0672de; - --light-color-ts-private: #707070; - --light-color-toolbar: #fff; - --light-color-toolbar-text: #333; - --light-icon-filter: invert(0); - --light-external-icon: url("data:image/svg+xml;utf8,"); - - /* Dark */ - --dark-color-background: #36393f; - --dark-color-secondary-background: #2f3136; - --dark-color-text: #ffffff; - --dark-color-text-aside: #e6e4e4; - --dark-color-link: #00aff4; - --dark-color-menu-divider: #eee; - --dark-color-menu-divider-focus: #000; - --dark-color-menu-label: #707070; - --dark-color-panel: var(--dark-color-secondary-background); - --dark-color-panel-divider: #818181; - --dark-color-comment-tag: #dcddde; - --dark-color-comment-tag-text: #2f3136; - --dark-color-ts: #c97dff; - --dark-color-ts-interface: #9cbe3c; - --dark-color-ts-enum: #d6ab29; - --dark-color-ts-class: #3695f3; - --dark-color-ts-private: #e2e2e2; - --dark-color-toolbar: #34373c; - --dark-color-toolbar-text: #ffffff; - --dark-icon-filter: invert(1); - --dark-external-icon: url("data:image/svg+xml;utf8,"); + /* Light */ + --light-color-background: #fcfcfc; + --light-color-secondary-background: #fff; + --light-color-text: #222; + --light-color-text-aside: #707070; + --light-color-link: #4da6ff; + --light-color-menu-divider: #eee; + --light-color-menu-divider-focus: #000; + --light-color-menu-label: #707070; + --light-color-panel: var(--light-color-secondary-background); + --light-color-panel-divider: #eee; + --light-color-comment-tag: #707070; + --light-color-comment-tag-text: #fff; + --light-color-ts: #9600ff; + --light-color-ts-interface: #647f1b; + --light-color-ts-enum: #937210; + --light-color-ts-class: #0672de; + --light-color-ts-private: #707070; + --light-color-toolbar: #fff; + --light-color-toolbar-text: #333; + --light-icon-filter: invert(0); + --light-external-icon: url("data:image/svg+xml;utf8,"); + + /* Dark */ + --dark-color-background: #36393f; + --dark-color-secondary-background: #2f3136; + --dark-color-text: #ffffff; + --dark-color-text-aside: #e6e4e4; + --dark-color-link: #00aff4; + --dark-color-menu-divider: #eee; + --dark-color-menu-divider-focus: #000; + --dark-color-menu-label: #707070; + --dark-color-panel: var(--dark-color-secondary-background); + --dark-color-panel-divider: #818181; + --dark-color-comment-tag: #dcddde; + --dark-color-comment-tag-text: #2f3136; + --dark-color-ts: #c97dff; + --dark-color-ts-interface: #9cbe3c; + --dark-color-ts-enum: #d6ab29; + --dark-color-ts-class: #3695f3; + --dark-color-ts-private: #e2e2e2; + --dark-color-toolbar: #34373c; + --dark-color-toolbar-text: #ffffff; + --dark-icon-filter: invert(1); + --dark-external-icon: url("data:image/svg+xml;utf8,"); } @media (prefers-color-scheme: light) { - :root { - --color-background: var(--light-color-background); - --color-secondary-background: var(--light-color-secondary-background); - --color-text: var(--light-color-text); - --color-text-aside: var(--light-color-text-aside); - --color-link: var(--light-color-link); - --color-menu-divider: var(--light-color-menu-divider); - --color-menu-divider-focus: var(--light-color-menu-divider-focus); - --color-menu-label: var(--light-color-menu-label); - --color-panel: var(--light-color-panel); - --color-panel-divider: var(--light-color-panel-divider); - --color-comment-tag: var(--light-color-comment-tag); - --color-comment-tag-text: var(--light-color-comment-tag-text); - --color-ts: var(--light-color-ts); - --color-ts-interface: var(--light-color-ts-interface); - --color-ts-enum: var(--light-color-ts-enum); - --color-ts-class: var(--light-color-ts-class); - --color-ts-private: var(--light-color-ts-private); - --color-toolbar: var(--light-color-toolbar); - --color-toolbar-text: var(--light-color-toolbar-text); - --icon-filter: var(--light-icon-filter); - --external-icon: var(--light-external-icon); - } -} - -@media (prefers-color-scheme: dark) { - :root { - --color-background: var(--dark-color-background); - --color-secondary-background: var(--dark-color-secondary-background); - --color-text: var(--dark-color-text); - --color-text-aside: var(--dark-color-text-aside); - --color-link: var(--dark-color-link); - --color-menu-divider: var(--dark-color-menu-divider); - --color-menu-divider-focus: var(--dark-color-menu-divider-focus); - --color-menu-label: var(--dark-color-menu-label); - --color-panel: var(--dark-color-panel); - --color-panel-divider: var(--dark-color-panel-divider); - --color-comment-tag: var(--dark-color-comment-tag); - --color-comment-tag-text: var(--dark-color-comment-tag-text); - --color-ts: var(--dark-color-ts); - --color-ts-interface: var(--dark-color-ts-interface); - --color-ts-enum: var(--dark-color-ts-enum); - --color-ts-class: var(--dark-color-ts-class); - --color-ts-private: var(--dark-color-ts-private); - --color-toolbar: var(--dark-color-toolbar); - --color-toolbar-text: var(--dark-color-toolbar-text); - --icon-filter: var(--dark-icon-filter); - --external-icon: var(--dark-external-icon); - } -} - -body { - margin: 0; -} - -body.light { + :root { --color-background: var(--light-color-background); --color-secondary-background: var(--light-color-secondary-background); --color-text: var(--light-color-text); @@ -126,9 +71,11 @@ body.light { --color-toolbar-text: var(--light-color-toolbar-text); --icon-filter: var(--light-icon-filter); --external-icon: var(--light-external-icon); + } } -body.dark { +@media (prefers-color-scheme: dark) { + :root { --color-background: var(--dark-color-background); --color-secondary-background: var(--dark-color-secondary-background); --color-text: var(--dark-color-text); @@ -150,6 +97,59 @@ body.dark { --color-toolbar-text: var(--dark-color-toolbar-text); --icon-filter: var(--dark-icon-filter); --external-icon: var(--dark-external-icon); + } +} + +body { + margin: 0; +} + +body.light { + --color-background: var(--light-color-background); + --color-secondary-background: var(--light-color-secondary-background); + --color-text: var(--light-color-text); + --color-text-aside: var(--light-color-text-aside); + --color-link: var(--light-color-link); + --color-menu-divider: var(--light-color-menu-divider); + --color-menu-divider-focus: var(--light-color-menu-divider-focus); + --color-menu-label: var(--light-color-menu-label); + --color-panel: var(--light-color-panel); + --color-panel-divider: var(--light-color-panel-divider); + --color-comment-tag: var(--light-color-comment-tag); + --color-comment-tag-text: var(--light-color-comment-tag-text); + --color-ts: var(--light-color-ts); + --color-ts-interface: var(--light-color-ts-interface); + --color-ts-enum: var(--light-color-ts-enum); + --color-ts-class: var(--light-color-ts-class); + --color-ts-private: var(--light-color-ts-private); + --color-toolbar: var(--light-color-toolbar); + --color-toolbar-text: var(--light-color-toolbar-text); + --icon-filter: var(--light-icon-filter); + --external-icon: var(--light-external-icon); +} + +body.dark { + --color-background: var(--dark-color-background); + --color-secondary-background: var(--dark-color-secondary-background); + --color-text: var(--dark-color-text); + --color-text-aside: var(--dark-color-text-aside); + --color-link: var(--dark-color-link); + --color-menu-divider: var(--dark-color-menu-divider); + --color-menu-divider-focus: var(--dark-color-menu-divider-focus); + --color-menu-label: var(--dark-color-menu-label); + --color-panel: var(--dark-color-panel); + --color-panel-divider: var(--dark-color-panel-divider); + --color-comment-tag: var(--dark-color-comment-tag); + --color-comment-tag-text: var(--dark-color-comment-tag-text); + --color-ts: var(--dark-color-ts); + --color-ts-interface: var(--dark-color-ts-interface); + --color-ts-enum: var(--dark-color-ts-enum); + --color-ts-class: var(--dark-color-ts-class); + --color-ts-private: var(--dark-color-ts-private); + --color-toolbar: var(--dark-color-toolbar); + --color-toolbar-text: var(--dark-color-toolbar-text); + --icon-filter: var(--dark-icon-filter); + --external-icon: var(--dark-external-icon); } h1, @@ -158,97 +158,97 @@ h3, h4, h5, h6 { - line-height: 1.2; + line-height: 1.2; } h1 { - font-size: 2em; - margin: 0.67em 0; + font-size: 2em; + margin: 0.67em 0; } h2 { - font-size: 1.5em; - margin: 0.83em 0; + font-size: 1.5em; + margin: 0.83em 0; } h3 { - font-size: 1.17em; - margin: 1em 0; + font-size: 1.17em; + margin: 1em 0; } h4, .tsd-index-panel h3 { - font-size: 1em; - margin: 1.33em 0; + font-size: 1em; + margin: 1.33em 0; } h5 { - font-size: 0.83em; - margin: 1.67em 0; + font-size: 0.83em; + margin: 1.67em 0; } h6 { - font-size: 0.67em; - margin: 2.33em 0; + font-size: 0.67em; + margin: 2.33em 0; } pre { - white-space: pre; - white-space: pre-wrap; - word-wrap: break-word; + white-space: pre; + white-space: pre-wrap; + word-wrap: break-word; } dl, menu, ol, ul { - margin: 1em 0; + margin: 1em 0; } dd { - margin: 0 0 0 40px; + margin: 0 0 0 40px; } .container { - max-width: 1200px; - margin: 0 auto; - padding: 0 40px; + max-width: 1200px; + margin: 0 auto; + padding: 0 40px; } @media (max-width: 640px) { - .container { - padding: 0 20px; - } + .container { + padding: 0 20px; + } } .container-main { - padding-bottom: 200px; + padding-bottom: 200px; } .row { - display: flex; - position: relative; - margin: 0 -10px; + display: flex; + position: relative; + margin: 0 -10px; } .row:after { - visibility: hidden; - display: block; - content: ""; - clear: both; - height: 0; + visibility: hidden; + display: block; + content: ''; + clear: both; + height: 0; } .col-4, .col-8 { - box-sizing: border-box; - float: left; - padding: 0 10px; + box-sizing: border-box; + float: left; + padding: 0 10px; } .col-4 { - width: 33.3333333333%; + width: 33.3333333333%; } .col-8 { - width: 66.6666666667%; + width: 66.6666666667%; } ul.tsd-descriptions > li > :first-child, @@ -263,7 +263,7 @@ ul.tsd-descriptions > li > :first-child > :first-child > :first-child, .tsd-panel > :first-child > :first-child > :first-child, .col-8 > :first-child > :first-child > :first-child, .col-4 > :first-child > :first-child > :first-child { - margin-top: 0; + margin-top: 0; } ul.tsd-descriptions > li > :last-child, .tsd-panel > :last-child, @@ -277,1137 +277,1137 @@ ul.tsd-descriptions > li > :last-child > :last-child > :last-child, .tsd-panel > :last-child > :last-child > :last-child, .col-8 > :last-child > :last-child > :last-child, .col-4 > :last-child > :last-child > :last-child { - margin-bottom: 0; + margin-bottom: 0; } @keyframes fade-in { - from { - opacity: 0; - } - to { - opacity: 1; - } + from { + opacity: 0; + } + to { + opacity: 1; + } } @keyframes fade-out { - from { - opacity: 1; - visibility: visible; - } - to { - opacity: 0; - } + from { + opacity: 1; + visibility: visible; + } + to { + opacity: 0; + } } @keyframes fade-in-delayed { - 0% { - opacity: 0; - } - 33% { - opacity: 0; - } - 100% { - opacity: 1; - } + 0% { + opacity: 0; + } + 33% { + opacity: 0; + } + 100% { + opacity: 1; + } } @keyframes fade-out-delayed { - 0% { - opacity: 1; - visibility: visible; - } - 66% { - opacity: 0; - } - 100% { - opacity: 0; - } + 0% { + opacity: 1; + visibility: visible; + } + 66% { + opacity: 0; + } + 100% { + opacity: 0; + } } @keyframes shift-to-left { - from { - transform: translate(0, 0); - } - to { - transform: translate(-25%, 0); - } + from { + transform: translate(0, 0); + } + to { + transform: translate(-25%, 0); + } } @keyframes unshift-to-left { - from { - transform: translate(-25%, 0); - } - to { - transform: translate(0, 0); - } + from { + transform: translate(-25%, 0); + } + to { + transform: translate(0, 0); + } } @keyframes pop-in-from-right { - from { - transform: translate(100%, 0); - } - to { - transform: translate(0, 0); - } + from { + transform: translate(100%, 0); + } + to { + transform: translate(0, 0); + } } @keyframes pop-out-to-right { - from { - transform: translate(0, 0); - visibility: visible; - } - to { - transform: translate(100%, 0); - } + from { + transform: translate(0, 0); + visibility: visible; + } + to { + transform: translate(100%, 0); + } } body { - background: var(--color-background); - font-family: "Segoe UI", sans-serif; - font-size: 16px; - color: var(--color-text); + background: var(--color-background); + font-family: 'Segoe UI', sans-serif; + font-size: 16px; + color: var(--color-text); } a { - color: var(--color-link); - text-decoration: none; + color: var(--color-link); + text-decoration: none; } a:hover { - text-decoration: underline; + text-decoration: underline; } -a.external[target="_blank"] { - background-image: var(--external-icon); - background-position: top 3px right; - background-repeat: no-repeat; - padding-right: 13px; +a.external[target='_blank'] { + background-image: var(--external-icon); + background-position: top 3px right; + background-repeat: no-repeat; + padding-right: 13px; } code, pre { - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - padding: 0.2em; - margin: 0; - font-size: 14px; + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; + padding: 0.2em; + margin: 0; + font-size: 14px; } pre { - padding: 10px; + padding: 10px; } pre code { - padding: 0; - font-size: 100%; + padding: 0; + font-size: 100%; } blockquote { - margin: 1em 0; - padding-left: 1em; - border-left: 4px solid gray; + margin: 1em 0; + padding-left: 1em; + border-left: 4px solid gray; } .tsd-typography { - line-height: 1.333em; + line-height: 1.333em; } .tsd-typography ul { - list-style: square; - padding: 0 0 0 20px; - margin: 0; + list-style: square; + padding: 0 0 0 20px; + margin: 0; } .tsd-typography h4, .tsd-typography .tsd-index-panel h3, .tsd-index-panel .tsd-typography h3, .tsd-typography h5, .tsd-typography h6 { - font-size: 1em; - margin: 0; + font-size: 1em; + margin: 0; } .tsd-typography h5, .tsd-typography h6 { - font-weight: normal; + font-weight: normal; } .tsd-typography p, .tsd-typography ul, .tsd-typography ol { - margin: 1em 0; + margin: 1em 0; } @media (min-width: 901px) and (max-width: 1024px) { - html .col-content { - width: 72%; - } - html .col-menu { - width: 28%; - } - html .tsd-navigation { - padding-left: 10px; - } + html .col-content { + width: 72%; + } + html .col-menu { + width: 28%; + } + html .tsd-navigation { + padding-left: 10px; + } } @media (max-width: 900px) { - html .col-content { - float: none; - width: 100%; - } - html .col-menu { - position: fixed !important; - overflow: auto; - -webkit-overflow-scrolling: touch; - z-index: 1024; - top: 0 !important; - bottom: 0 !important; - left: auto !important; - right: 0 !important; - width: 100%; - padding: 20px 20px 0 0; - max-width: 450px; - visibility: hidden; - background-color: var(--color-panel); - transform: translate(100%, 0); - } - html .col-menu > *:last-child { - padding-bottom: 20px; - } - html .overlay { - content: ""; - display: block; - position: fixed; - z-index: 1023; - top: 0; - left: 0; - right: 0; - bottom: 0; - background-color: rgba(0, 0, 0, 0.75); - visibility: hidden; - } - - .to-has-menu .overlay { - animation: fade-in 0.4s; - } - - .to-has-menu :is(header, footer, .col-content) { - animation: shift-to-left 0.4s; - } - - .to-has-menu .col-menu { - animation: pop-in-from-right 0.4s; - } - - .from-has-menu .overlay { - animation: fade-out 0.4s; - } - - .from-has-menu :is(header, footer, .col-content) { - animation: unshift-to-left 0.4s; - } - - .from-has-menu .col-menu { - animation: pop-out-to-right 0.4s; - } - - .has-menu body { - overflow: hidden; - } - .has-menu .overlay { - visibility: visible; - } - .has-menu :is(header, footer, .col-content) { - transform: translate(-25%, 0); - } - .has-menu .col-menu { - visibility: visible; - transform: translate(0, 0); - display: grid; - grid-template-rows: auto 1fr; - max-height: 100vh; - } - .has-menu .tsd-navigation { - max-height: 100%; - } + html .col-content { + float: none; + width: 100%; + } + html .col-menu { + position: fixed !important; + overflow: auto; + -webkit-overflow-scrolling: touch; + z-index: 1024; + top: 0 !important; + bottom: 0 !important; + left: auto !important; + right: 0 !important; + width: 100%; + padding: 20px 20px 0 0; + max-width: 450px; + visibility: hidden; + background-color: var(--color-panel); + transform: translate(100%, 0); + } + html .col-menu > *:last-child { + padding-bottom: 20px; + } + html .overlay { + content: ''; + display: block; + position: fixed; + z-index: 1023; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: rgba(0, 0, 0, 0.75); + visibility: hidden; + } + + .to-has-menu .overlay { + animation: fade-in 0.4s; + } + + .to-has-menu :is(header, footer, .col-content) { + animation: shift-to-left 0.4s; + } + + .to-has-menu .col-menu { + animation: pop-in-from-right 0.4s; + } + + .from-has-menu .overlay { + animation: fade-out 0.4s; + } + + .from-has-menu :is(header, footer, .col-content) { + animation: unshift-to-left 0.4s; + } + + .from-has-menu .col-menu { + animation: pop-out-to-right 0.4s; + } + + .has-menu body { + overflow: hidden; + } + .has-menu .overlay { + visibility: visible; + } + .has-menu :is(header, footer, .col-content) { + transform: translate(-25%, 0); + } + .has-menu .col-menu { + visibility: visible; + transform: translate(0, 0); + display: grid; + grid-template-rows: auto 1fr; + max-height: 100vh; + } + .has-menu .tsd-navigation { + max-height: 100%; + } } .tsd-page-title { - padding: 70px 0 20px 0; - margin: 0 0 40px 0; - background: var(--color-panel); - box-shadow: 0 0 5px rgba(0, 0, 0, 0.35); + padding: 70px 0 20px 0; + margin: 0 0 40px 0; + background: var(--color-panel); + box-shadow: 0 0 5px rgba(0, 0, 0, 0.35); } .tsd-page-title h1 { - margin: 0; + margin: 0; } .tsd-breadcrumb { - margin: 0; - padding: 0; - color: var(--color-text-aside); + margin: 0; + padding: 0; + color: var(--color-text-aside); } .tsd-breadcrumb a { - color: var(--color-text-aside); - text-decoration: none; + color: var(--color-text-aside); + text-decoration: none; } .tsd-breadcrumb a:hover { - text-decoration: underline; + text-decoration: underline; } .tsd-breadcrumb li { - display: inline; + display: inline; } .tsd-breadcrumb li:after { - content: " / "; + content: ' / '; } dl.tsd-comment-tags { - overflow: hidden; + overflow: hidden; } dl.tsd-comment-tags dt { - float: left; - padding: 1px 5px; - margin: 0 10px 0 0; - border-radius: 4px; - border: 1px solid var(--color-comment-tag); - color: var(--color-comment-tag); - font-size: 0.8em; - font-weight: normal; + float: left; + padding: 1px 5px; + margin: 0 10px 0 0; + border-radius: 4px; + border: 1px solid var(--color-comment-tag); + color: var(--color-comment-tag); + font-size: 0.8em; + font-weight: normal; } dl.tsd-comment-tags dd { - margin: 0 0 10px 0; + margin: 0 0 10px 0; } dl.tsd-comment-tags dd:before, dl.tsd-comment-tags dd:after { - display: table; - content: " "; + display: table; + content: ' '; } dl.tsd-comment-tags dd pre, dl.tsd-comment-tags dd:after { - clear: both; + clear: both; } dl.tsd-comment-tags p { - margin: 0; + margin: 0; } .tsd-panel.tsd-comment .lead { - font-size: 1.1em; - line-height: 1.333em; - margin-bottom: 2em; + font-size: 1.1em; + line-height: 1.333em; + margin-bottom: 2em; } .tsd-panel.tsd-comment .lead:last-child { - margin-bottom: 0; + margin-bottom: 0; } .toggle-protected .tsd-is-private { - display: none; + display: none; } .toggle-public .tsd-is-private, .toggle-public .tsd-is-protected, .toggle-public .tsd-is-private-protected { - display: none; + display: none; } .toggle-inherited .tsd-is-inherited { - display: none; + display: none; } .toggle-externals .tsd-is-external { - display: none; + display: none; } #tsd-filter { - position: relative; - display: inline-block; - height: 40px; - vertical-align: bottom; + position: relative; + display: inline-block; + height: 40px; + vertical-align: bottom; } .no-filter #tsd-filter { - display: none; + display: none; } #tsd-filter .tsd-filter-group { - display: inline-block; - height: 40px; - vertical-align: bottom; - white-space: nowrap; + display: inline-block; + height: 40px; + vertical-align: bottom; + white-space: nowrap; } #tsd-filter input { - display: none; + display: none; } @media (max-width: 900px) { - #tsd-filter .tsd-filter-group { - display: block; - position: absolute; - top: 40px; - right: 20px; - height: auto; - background-color: var(--color-panel); - visibility: hidden; - transform: translate(50%, 0); - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); - } - .has-options #tsd-filter .tsd-filter-group { - visibility: visible; - } - .to-has-options #tsd-filter .tsd-filter-group { - animation: fade-in 0.2s; - } - .from-has-options #tsd-filter .tsd-filter-group { - animation: fade-out 0.2s; - } - #tsd-filter label, - #tsd-filter .tsd-select { - display: block; - padding-right: 20px; - } + #tsd-filter .tsd-filter-group { + display: block; + position: absolute; + top: 40px; + right: 20px; + height: auto; + background-color: var(--color-panel); + visibility: hidden; + transform: translate(50%, 0); + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + } + .has-options #tsd-filter .tsd-filter-group { + visibility: visible; + } + .to-has-options #tsd-filter .tsd-filter-group { + animation: fade-in 0.2s; + } + .from-has-options #tsd-filter .tsd-filter-group { + animation: fade-out 0.2s; + } + #tsd-filter label, + #tsd-filter .tsd-select { + display: block; + padding-right: 20px; + } } footer { - border-top: 1px solid var(--color-panel-divider); - background-color: var(--color-panel); + border-top: 1px solid var(--color-panel-divider); + background-color: var(--color-panel); } footer:after { - content: ""; - display: table; + content: ''; + display: table; } footer.with-border-bottom { - border-bottom: 1px solid var(--color-panel-divider); + border-bottom: 1px solid var(--color-panel-divider); } footer .tsd-legend-group { - font-size: 0; + font-size: 0; } footer .tsd-legend { - display: inline-block; - width: 25%; - padding: 0; - font-size: 16px; - list-style: none; - line-height: 1.333em; - vertical-align: top; + display: inline-block; + width: 25%; + padding: 0; + font-size: 16px; + list-style: none; + line-height: 1.333em; + vertical-align: top; } @media (max-width: 900px) { - footer .tsd-legend { - width: 50%; - } + footer .tsd-legend { + width: 50%; + } } .tsd-hierarchy { - list-style: square; - padding: 0 0 0 20px; - margin: 0; + list-style: square; + padding: 0 0 0 20px; + margin: 0; } .tsd-hierarchy .target { - font-weight: bold; + font-weight: bold; } .tsd-index-panel .tsd-index-content { - margin-bottom: -30px !important; + margin-bottom: -30px !important; } .tsd-index-panel .tsd-index-section { - margin-bottom: 30px !important; + margin-bottom: 30px !important; } .tsd-index-panel h3 { - margin: 0 -20px 10px -20px; - padding: 0 20px 10px 20px; - border-bottom: 1px solid var(--color-panel-divider); + margin: 0 -20px 10px -20px; + padding: 0 20px 10px 20px; + border-bottom: 1px solid var(--color-panel-divider); } .tsd-index-panel ul.tsd-index-list { - -webkit-column-count: 3; - -moz-column-count: 3; - -ms-column-count: 3; - -o-column-count: 3; - column-count: 3; - -webkit-column-gap: 20px; - -moz-column-gap: 20px; - -ms-column-gap: 20px; - -o-column-gap: 20px; - column-gap: 20px; - padding: 0; - list-style: none; - line-height: 1.333em; + -webkit-column-count: 3; + -moz-column-count: 3; + -ms-column-count: 3; + -o-column-count: 3; + column-count: 3; + -webkit-column-gap: 20px; + -moz-column-gap: 20px; + -ms-column-gap: 20px; + -o-column-gap: 20px; + column-gap: 20px; + padding: 0; + list-style: none; + line-height: 1.333em; } @media (max-width: 900px) { - .tsd-index-panel ul.tsd-index-list { - -webkit-column-count: 1; - -moz-column-count: 1; - -ms-column-count: 1; - -o-column-count: 1; - column-count: 1; - } + .tsd-index-panel ul.tsd-index-list { + -webkit-column-count: 1; + -moz-column-count: 1; + -ms-column-count: 1; + -o-column-count: 1; + column-count: 1; + } } @media (min-width: 901px) and (max-width: 1024px) { - .tsd-index-panel ul.tsd-index-list { - -webkit-column-count: 2; - -moz-column-count: 2; - -ms-column-count: 2; - -o-column-count: 2; - column-count: 2; - } + .tsd-index-panel ul.tsd-index-list { + -webkit-column-count: 2; + -moz-column-count: 2; + -ms-column-count: 2; + -o-column-count: 2; + column-count: 2; + } } .tsd-index-panel ul.tsd-index-list li { - -webkit-page-break-inside: avoid; - -moz-page-break-inside: avoid; - -ms-page-break-inside: avoid; - -o-page-break-inside: avoid; - page-break-inside: avoid; + -webkit-page-break-inside: avoid; + -moz-page-break-inside: avoid; + -ms-page-break-inside: avoid; + -o-page-break-inside: avoid; + page-break-inside: avoid; } .tsd-index-panel a, .tsd-index-panel .tsd-parent-kind-module a { - color: var(--color-ts); + color: var(--color-ts); } .tsd-index-panel .tsd-parent-kind-interface a { - color: var(--color-ts-interface); + color: var(--color-ts-interface); } .tsd-index-panel .tsd-parent-kind-enum a { - color: var(--color-ts-enum); + color: var(--color-ts-enum); } .tsd-index-panel .tsd-parent-kind-class a { - color: var(--color-ts-class); + color: var(--color-ts-class); } .tsd-index-panel .tsd-kind-module a { - color: var(--color-ts); + color: var(--color-ts); } .tsd-index-panel .tsd-kind-interface a { - color: var(--color-ts-interface); + color: var(--color-ts-interface); } .tsd-index-panel .tsd-kind-enum a { - color: var(--color-ts-enum); + color: var(--color-ts-enum); } .tsd-index-panel .tsd-kind-class a { - color: var(--color-ts-class); + color: var(--color-ts-class); } .tsd-index-panel .tsd-is-private a { - color: var(--color-ts-private); + color: var(--color-ts-private); } .tsd-flag { - display: inline-block; - padding: 1px 5px; - border-radius: 4px; - color: var(--color-comment-tag-text); - background-color: var(--color-comment-tag); - text-indent: 0; - font-size: 14px; - font-weight: normal; + display: inline-block; + padding: 1px 5px; + border-radius: 4px; + color: var(--color-comment-tag-text); + background-color: var(--color-comment-tag); + text-indent: 0; + font-size: 14px; + font-weight: normal; } .tsd-anchor { - position: absolute; - top: -100px; + position: absolute; + top: -100px; } .tsd-member { - position: relative; + position: relative; } .tsd-member .tsd-anchor + h3 { - margin-top: 0; - margin-bottom: 0; - border-bottom: none; + margin-top: 0; + margin-bottom: 0; + border-bottom: none; } .tsd-member [data-tsd-kind] { - color: var(--color-ts); + color: var(--color-ts); } -.tsd-member [data-tsd-kind="Interface"] { - color: var(--color-ts-interface); +.tsd-member [data-tsd-kind='Interface'] { + color: var(--color-ts-interface); } -.tsd-member [data-tsd-kind="Enum"] { - color: var(--color-ts-enum); +.tsd-member [data-tsd-kind='Enum'] { + color: var(--color-ts-enum); } -.tsd-member [data-tsd-kind="Class"] { - color: var(--color-ts-class); +.tsd-member [data-tsd-kind='Class'] { + color: var(--color-ts-class); } -.tsd-member [data-tsd-kind="Private"] { - color: var(--color-ts-private); +.tsd-member [data-tsd-kind='Private'] { + color: var(--color-ts-private); } .tsd-navigation { - margin: 0 0 0 40px; + margin: 0 0 0 40px; } .tsd-navigation a { - display: block; - padding-top: 2px; - padding-bottom: 2px; - border-left: 2px solid transparent; - color: var(--color-text); - text-decoration: none; - transition: border-left-color 0.1s; + display: block; + padding-top: 2px; + padding-bottom: 2px; + border-left: 2px solid transparent; + color: var(--color-text); + text-decoration: none; + transition: border-left-color 0.1s; } .tsd-navigation a:hover { - text-decoration: underline; + text-decoration: underline; } .tsd-navigation ul { - margin: 0; - padding: 0; - list-style: none; + margin: 0; + padding: 0; + list-style: none; } .tsd-navigation li { - padding: 0; + padding: 0; } .tsd-navigation.primary { - padding-bottom: 40px; + padding-bottom: 40px; } .tsd-navigation.primary a { - display: block; - padding-top: 6px; - padding-bottom: 6px; + display: block; + padding-top: 6px; + padding-bottom: 6px; } .tsd-navigation.primary ul li a { - padding-left: 5px; + padding-left: 5px; } .tsd-navigation.primary ul li li a { - padding-left: 25px; + padding-left: 25px; } .tsd-navigation.primary ul li li li a { - padding-left: 45px; + padding-left: 45px; } .tsd-navigation.primary ul li li li li a { - padding-left: 65px; + padding-left: 65px; } .tsd-navigation.primary ul li li li li li a { - padding-left: 85px; + padding-left: 85px; } .tsd-navigation.primary ul li li li li li li a { - padding-left: 105px; + padding-left: 105px; } .tsd-navigation.primary > ul { - border-bottom: 1px solid var(--color-panel-divider); + border-bottom: 1px solid var(--color-panel-divider); } .tsd-navigation.primary li { - border-top: 1px solid var(--color-panel-divider); + border-top: 1px solid var(--color-panel-divider); } .tsd-navigation.primary li.current > a { - font-weight: bold; + font-weight: bold; } .tsd-navigation.primary li.label span { - display: block; - padding: 20px 0 6px 5px; - color: var(--color-menu-label); + display: block; + padding: 20px 0 6px 5px; + color: var(--color-menu-label); } .tsd-navigation.primary li.globals + li > span, .tsd-navigation.primary li.globals + li > a { - padding-top: 20px; + padding-top: 20px; } .tsd-navigation.secondary { - max-height: calc(100vh - 1rem - 40px); - overflow: auto; - position: sticky; - top: calc(0.5rem + 40px); - transition: 0.3s; + max-height: calc(100vh - 1rem - 40px); + overflow: auto; + position: sticky; + top: calc(0.5rem + 40px); + transition: 0.3s; } .tsd-navigation.secondary.tsd-navigation--toolbar-hide { - max-height: calc(100vh - 1rem); - top: 0.5rem; + max-height: calc(100vh - 1rem); + top: 0.5rem; } .tsd-navigation.secondary ul { - transition: opacity 0.2s; + transition: opacity 0.2s; } .tsd-navigation.secondary ul li a { - padding-left: 25px; + padding-left: 25px; } .tsd-navigation.secondary ul li li a { - padding-left: 45px; + padding-left: 45px; } .tsd-navigation.secondary ul li li li a { - padding-left: 65px; + padding-left: 65px; } .tsd-navigation.secondary ul li li li li a { - padding-left: 85px; + padding-left: 85px; } .tsd-navigation.secondary ul li li li li li a { - padding-left: 105px; + padding-left: 105px; } .tsd-navigation.secondary ul li li li li li li a { - padding-left: 125px; + padding-left: 125px; } .tsd-navigation.secondary ul.current a { - border-left-color: var(--color-panel-divider); + border-left-color: var(--color-panel-divider); } .tsd-navigation.secondary li.focus > a, .tsd-navigation.secondary ul.current li.focus > a { - border-left-color: var(--color-menu-divider-focus); + border-left-color: var(--color-menu-divider-focus); } .tsd-navigation.secondary li.current { - margin-top: 20px; - margin-bottom: 20px; - border-left-color: var(--color-panel-divider); + margin-top: 20px; + margin-bottom: 20px; + border-left-color: var(--color-panel-divider); } .tsd-navigation.secondary li.current > a { - font-weight: bold; + font-weight: bold; } @media (min-width: 901px) { - .menu-sticky-wrap { - position: static; - } + .menu-sticky-wrap { + position: static; + } } .tsd-panel { - margin: 20px 0; - padding: 20px; - background-color: var(--color-panel); - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + margin: 20px 0; + padding: 20px; + background-color: var(--color-panel); + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); } .tsd-panel:empty { - display: none; + display: none; } .tsd-panel > h1, .tsd-panel > h2, .tsd-panel > h3 { - margin: 1.5em -20px 10px -20px; - padding: 0 20px 10px 20px; - border-bottom: 1px solid var(--color-panel-divider); + margin: 1.5em -20px 10px -20px; + padding: 0 20px 10px 20px; + border-bottom: 1px solid var(--color-panel-divider); } .tsd-panel > h1.tsd-before-signature, .tsd-panel > h2.tsd-before-signature, .tsd-panel > h3.tsd-before-signature { - margin-bottom: 0; - border-bottom: 0; + margin-bottom: 0; + border-bottom: 0; } .tsd-panel table { - display: block; - width: 100%; - overflow: auto; - margin-top: 10px; - word-break: normal; - word-break: keep-all; - border-collapse: collapse; + display: block; + width: 100%; + overflow: auto; + margin-top: 10px; + word-break: normal; + word-break: keep-all; + border-collapse: collapse; } .tsd-panel table th { - font-weight: bold; + font-weight: bold; } .tsd-panel table th, .tsd-panel table td { - padding: 6px 13px; - border: 1px solid var(--color-panel-divider); + padding: 6px 13px; + border: 1px solid var(--color-panel-divider); } .tsd-panel table tr { - background: var(--color-background); + background: var(--color-background); } .tsd-panel table tr:nth-child(even) { - background: var(--color-secondary-background); + background: var(--color-secondary-background); } .tsd-panel-group { - margin: 60px 0; + margin: 60px 0; } .tsd-panel-group > h1, .tsd-panel-group > h2, .tsd-panel-group > h3 { - padding-left: 20px; - padding-right: 20px; + padding-left: 20px; + padding-right: 20px; } #tsd-search { - transition: background-color 0.2s; + transition: background-color 0.2s; } #tsd-search .title { - position: relative; - z-index: 2; + position: relative; + z-index: 2; } #tsd-search .field { - position: absolute; - left: 0; - top: 0; - right: 40px; - height: 40px; + position: absolute; + left: 0; + top: 0; + right: 40px; + height: 40px; } #tsd-search .field input { - box-sizing: border-box; - position: relative; - top: -50px; - z-index: 1; - width: 100%; - padding: 0 10px; - opacity: 0; - outline: 0; - border: 0; - background: transparent; - color: var(--color-text); + box-sizing: border-box; + position: relative; + top: -50px; + z-index: 1; + width: 100%; + padding: 0 10px; + opacity: 0; + outline: 0; + border: 0; + background: transparent; + color: var(--color-text); } #tsd-search .field label { - position: absolute; - overflow: hidden; - right: -40px; + position: absolute; + overflow: hidden; + right: -40px; } #tsd-search .field input, #tsd-search .title { - transition: opacity 0.2s; + transition: opacity 0.2s; } #tsd-search .results { - position: absolute; - visibility: hidden; - top: 40px; - width: 100%; - margin: 0; - padding: 0; - list-style: none; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + position: absolute; + visibility: hidden; + top: 40px; + width: 100%; + margin: 0; + padding: 0; + list-style: none; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); } #tsd-search .results li { - padding: 0 10px; - background-color: var(--color-background); + padding: 0 10px; + background-color: var(--color-background); } #tsd-search .results li:nth-child(even) { - background-color: var(--color-panel); + background-color: var(--color-panel); } #tsd-search .results li.state { - display: none; + display: none; } #tsd-search .results li.current, #tsd-search .results li:hover { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } #tsd-search .results a { - display: block; + display: block; } #tsd-search .results a:before { - top: 10px; + top: 10px; } #tsd-search .results span.parent { - color: var(--color-text-aside); - font-weight: normal; + color: var(--color-text-aside); + font-weight: normal; } #tsd-search.has-focus { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } #tsd-search.has-focus .field input { - top: 0; - opacity: 1; + top: 0; + opacity: 1; } #tsd-search.has-focus .title { - z-index: 0; - opacity: 0; + z-index: 0; + opacity: 0; } #tsd-search.has-focus .results { - visibility: visible; + visibility: visible; } #tsd-search.loading .results li.state.loading { - display: block; + display: block; } #tsd-search.failure .results li.state.failure { - display: block; + display: block; } .tsd-signature { - margin: 0 0 1em 0; - padding: 10px; - border: 1px solid var(--color-panel-divider); - font-family: Menlo, Monaco, Consolas, "Courier New", monospace; - font-size: 14px; - overflow-x: auto; + margin: 0 0 1em 0; + padding: 10px; + border: 1px solid var(--color-panel-divider); + font-family: Menlo, Monaco, Consolas, 'Courier New', monospace; + font-size: 14px; + overflow-x: auto; } .tsd-signature.tsd-kind-icon { - padding-left: 30px; + padding-left: 30px; } .tsd-signature.tsd-kind-icon:before { - top: 10px; - left: 10px; + top: 10px; + left: 10px; } .tsd-panel > .tsd-signature { - margin-left: -20px; - margin-right: -20px; - border-width: 1px 0; + margin-left: -20px; + margin-right: -20px; + border-width: 1px 0; } .tsd-panel > .tsd-signature.tsd-kind-icon { - padding-left: 40px; + padding-left: 40px; } .tsd-panel > .tsd-signature.tsd-kind-icon:before { - left: 20px; + left: 20px; } .tsd-signature-symbol { - color: var(--color-text-aside); - font-weight: normal; + color: var(--color-text-aside); + font-weight: normal; } .tsd-signature-type { - font-style: italic; - font-weight: normal; + font-style: italic; + font-weight: normal; } .tsd-signatures { - padding: 0; - margin: 0 0 1em 0; - border: 1px solid var(--color-panel-divider); + padding: 0; + margin: 0 0 1em 0; + border: 1px solid var(--color-panel-divider); } .tsd-signatures .tsd-signature { - margin: 0; - border-width: 1px 0 0 0; - transition: background-color 0.1s; + margin: 0; + border-width: 1px 0 0 0; + transition: background-color 0.1s; } .tsd-signatures .tsd-signature:first-child { - border-top-width: 0; + border-top-width: 0; } .tsd-signatures .tsd-signature.current { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } .tsd-signatures.active > .tsd-signature { - cursor: pointer; + cursor: pointer; } .tsd-panel > .tsd-signatures { - margin-left: -20px; - margin-right: -20px; - border-width: 1px 0; + margin-left: -20px; + margin-right: -20px; + border-width: 1px 0; } .tsd-panel > .tsd-signatures .tsd-signature.tsd-kind-icon { - padding-left: 40px; + padding-left: 40px; } .tsd-panel > .tsd-signatures .tsd-signature.tsd-kind-icon:before { - left: 20px; + left: 20px; } .tsd-panel > a.anchor + .tsd-signatures { - border-top-width: 0; - margin-top: -20px; + border-top-width: 0; + margin-top: -20px; } ul.tsd-descriptions { - position: relative; - overflow: hidden; - padding: 0; - list-style: none; + position: relative; + overflow: hidden; + padding: 0; + list-style: none; } ul.tsd-descriptions.active > .tsd-description { - display: none; + display: none; } ul.tsd-descriptions.active > .tsd-description.current { - display: block; + display: block; } ul.tsd-descriptions.active > .tsd-description.fade-in { - animation: fade-in-delayed 0.3s; + animation: fade-in-delayed 0.3s; } ul.tsd-descriptions.active > .tsd-description.fade-out { - animation: fade-out-delayed 0.3s; - position: absolute; - display: block; - top: 0; - left: 0; - right: 0; - opacity: 0; - visibility: hidden; + animation: fade-out-delayed 0.3s; + position: absolute; + display: block; + top: 0; + left: 0; + right: 0; + opacity: 0; + visibility: hidden; } ul.tsd-descriptions h4, ul.tsd-descriptions .tsd-index-panel h3, .tsd-index-panel ul.tsd-descriptions h3 { - font-size: 16px; - margin: 1em 0 0.5em 0; + font-size: 16px; + margin: 1em 0 0.5em 0; } ul.tsd-parameters, ul.tsd-type-parameters { - list-style: square; - margin: 0; - padding-left: 20px; + list-style: square; + margin: 0; + padding-left: 20px; } ul.tsd-parameters > li.tsd-parameter-signature, ul.tsd-type-parameters > li.tsd-parameter-signature { - list-style: none; - margin-left: -20px; + list-style: none; + margin-left: -20px; } ul.tsd-parameters h5, ul.tsd-type-parameters h5 { - font-size: 16px; - margin: 1em 0 0.5em 0; + font-size: 16px; + margin: 1em 0 0.5em 0; } ul.tsd-parameters .tsd-comment, ul.tsd-type-parameters .tsd-comment { - margin-top: -0.5em; + margin-top: -0.5em; } .tsd-sources { - font-size: 14px; - color: var(--color-text-aside); - margin: 0 0 1em 0; + font-size: 14px; + color: var(--color-text-aside); + margin: 0 0 1em 0; } .tsd-sources a { - color: var(--color-text-aside); - text-decoration: underline; + color: var(--color-text-aside); + text-decoration: underline; } .tsd-sources ul, .tsd-sources p { - margin: 0 !important; + margin: 0 !important; } .tsd-sources ul { - list-style: none; - padding: 0; + list-style: none; + padding: 0; } .tsd-page-toolbar { - position: fixed; - z-index: 1; - top: 0; - left: 0; - width: 100%; - height: 40px; - color: var(--color-toolbar-text); - background: var(--color-toolbar); - border-bottom: 1px solid var(--color-panel-divider); - transition: transform 0.3s linear; + position: fixed; + z-index: 1; + top: 0; + left: 0; + width: 100%; + height: 40px; + color: var(--color-toolbar-text); + background: var(--color-toolbar); + border-bottom: 1px solid var(--color-panel-divider); + transition: transform 0.3s linear; } .tsd-page-toolbar a { - color: var(--color-toolbar-text); - text-decoration: none; + color: var(--color-toolbar-text); + text-decoration: none; } .tsd-page-toolbar a.title { - font-weight: bold; + font-weight: bold; } .tsd-page-toolbar a.title:hover { - text-decoration: underline; + text-decoration: underline; } .tsd-page-toolbar .table-wrap { - display: table; - width: 100%; - height: 40px; + display: table; + width: 100%; + height: 40px; } .tsd-page-toolbar .table-cell { - display: table-cell; - position: relative; - white-space: nowrap; - line-height: 40px; + display: table-cell; + position: relative; + white-space: nowrap; + line-height: 40px; } .tsd-page-toolbar .table-cell:first-child { - width: 100%; + width: 100%; } .tsd-page-toolbar--hide { - transform: translateY(-100%); + transform: translateY(-100%); } .tsd-select .tsd-select-list li:before, .tsd-select .tsd-select-label:before, .tsd-widget:before { - content: ""; - display: inline-block; - width: 40px; - height: 40px; - margin: 0 -8px 0 0; - background-image: url(./widgets.png); - background-repeat: no-repeat; - text-indent: -1024px; - vertical-align: bottom; - filter: var(--icon-filter); + content: ''; + display: inline-block; + width: 40px; + height: 40px; + margin: 0 -8px 0 0; + background-image: url(./widgets.png); + background-repeat: no-repeat; + text-indent: -1024px; + vertical-align: bottom; + filter: var(--icon-filter); } @media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) { - .tsd-select .tsd-select-list li:before, - .tsd-select .tsd-select-label:before, - .tsd-widget:before { - background-image: url(./widgets@2x.png); - background-size: 320px 40px; - } + .tsd-select .tsd-select-list li:before, + .tsd-select .tsd-select-label:before, + .tsd-widget:before { + background-image: url(./widgets@2x.png); + background-size: 320px 40px; + } } .tsd-widget { - display: inline-block; - overflow: hidden; - opacity: 0.8; - height: 40px; - transition: opacity 0.1s, background-color 0.2s; - vertical-align: bottom; - cursor: pointer; + display: inline-block; + overflow: hidden; + opacity: 0.8; + height: 40px; + transition: opacity 0.1s, background-color 0.2s; + vertical-align: bottom; + cursor: pointer; } .tsd-widget:hover { - opacity: 0.9; + opacity: 0.9; } .tsd-widget.active { - opacity: 1; - background-color: var(--color-panel-divider); + opacity: 1; + background-color: var(--color-panel-divider); } .tsd-widget.no-caption { - width: 40px; + width: 40px; } .tsd-widget.no-caption:before { - margin: 0; + margin: 0; } .tsd-widget.search:before { - background-position: 0 0; + background-position: 0 0; } .tsd-widget.menu:before { - background-position: -40px 0; + background-position: -40px 0; } .tsd-widget.options:before { - background-position: -80px 0; + background-position: -80px 0; } .tsd-widget.options, .tsd-widget.menu { - display: none; + display: none; } @media (max-width: 900px) { - .tsd-widget.options, - .tsd-widget.menu { - display: inline-block; - } + .tsd-widget.options, + .tsd-widget.menu { + display: inline-block; + } } -input[type="checkbox"] + .tsd-widget:before { - background-position: -120px 0; +input[type='checkbox'] + .tsd-widget:before { + background-position: -120px 0; } -input[type="checkbox"]:checked + .tsd-widget:before { - background-position: -160px 0; +input[type='checkbox']:checked + .tsd-widget:before { + background-position: -160px 0; } .tsd-select { - position: relative; - display: inline-block; - height: 40px; - transition: opacity 0.1s, background-color 0.2s; - vertical-align: bottom; - cursor: pointer; + position: relative; + display: inline-block; + height: 40px; + transition: opacity 0.1s, background-color 0.2s; + vertical-align: bottom; + cursor: pointer; } .tsd-select .tsd-select-label { - opacity: 0.6; - transition: opacity 0.2s; + opacity: 0.6; + transition: opacity 0.2s; } .tsd-select .tsd-select-label:before { - background-position: -240px 0; + background-position: -240px 0; } .tsd-select.active .tsd-select-label { - opacity: 0.8; + opacity: 0.8; } .tsd-select.active .tsd-select-list { - visibility: visible; - opacity: 1; - transition-delay: 0s; + visibility: visible; + opacity: 1; + transition-delay: 0s; } .tsd-select .tsd-select-list { - position: absolute; - visibility: hidden; - top: 40px; - left: 0; - margin: 0; - padding: 0; - opacity: 0; - list-style: none; - box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); - transition: visibility 0s 0.2s, opacity 0.2s; + position: absolute; + visibility: hidden; + top: 40px; + left: 0; + margin: 0; + padding: 0; + opacity: 0; + list-style: none; + box-shadow: 0 0 4px rgba(0, 0, 0, 0.25); + transition: visibility 0s 0.2s, opacity 0.2s; } .tsd-select .tsd-select-list li { - padding: 0 20px 0 0; - background-color: var(--color-background); + padding: 0 20px 0 0; + background-color: var(--color-background); } .tsd-select .tsd-select-list li:before { - background-position: 40px 0; + background-position: 40px 0; } .tsd-select .tsd-select-list li:nth-child(even) { - background-color: var(--color-panel); + background-color: var(--color-panel); } .tsd-select .tsd-select-list li:hover { - background-color: var(--color-panel-divider); + background-color: var(--color-panel-divider); } .tsd-select .tsd-select-list li.selected:before { - background-position: -200px 0; + background-position: -200px 0; } @media (max-width: 900px) { - .tsd-select .tsd-select-list { - top: 0; - left: auto; - right: 100%; - margin-right: -5px; - } - .tsd-select .tsd-select-label:before { - background-position: -280px 0; - } + .tsd-select .tsd-select-list { + top: 0; + left: auto; + right: 100%; + margin-right: -5px; + } + .tsd-select .tsd-select-label:before { + background-position: -280px 0; + } } img { - max-width: 100%; + max-width: 100%; } .tsd-anchor-icon { - margin-left: 10px; - vertical-align: middle; - color: var(--color-text); + margin-left: 10px; + vertical-align: middle; + color: var(--color-text); } .tsd-anchor-icon svg { - width: 1em; - height: 1em; - visibility: hidden; + width: 1em; + height: 1em; + visibility: hidden; } .tsd-anchor-link:hover > .tsd-anchor-icon svg { - visibility: visible; + visibility: visible; } From 0377b081d939e2097ff2a75684af43c12c086dcd Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 14 Apr 2022 22:49:38 +0300 Subject: [PATCH 098/128] chore: Added docs maintainer --- .github/CODEOWNERS | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 00000000..42d14d29 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,2 @@ +src/* @jacoobes +docs/* @Murtatrxx \ No newline at end of file From 5f1e09e1ab912ce5d8d71884eab75506f5f95cd3 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 14 Apr 2022 22:57:16 +0300 Subject: [PATCH 099/128] chore: Changed typedoc configration --- .gitignore | 15 +++++++++------ package.json | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.gitignore b/.gitignore index d765bb9b..5c1ee6c2 100644 --- a/.gitignore +++ b/.gitignore @@ -54,19 +54,20 @@ typings/ # Yarn Integrity file .yarn-integrity -# dotenv environment variables file +# Typedoc raw output +.typedoc + +# Dotenv environment variables file .env -# parcel-bundler cache (https://parceljs.org/) +# Parcel-bundler cache (https://parceljs.org/) .cache -# next.js build output +# next.js and nuxt.js build output .next - -# nuxt.js build output .nuxt -# vuepress build output +# Vuepress build output .vuepress/dist # Serverless directories @@ -75,8 +76,10 @@ typings/ # FuseBox cache .fusebox/ +# TypeScript build output dist +# VisualStudio config file .vs .idea \ No newline at end of file diff --git a/package.json b/package.json index 0f282e03..6577aece 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "release": "standard-version && git push --follow-tags", "test": "jest --coverage --verbose", "commit": "cz", - "docs": "typedoc src/index.ts --out docs" + "docs": "typedoc src/index.ts --out .typedoc" }, "keywords": [], "author": "", From 36dc12ee601c2cc38c6443679e2aac1de341ccfc Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Thu, 14 Apr 2022 23:00:27 +0300 Subject: [PATCH 100/128] chore(README.md): Removed coming soon from links --- README.md | 86 ++++++++++++++++++++++--------------------------------- 1 file changed, 35 insertions(+), 51 deletions(-) diff --git a/README.md b/README.md index 0501c6ed..afa7d185 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -# Sern Handler - -NPM version NPM downloads Builds Passing +# SernHandler NPM version +NPM downloads +[![License: MIT](https://img.shields.io/badge/License-MIT-blavk.svg)](https://opensource.org/licenses/MIT) -Sern can automate and streamline development of your discord bot with new version compatibility and full customization. +A customizable, batteries-included, powerful discord.js framework to automate and streamline your bot development. - A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) @@ -23,74 +23,58 @@ pnpm add sern-handler ## Basic Usage -#### ` index.js ` +#### ` index.js (CommonJS)` ```js -import { Client, Intents } from 'discord.js'; -import { Sern } from 'sern-handler'; -import { prefix, token } from '../src/secrets.json'; +const { Client, Intents } = require('discord.js'); +const { Sern } = require('sern-handler'); +const { defaultPrefix, token } = require('./config.json'); const client = new Client({ - intents: [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MEMBERS - ] + intents: [ + Intents.FLAGS.GUILDS, + Intents.FLAGS.GUILD_MESSAGES, + Intents.FLAGS.GUILD_MEMBERS + ], }); -new Sern.Handler({ - client, - prefix, - commands: 'dist/commands', - privateServers: [ - { - test: true, - id: 'server-id' - } - ], - init: async (handler) => { - // Optional function to initialize anything else on bot startup - }, +Sern.init({ + client, + defaultPrefix, + commands : 'src/commands', }); - client.login(token); ``` -#### ` ping.js ` +#### ` ping.js (CommonJS)` ```js -import { Sern, Types } from 'sern-handler'; -import { Ok } from 'ts-results'; - -export default { - alias: [], - desc: 'A ping pong command', - visibility: 'private', - test: false, - type: Sern.CommandType.SLASH | Sern.CommandType.TEXT, - execute: async ({ message, interaction }, args) => 'pong!' +const { Sern, CommandType } = require('@sern/handler'); + +exports.default = { + description: 'A ping pong command', + type: CommandType.Slash, + execute(ctx) { + ctx.reply('pong!'); + } }; ``` See [documentation](https://sern-handler.js.org) for TypeScript examples and more -## Links ![link](https://img.shields.io/badge/Coming-Soon-purple) +## Links -- [Official Documentation](https://tmp.com) -- [Example Bot](https://tmp.com) -- [Discord Server](https://google.com) +- [Official Documentation](https://sern-handler.js.org) +- [Example Bot](https://github.com/sern-handler/cheemsBanker) +- [Support Server](https://discord.com/invite/Yvb7DnqjXX) ## Contribute -- Pull up on [issues](https://github.com/sern-handler/Sern/issues) and tell us, if there are bugs -- All kinds of contributions are welcomed! +- Read our contribution [guidelines](https://github.com/sern-handler/handler) carefully +- Pull up on [issues](https://github.com/sern-handler/handler/issues) and report bugs +- All kinds of contributions are welcomed. -## TODO +## Roadmap -- Default commands -- Categories -- Ruling out all bugs in the command system -- Better support for slash commands -- More Build scripts -- Logger +You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or patched in the future. \ No newline at end of file From 030dd47bc12325bb52c2eb34683f61dbb5f43439 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 24 Apr 2022 18:14:33 +0300 Subject: [PATCH 101/128] docs(readme): Improved Readme readability --- README.md | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index afa7d185..a8af8b1a 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,26 @@ +# SernHandler -# SernHandler NPM version +NPM version NPM downloads [![License: MIT](https://img.shields.io/badge/License-MIT-blavk.svg)](https://opensource.org/licenses/MIT) A customizable, batteries-included, powerful discord.js framework to automate and streamline your bot development. -- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) +- A reincarnation of [this old project](https://www.npmjs.com/package/sern_handler) ## Installation ```sh -npm install sern-handler +npm install @sern/handler ``` ```sh -yarn add sern-handler +yarn add @sern/handler +``` ``` ```sh -pnpm add sern-handler +pnpm add @sern/handler ``` ## Basic Usage @@ -66,7 +68,6 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor ## Links - [Official Documentation](https://sern-handler.js.org) -- [Example Bot](https://github.com/sern-handler/cheemsBanker) - [Support Server](https://discord.com/invite/Yvb7DnqjXX) ## Contribute From 2f10be994f56a1d42013206c082f9aa211a265f3 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:44:00 +0300 Subject: [PATCH 102/128] chore: Added CONTRIBUTING.md --- .github/CONTRIBUTING.md | 49 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 .github/CONTRIBUTING.md diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md new file mode 100644 index 00000000..685cb74c --- /dev/null +++ b/.github/CONTRIBUTING.md @@ -0,0 +1,49 @@ +# Contributing + +When contributing to this repository, please first discuss the change you wish to make via issue, +email, or any other method with the owners of this repository before making a change. + +Please note we have a [code of conduct](https://github.com/sern-handler/handler/blob/main/CODE_OF_CONDUCT.md), please follow it in all your interactions with the project. + +## Pull Request Process + +1. Ensure any install or build dependencies are removed before the end of the layer when doing a + build. +2. Update the README.md with details of changes to the interface, this includes new environment + variables, exposed ports, useful file locations and container parameters. +3. Increase the version numbers in any examples files and the README.md to the new version that this + Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/). +4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you + do not have permission to do that, you may request the second reviewer to merge it for you. + +### Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. +### Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at [INSERT EMAIL ADDRESS]. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +### Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file From 9ae76b8ad98669d2a4cf4b010e4329afdc9c13cc Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 25 Apr 2022 08:39:12 +0300 Subject: [PATCH 103/128] docs(README): Fixed installation box --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index a8af8b1a..9843614e 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,6 @@ npm install @sern/handler ```sh yarn add @sern/handler ``` -``` ```sh pnpm add @sern/handler From 6e96658d78e6ceb2ffba5687960e511be3f00cd1 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 10:27:49 +0300 Subject: [PATCH 104/128] style(README.md): Improved readability --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9843614e..ff667211 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A customizable, batteries-included, powerful discord.js framework to automate and streamline your bot development. -- A reincarnation of [this old project](https://www.npmjs.com/package/sern_handler) +- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) ## Installation From ebb3e897c2dc52eed6d9bb3f8a155671bf51965f Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:49:14 +0300 Subject: [PATCH 105/128] docs(README.md): Removed old repo link and it's line --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index ff667211..07f00207 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ A customizable, batteries-included, powerful discord.js framework to automate and streamline your bot development. -- A reincarnation of [this old project](https://github.com/jacoobes/sern_handler) ## Installation From a723155a7671860656b33dd32cf7346dda1c51f1 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:54:02 +0300 Subject: [PATCH 106/128] docs: Updated README example to djs v14 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 07f00207..244eadac 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ pnpm add @sern/handler #### ` index.js (CommonJS)` ```js -const { Client, Intents } = require('discord.js'); +const { Client, GatewayIntentBits } = require('discord.js'); const { Sern } = require('sern-handler'); const { defaultPrefix, token } = require('./config.json'); From 1747298313240a94db96a53cbccec896d232b951 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:53:01 +0300 Subject: [PATCH 107/128] docs(README): Updated Intents to djs v14 Co-authored-by: EvolutionX <85353424+EvolutionX-10@users.noreply.github.com> --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 244eadac..ad283f18 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ const { defaultPrefix, token } = require('./config.json'); const client = new Client({ intents: [ - Intents.FLAGS.GUILDS, - Intents.FLAGS.GUILD_MESSAGES, - Intents.FLAGS.GUILD_MEMBERS - ], + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages + ] }); Sern.init({ From 4a30a990fe5b2fa7b284e8ea7dc87dcadd610f7c Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Fri, 29 Apr 2022 14:55:14 +0300 Subject: [PATCH 108/128] docs: Formatted README examples --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ad283f18..5f2d259a 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ const { defaultPrefix, token } = require('./config.json'); const client = new Client({ intents: [ - GatewayIntentBits.Guilds, - GatewayIntentBits.GuildMembers, - GatewayIntentBits.GuildMessages - ] + GatewayIntentBits.Guilds, + GatewayIntentBits.GuildMembers, + GatewayIntentBits.GuildMessages + ] }); Sern.init({ From cac03e40745a62f650f32411b2f2b21de03669b2 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 2 May 2022 10:47:01 +0300 Subject: [PATCH 109/128] Update README.md --- README.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 5f2d259a..7da71a37 100644 --- a/README.md +++ b/README.md @@ -53,12 +53,12 @@ client.login(token); const { Sern, CommandType } = require('@sern/handler'); exports.default = { - description: 'A ping pong command', - type: CommandType.Slash, - execute(ctx) { - ctx.reply('pong!'); - } -}; + description: 'A ping pong command', + type: CommandType.Slash, + execute(ctx) { + ctx.reply('pong!'); + } + }; ``` See [documentation](https://sern-handler.js.org) for TypeScript examples and more From 80547b22924cb8dd6fd66bac76da916e1eba0a08 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 08:32:18 +0300 Subject: [PATCH 110/128] chore: Updated LICENSE --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index 921e84f8..ff8067c0 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. A discord.js wrapper to make easier to use discord.js - Copyright (C) 2022 SernHandler, Inc. + Copyright (C) 2022 Sern, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From cccdd504c006a3f695cb31798413a696593ee4d7 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 08:40:35 +0300 Subject: [PATCH 111/128] chore: Updated LICNESE --- LICENSE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.md b/LICENSE.md index ff8067c0..c62d772d 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -291,7 +291,7 @@ convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. A discord.js wrapper to make easier to use discord.js - Copyright (C) 2022 Sern, Inc. + Copyright (C) 2022 Sern. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 355fb398d5aa75cba3aa214f128b0d4e0d021e65 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 11:35:38 +0300 Subject: [PATCH 112/128] chore: Changed license to MIT --- LICENSE.md | 340 +---------------------------------------------------- 1 file changed, 5 insertions(+), 335 deletions(-) diff --git a/LICENSE.md b/LICENSE.md index c62d772d..72d26a38 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,339 +1,9 @@ - GNU GENERAL PUBLIC LICENSE - Version 2, June 1991 +Copyright (C) 2022 Sern - Copyright (C) 1989, 1991 Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - Preamble +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -License is intended to guarantee your freedom to share and change free -software--to make sure the software is free for all its users. This -General Public License applies to most of the Free Software -Foundation's software and to any other program whose authors commit to -using it. (Some other Free Software Foundation software is covered by -the GNU Lesser General Public License instead.) You can apply it to -your programs, too. +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -this service if you wish), that you receive source code or can get it -if you want it, that you can change the software or use pieces of it -in new free programs; and that you know you can do these things. - - To protect your rights, we need to make restrictions that forbid -anyone to deny you these rights or to ask you to surrender the rights. -These restrictions translate to certain responsibilities for you if you -distribute copies of the software, or if you modify it. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must give the recipients all the rights that -you have. You must make sure that they, too, receive or can get the -source code. And you must show them these terms so they know their -rights. - - We protect your rights with two steps: (1) copyright the software, and -(2) offer you this license which gives you legal permission to copy, -distribute and/or modify the software. - - Also, for each author's protection and ours, we want to make certain -that everyone understands that there is no warranty for this free -software. If the software is modified by someone else and passed on, we -want its recipients to know that what they have is not the original, so -that any problems introduced by others will not reflect on the original -authors' reputations. - - Finally, any free program is threatened constantly by software -patents. We wish to avoid the danger that redistributors of a free -program will individually obtain patent licenses, in effect making the -program proprietary. To prevent this, we have made it clear that any -patent must be licensed for everyone's free use or not licensed at all. - - The precise terms and conditions for copying, distribution and -modification follow. - - GNU GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License applies to any program or other work which contains -a notice placed by the copyright holder saying it may be distributed -under the terms of this General Public License. The "Program", below, -refers to any such program or work, and a "work based on the Program" -means either the Program or any derivative work under copyright law: -that is to say, a work containing the Program or a portion of it, -either verbatim or with modifications and/or translated into another -language. (Hereinafter, translation is included without limitation in -the term "modification".) Each licensee is addressed as "you". - -Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running the Program is not restricted, and the output from the Program -is covered only if its contents constitute a work based on the -Program (independent of having been made by running the Program). -Whether that is true depends on what the Program does. - - 1. You may copy and distribute verbatim copies of the Program's -source code as you receive it, in any medium, provided that you -conspicuously and appropriately publish on each copy an appropriate -copyright notice and disclaimer of warranty; keep intact all the -notices that refer to this License and to the absence of any warranty; -and give any other recipients of the Program a copy of this License -along with the Program. - -You may charge a fee for the physical act of transferring a copy, and -you may at your option offer warranty protection in exchange for a fee. - - 2. You may modify your copy or copies of the Program or any portion -of it, thus forming a work based on the Program, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) You must cause the modified files to carry prominent notices - stating that you changed the files and the date of any change. - - b) You must cause any work that you distribute or publish, that in - whole or in part contains or is derived from the Program or any - part thereof, to be licensed as a whole at no charge to all third - parties under the terms of this License. - - c) If the modified program normally reads commands interactively - when run, you must cause it, when started running for such - interactive use in the most ordinary way, to print or display an - announcement including an appropriate copyright notice and a - notice that there is no warranty (or else, saying that you provide - a warranty) and that users may redistribute the program under - these conditions, and telling the user how to view a copy of this - License. (Exception: if the Program itself is interactive but - does not normally print such an announcement, your work based on - the Program is not required to print an announcement.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Program, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Program, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Program. - -In addition, mere aggregation of another work not based on the Program -with the Program (or with a work based on the Program) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may copy and distribute the Program (or a work based on it, -under Section 2) in object code or executable form under the terms of -Sections 1 and 2 above provided that you also do one of the following: - - a) Accompany it with the complete corresponding machine-readable - source code, which must be distributed under the terms of Sections - 1 and 2 above on a medium customarily used for software interchange; or, - - b) Accompany it with a written offer, valid for at least three - years, to give any third party, for a charge no more than your - cost of physically performing source distribution, a complete - machine-readable copy of the corresponding source code, to be - distributed under the terms of Sections 1 and 2 above on a medium - customarily used for software interchange; or, - - c) Accompany it with the information you received as to the offer - to distribute corresponding source code. (This alternative is - allowed only for noncommercial distribution and only if you - received the program in object code or executable form with such - an offer, in accord with Subsection b above.) - -The source code for a work means the preferred form of the work for -making modifications to it. For an executable work, complete source -code means all the source code for all modules it contains, plus any -associated interface definition files, plus the scripts used to -control compilation and installation of the executable. However, as a -special exception, the source code distributed need not include -anything that is normally distributed (in either source or binary -form) with the major components (compiler, kernel, and so on) of the -operating system on which the executable runs, unless that component -itself accompanies the executable. - -If distribution of executable or object code is made by offering -access to copy from a designated place, then offering equivalent -access to copy the source code from the same place counts as -distribution of the source code, even though third parties are not -compelled to copy the source along with the object code. - - 4. You may not copy, modify, sublicense, or distribute the Program -except as expressly provided under this License. Any attempt -otherwise to copy, modify, sublicense or distribute the Program is -void, and will automatically terminate your rights under this License. -However, parties who have received copies, or rights, from you under -this License will not have their licenses terminated so long as such -parties remain in full compliance. - - 5. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Program or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Program (or any work based on the -Program), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Program or works based on it. - - 6. Each time you redistribute the Program (or any work based on the -Program), the recipient automatically receives a license from the -original licensor to copy, distribute or modify the Program subject to -these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties to -this License. - - 7. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Program at all. For example, if a patent -license would not permit royalty-free redistribution of the Program by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Program. - -If any portion of this section is held invalid or unenforceable under -any particular circumstance, the balance of the section is intended to -apply and the section as a whole is intended to apply in other -circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system, which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 8. If the distribution and/or use of the Program is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Program under this License -may add an explicit geographical distribution limitation excluding -those countries, so that distribution is permitted only in or among -countries not thus excluded. In such case, this License incorporates -the limitation as if written in the body of this License. - - 9. The Free Software Foundation may publish revised and/or new versions -of the General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - -Each version is given a distinguishing version number. If the Program -specifies a version number of this License which applies to it and "any -later version", you have the option of following the terms and conditions -either of that version or of any later version published by the Free -Software Foundation. If the Program does not specify a version number of -this License, you may choose any version ever published by the Free Software -Foundation. - - 10. If you wish to incorporate parts of the Program into other free -programs whose distribution conditions are different, write to the author -to ask for permission. For software which is copyrighted by the Free -Software Foundation, write to the Free Software Foundation; we sometimes -make exceptions for this. Our decision will be guided by the two goals -of preserving the free status of all derivatives of our free software and -of promoting the sharing and reuse of software generally. - - NO WARRANTY - - 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY -FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN -OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES -PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED -OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS -TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE -PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, -REPAIR OR CORRECTION. - - 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR -REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, -INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING -OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED -TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY -YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER -PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE -POSSIBILITY OF SUCH DAMAGES. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -convey the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - A discord.js wrapper to make easier to use discord.js - Copyright (C) 2022 Sern. - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License along - with this program; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -Also add information on how to contact you by electronic and paper mail. - -If the program is interactive, make it output a short notice like this -when it starts in an interactive mode: - - Gnomovision version 69, Copyright (C) year name of author - Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, the commands you use may -be called something other than `show w' and `show c'; they could even be -mouse-clicks or menu items--whatever suits your program. - -You should also get your employer (if you work as a programmer) or your -school, if any, to sign a "copyright disclaimer" for the program, if -necessary. Here is a sample; alter the names: - - Yoyodyne, Inc., hereby disclaims all copyright interest in the program - `Gnomovision' (which makes passes at compilers) written by James Hacker. - - , 1 April 1989 - Ty Coon, President of Vice - -This General Public License does not permit incorporating your program into -proprietary programs. If your program is a subroutine library, you may -consider it more useful to permit linking proprietary applications with the -library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. +End license text. From ff9a73b78ca5c94b2c9efacf343c574af1d11b54 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 11:42:18 +0300 Subject: [PATCH 113/128] Delete LICENSE.md --- LICENSE.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 72d26a38..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -Copyright (C) 2022 Sern - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -End license text. From 67a6abe1359d65b81e01b25bf77c1f94437d07ac Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 11:45:39 +0300 Subject: [PATCH 114/128] chore: Recreated LICENSE --- LICENSE.md | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..18f6a203 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,9 @@ +**Copyright (C) 2022 Sern** + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +End license text. From 6a302c955d9cc160c2b8dbfa0654222111ea9dab Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 14:16:15 +0300 Subject: [PATCH 115/128] chore: First License boilerplate preview --- src/index.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/index.ts b/src/index.ts index 4fd70b99..7abe408d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,10 @@ +/* + * Batteries-included, yet powerful discord.is framework + * Copyright (C) 2021 Xx-Mohit-xX + * This software is licensed under MIT LICENSE + * For more information, see README.md and LICENSE.md +*/ + export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; From cc1a5b490344bd88889517f03df5f735f4a19f34 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 14:18:10 +0300 Subject: [PATCH 116/128] style(index.ts): Added a space --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 7abe408d..0b03e6f3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ * Copyright (C) 2021 Xx-Mohit-xX * This software is licensed under MIT LICENSE * For more information, see README.md and LICENSE.md -*/ + */ export * as Sern from './handler/sern'; export * from './types/handler'; From 492f2b8b21f8386655b7eabb359403ce42d76351 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 14:36:03 +0300 Subject: [PATCH 117/128] chore(index.ts): First license boilerplate preview --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 0b03e6f3..7a0dd753 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,6 +1,6 @@ /* * Batteries-included, yet powerful discord.is framework - * Copyright (C) 2021 Xx-Mohit-xX + * Copyright (C) 2022 Sern * This software is licensed under MIT LICENSE * For more information, see README.md and LICENSE.md */ From 8b1ede8606a21a052f9d367c39c8f3d7865439cd Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 10 May 2022 17:36:59 +0300 Subject: [PATCH 118/128] chore(SECURITY): Updated security.md file --- .github/SECURITY.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/SECURITY.md b/.github/SECURITY.md index 8081eaec..45d71847 100644 --- a/.github/SECURITY.md +++ b/.github/SECURITY.md @@ -2,12 +2,14 @@ ## Supported Versions -Project is currently in development and is not yet ready to be used. +Project is currently under heavy development but you can try out our [npm package](https://npmjs.com/package/@sern/handler) | Version | Supported | | ------- | ------------------ | | 0.1.0 @ dev | :white_check_mark: | +* Dev versions might include bugs, use it with your own risk. + ## Reporting a Vulnerability You can report a vulnerability by opening an issue on the [project's GitHub](https://github.com/SernHandler/Sern/issues) repository. From 85fb1e62e4705b6552f35a00431efae2ebc7c1ff Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Sun, 15 May 2022 18:30:25 +0300 Subject: [PATCH 119/128] style: Updated license boilerplate --- src/index.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/index.ts b/src/index.ts index 7a0dd753..5fd8db22 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,12 @@ -/* - * Batteries-included, yet powerful discord.is framework - * Copyright (C) 2022 Sern - * This software is licensed under MIT LICENSE - * For more information, see README.md and LICENSE.md +/* + * --------------------------------------------------------------------- + * Copyright (C) 2022 Sern + * This software is licensed under the MIT License. + * See LICENSE.md in the project root for license information. + * --------------------------------------------------------------------- */ + export * as Sern from './handler/sern'; export * from './types/handler'; export * from './handler/structures/structxports'; From 991439c2594c071782d442795e411a638d1b3673 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Mon, 16 May 2022 09:21:46 +0300 Subject: [PATCH 120/128] docs(README): Added stats --- README.md | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 7da71a37..6292eb05 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,11 @@ exports.default = { }; ``` -See [documentation](https://sern-handler.js.org) for TypeScript examples and more +See our [templates](https://github.com/sern-handler/templates) for TypeScript examples and more + +## CLI + +We are providing a [command line interface](https://github.com/sern-handler/cli) for better & easier bot developement. Don't forget to view it. ## Links @@ -76,4 +80,4 @@ See [documentation](https://sern-handler.js.org) for TypeScript examples and mor ## Roadmap -You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or patched in the future. \ No newline at end of file +You can check our [roadmap](https://github.com/sern-handler/roadmap) to see what's going to be added or patched in the future. From 2bd5196b833a7255e7c91f4ffc66edd7939f3f3c Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 10:39:19 +0300 Subject: [PATCH 121/128] chore: Updated CONTRIBUTING.md file --- .github/CONTRIBUTING.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 685cb74c..8e8bdaee 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -30,7 +30,7 @@ threatening, offensive, or harmful. ### Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at [INSERT EMAIL ADDRESS]. All +reported by contacting the project team at our [discord server](https://discord.com/invite/QgnfxWzrcj). All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. @@ -42,8 +42,8 @@ members of the project's leadership. ### Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +This contributing guidelines is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] [homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file +[version]: http://contributor-covenant.org/version/1/4/ From 3f597ff26ea7b73e6785a85f940a7fa64eb44f3a Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 12:44:57 +0300 Subject: [PATCH 122/128] chore: Updated credits --- src/types/handler.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/types/handler.ts b/src/types/handler.ts index e14f8f06..7791c380 100644 --- a/src/types/handler.ts +++ b/src/types/handler.ts @@ -1,7 +1,8 @@ import type { Awaitable, ClientEvents, CommandInteractionOptionResolver } from 'discord.js'; import type { EventEmitter } from 'events'; export type Nullish = T | undefined | null; -// Thanks @cursorsdottsx + +// Thanks to @kelsny export type ParseType = { [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never; }[keyof T]; @@ -19,7 +20,7 @@ export type EventEmitterRegister = [ export type SlashOptions = Omit; -//https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l +// Source: https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l export type Override = Omit & T2; export type DefinitelyDefined = T & Override; From a8aeff3d83ec8f8a7d75a25c9e4e6ad05c504813 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 16:37:35 +0300 Subject: [PATCH 123/128] chore(NPM): Prepared package.json for release --- package.json | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 6577aece..9572ee32 100644 --- a/package.json +++ b/package.json @@ -1,21 +1,28 @@ { "name": "@sern/handler", - "version": "0.0.1", - "description": "", + "version": "1.0.0-beta", + "description": "A customizable, batteries-included, powerful discord.js framework to automate and streamline bot development.", "main": "dist/index.js", - "scripts": { + "scripts": { "compile": "tsc", "watch": "tsc -w", "lint": "eslint src/**/*.ts", "format": "eslint src/**/*.ts --fix", "release": "standard-version && git push --follow-tags", "test": "jest --coverage --verbose", - "commit": "cz", - "docs": "typedoc src/index.ts --out .typedoc" + "commit": "cz" }, - "keywords": [], - "author": "", - "license": "ISC", + "keywords": [ + "sern-handler", + "sern", + "handler", + "sern handler", + "wrapper", + "discord.js", + "framework" + ], + "author": "SernDevs", + "license": "MIT", "dependencies": { "discord.js": "^14.0.0-dev.1647259751.2297c2b", "rxjs": "^7.5.5", From d8ce09fd4cdc0b6f500148736bc0f5005f5cd09c Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 18:17:42 +0300 Subject: [PATCH 124/128] revert: Some changes --- LICENSE.md | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md deleted file mode 100644 index 18f6a203..00000000 --- a/LICENSE.md +++ /dev/null @@ -1,9 +0,0 @@ -**Copyright (C) 2022 Sern** - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - -End license text. From b3be79d1c1c97c49988a1d44e4e8aa68c1bc87e1 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Tue, 17 May 2022 18:23:06 +0300 Subject: [PATCH 125/128] revert: Revert back to MIT LICENSE (#50) --- LICENSE.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 LICENSE.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 00000000..a668bd1c --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,23 @@ +MIT License + +**Copyright (c) 2022 Sern** + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +End license text. From b7872e7d5a7e57f233ff71383338d4f672dc8952 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 18 May 2022 17:00:57 +0300 Subject: [PATCH 126/128] fix(CODE_OF_CONDUCT): Removed unusual dot --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 9aa60006..102875c8 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,5 +1,5 @@ # Code of Conduct -All participants of SernHandler. are expected to abide by our Code of Conduct, both online and during in-person events that are hosted and/or associated with SernHandler. +All participants of SernHandler are expected to abide by our Code of Conduct, both online and during in-person events that are hosted and/or associated with SernHandler. # The Pledge In the interest of fostering an open and welcoming environment, we pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. From dc4ed8d59b762e97185dd4c76c7d315050c6b475 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 18 May 2022 19:11:47 +0300 Subject: [PATCH 127/128] fix: Resolve conflicts --- .gitignore | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 5c1ee6c2..17a25890 100644 --- a/.gitignore +++ b/.gitignore @@ -79,7 +79,8 @@ typings/ # TypeScript build output dist -# VisualStudio config file +# VisualStudio Config file .vs -.idea \ No newline at end of file +# IntelliJ IDEA Config file +.idea/ \ No newline at end of file From 34c0d9944890d1ad14d96b88d5a513173d689b21 Mon Sep 17 00:00:00 2001 From: xxDeveloper <77380166+Murtatrxx@users.noreply.github.com> Date: Wed, 18 May 2022 19:12:17 +0300 Subject: [PATCH 128/128] fix: Resolve conflicts --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 17a25890..f208b310 100644 --- a/.gitignore +++ b/.gitignore @@ -83,4 +83,4 @@ dist .vs # IntelliJ IDEA Config file -.idea/ \ No newline at end of file +.idea/