From 57dc0bac885e0d066f517026e20198572ca2e693 Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Sat, 7 May 2022 21:07:10 -0500 Subject: [PATCH] build : Added ts-pattern for pattern matching with command types and plugin types --- package-lock.json | 15 +++++++++++++-- package.json | 3 ++- src/handler/events/interactionCreate.ts | 5 ++--- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/package-lock.json b/package-lock.json index bd92654..a629ce9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@sern/handler", - "version": "0.1.0", + "version": "0.0.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@sern/handler", - "version": "0.1.0", + "version": "0.0.1", "license": "ISC", "dependencies": { "@typescript-eslint/eslint-plugin": "^5.10.2", @@ -15,6 +15,7 @@ "eslint": "^8.8.0", "prettier": "^2.5.1", "rxjs": "^7.5.5", + "ts-pattern": "^4.0.2", "ts-results": "^3.3.0" }, "devDependencies": { @@ -8418,6 +8419,11 @@ } } }, + "node_modules/ts-pattern": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-4.0.2.tgz", + "integrity": "sha512-eHqR/7A6fcw05vCOfnL6RwgGJbVi9G/YHTdYdjYmElhDdJ1SMn7pWs+6+YuxygaFwQS/g+cIDlu+UD8IVpur1A==" + }, "node_modules/ts-results": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/ts-results/-/ts-results-3.3.0.tgz", @@ -15236,6 +15242,11 @@ "yn": "3.1.1" } }, + "ts-pattern": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/ts-pattern/-/ts-pattern-4.0.2.tgz", + "integrity": "sha512-eHqR/7A6fcw05vCOfnL6RwgGJbVi9G/YHTdYdjYmElhDdJ1SMn7pWs+6+YuxygaFwQS/g+cIDlu+UD8IVpur1A==" + }, "ts-results": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/ts-results/-/ts-results-3.3.0.tgz", diff --git a/package.json b/package.json index 12627d8..9e861b6 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", @@ -23,6 +23,7 @@ "eslint": "^8.8.0", "prettier": "^2.5.1", "rxjs": "^7.5.5", + "ts-pattern": "^4.0.2", "ts-results": "^3.3.0" }, "devDependencies": { diff --git a/src/handler/events/interactionCreate.ts b/src/handler/events/interactionCreate.ts index 871f5a8..610f8c6 100644 --- a/src/handler/events/interactionCreate.ts +++ b/src/handler/events/interactionCreate.ts @@ -3,6 +3,8 @@ import { ApplicationCommandType, Interaction } from 'discord.js'; import { fromEvent, Observable, of, concatMap, map, filter } from 'rxjs'; import { CommandType } from '../sern'; import Context from '../structures/context'; +import type { ModuleDefs } from '../structures/modules/commands/moduleHandler'; +import type { PluggedModule } from '../structures/modules/module'; import type Wrapper from '../structures/wrapper'; import * as Files from '../utilities/readFile'; import { match, partition } from './observableHandling'; @@ -16,9 +18,6 @@ export const onInteractionCreate = ( wrapper : Wrapper ) => { const interactionEvent$ = (> fromEvent(client, 'interactionCreate')) - const processPlugins = ( plug : Observable ) => { - return plug - }; const processCommand$ = interactionEvent$.pipe( concatMap( interaction => {