From 05b4080ac5dbeb11e5b5d858cdedeb13867c2c1c Mon Sep 17 00:00:00 2001 From: DJj123dj <80536295+DJj123dj@users.noreply.github.com> Date: Wed, 25 Dec 2024 18:20:58 +0100 Subject: [PATCH] Plugins can now use import path shortcuts Plugins are now able to use import path shortcuts to import all API classes, utilities and the openticket globals. You can now import everything from "#opendiscord" instead of "../../src/index" --- package.json | 8 ++++++-- plugins/example-plugin/index.ts | 4 ++-- tsconfig.json | 5 +---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 8e2a1dd..88c5943 100644 --- a/package.json +++ b/package.json @@ -35,5 +35,9 @@ "url": "https://github.com/DJj123dj/open-ticket/issues", "email": "support@dj-dj.be" }, - "homepage": "https://openticket.dj-dj.be" -} + "homepage": "https://openticket.dj-dj.be", + "imports": { + "#opendiscord":"./dist/src/index.js", + "#opendiscord-types":"./dist/src/core/api/api.js" + } +} \ No newline at end of file diff --git a/plugins/example-plugin/index.ts b/plugins/example-plugin/index.ts index ec70562..fce3aac 100644 --- a/plugins/example-plugin/index.ts +++ b/plugins/example-plugin/index.ts @@ -1,4 +1,4 @@ -import {api, openticket, utilities} from "../../src/index" +import {api, openticket, utilities} from "#opendiscord" import * as discord from "discord.js" ///////////////////////////////////////////// @@ -9,7 +9,7 @@ import * as discord from "discord.js" if (utilities.project != "openticket") throw new api.ODPluginError("This plugin only works in Open Ticket!") //Add Typescript autocomplete support for plugin data. (!!!OPTIONAL!!!) -declare module "../../src/core/api/api.js" { +declare module "#opendiscord-types" { export interface ODConfigManagerIds_Default { "example-plugin:config":api.ODJsonConfig } diff --git a/tsconfig.json b/tsconfig.json index 50bcbcf..95a1996 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,10 +1,7 @@ { "compilerOptions": { "target": "ES2022", - "rootDirs":[ - "./src", - "./plugins" - ], + "rootDir":"./", "outDir": "./dist/", "module": "NodeNext", "moduleResolution": "NodeNext",