From 50288867a5b171511941a1be3877d721694e9f77 Mon Sep 17 00:00:00 2001
From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com>
Date: Wed, 28 Sep 2022 11:52:25 -0500
Subject: [PATCH] feat: classmodules@arcs (#143)
* feat: add class based commands
* docs: add deprecation warnings
* feat: add deprecation warnings
* feat: add more deprecation warnings
* feat: add prototype ClassModule abstract class
* feat: add EventModuleClass prototype, change names
* feat: more flexible contract
* feat: EventExecutable
* fix: typo
* feat: made abstract classes because of defaults
* fix: typings
* feat: update Context typings, update to djs v15
* chore: update typescript dependency
* chore: bump version
* chore: update ignore
* chore: prettier
* docs: change readme to be docusaurus compliant
---
.prettierignore | 3 +-
README.md | 12 +-
package-lock.json | 302 ++++++++++++++++++++----------
package.json | 6 +-
src/handler/sern.ts | 25 ++-
src/handler/structures/context.ts | 10 +-
src/handler/structures/wrapper.ts | 4 +
src/handler/utilities/readFile.ts | 10 +-
src/index.ts | 2 +-
src/types/handler.ts | 12 +-
10 files changed, 260 insertions(+), 126 deletions(-)
diff --git a/.prettierignore b/.prettierignore
index a8862f3b..259019cf 100644
--- a/.prettierignore
+++ b/.prettierignore
@@ -1,2 +1,3 @@
.github/
-*.md
\ No newline at end of file
+*.md
+dist/
\ No newline at end of file
diff --git a/README.md b/README.md
index c3a6fadf..60e4463c 100644
--- a/README.md
+++ b/README.md
@@ -1,17 +1,17 @@
-
+
diff --git a/package-lock.json b/package-lock.json
index 34c05be9..9b273812 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -19,10 +19,10 @@
"eslint": "8.22.0",
"prettier": "2.7.1",
"tsup": "^6.1.3",
- "typescript": "4.7.4"
+ "typescript": "^4.8.3"
},
"peerDependencies": {
- "discord.js": "^14.2.x"
+ "discord.js": "^14.5.x"
}
},
"node_modules/@discordjs/builders": {
@@ -51,18 +51,18 @@
}
},
"node_modules/@discordjs/rest": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.1.0.tgz",
- "integrity": "sha512-yCrthRTQeUyNThQEpCk7bvQJlwQmz6kU0tf3dcWBv2WX3Bncl41x7Wc+v5b5OsIxfNYq38PvVtWircu9jtYZug==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.2.0.tgz",
+ "integrity": "sha512-WX79uzMdnBzFNgsDdA440Ia2q7SMk6F8bNaPMmV4i6qcUNJpg+Sgb2spKuQmQPlNTX4HCntR609xHqUkK1tnVQ==",
"peer": true,
"dependencies": {
- "@discordjs/collection": "^1.0.1",
+ "@discordjs/collection": "^1.1.0",
"@sapphire/async-queue": "^1.5.0",
"@sapphire/snowflake": "^3.2.2",
- "discord-api-types": "^0.37.3",
- "file-type": "^17.1.6",
+ "discord-api-types": "^0.37.10",
+ "file-type": "^18.0.0",
"tslib": "^2.4.0",
- "undici": "^5.9.1"
+ "undici": "^5.10.0"
},
"engines": {
"node": ">=16.9.0"
@@ -266,6 +266,27 @@
}
}
},
+ "node_modules/@typescript-eslint/eslint-plugin/node_modules/tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "node_modules/@typescript-eslint/eslint-plugin/node_modules/tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "dependencies": {
+ "tslib": "^1.8.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ },
+ "peerDependencies": {
+ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
+ }
+ },
"node_modules/@typescript-eslint/parser": {
"version": "5.36.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-5.36.2.tgz",
@@ -424,6 +445,27 @@
}
}
},
+ "node_modules/@typescript-eslint/type-utils/node_modules/tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "node_modules/@typescript-eslint/type-utils/node_modules/tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "dependencies": {
+ "tslib": "^1.8.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ },
+ "peerDependencies": {
+ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
+ }
+ },
"node_modules/@typescript-eslint/types": {
"version": "5.36.2",
"resolved": "https://registry.npmjs.org/@typescript-eslint/types/-/types-5.36.2.tgz",
@@ -481,6 +523,27 @@
"url": "https://opencollective.com/typescript-eslint"
}
},
+ "node_modules/@typescript-eslint/typescript-estree/node_modules/tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "node_modules/@typescript-eslint/typescript-estree/node_modules/tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "dependencies": {
+ "tslib": "^1.8.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ },
+ "peerDependencies": {
+ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
+ }
+ },
"node_modules/@typescript-eslint/utils": {
"version": "5.36.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/utils/-/utils-5.36.1.tgz",
@@ -545,6 +608,27 @@
}
}
},
+ "node_modules/@typescript-eslint/utils/node_modules/tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "node_modules/@typescript-eslint/utils/node_modules/tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "dependencies": {
+ "tslib": "^1.8.1"
+ },
+ "engines": {
+ "node": ">= 6"
+ },
+ "peerDependencies": {
+ "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
+ }
+ },
"node_modules/@typescript-eslint/visitor-keys": {
"version": "5.36.1",
"resolved": "https://registry.npmjs.org/@typescript-eslint/visitor-keys/-/visitor-keys-5.36.1.tgz",
@@ -878,28 +962,28 @@
}
},
"node_modules/discord-api-types": {
- "version": "0.37.8",
- "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.8.tgz",
- "integrity": "sha512-uhol9KQ2moExZItMpuDMkf0R7sqqNHqcJBFN7S5iSdXBVCMRO7sC0GoyuRrv6ZDBYxoFU6nDy4dv0nld/aysqA==",
+ "version": "0.37.10",
+ "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.10.tgz",
+ "integrity": "sha512-NvDh2Puc3wZQzQt2zLavlI5ewBnLFjI46/NJmvWIs6OC0JOkq7KcmH4s80X2+22mSQ3wUyge2mxq3cGYRT2noQ==",
"peer": true
},
"node_modules/discord.js": {
- "version": "14.3.0",
- "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.3.0.tgz",
- "integrity": "sha512-CpIwoAAuELiHSgVKRMzsCADS6ZlJwAZ9RlvcJYdEgS00aW36dSvXyBgE+S3pigkc7G+jU6BEalMUWIJFveqrBQ==",
+ "version": "14.5.0",
+ "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.5.0.tgz",
+ "integrity": "sha512-Kd5OqdeiXe3t9eHUHCzf1r3LmKpeJJ7lKqwlWX1qdC0WfsbO2K3kucIDLfe0INnZVZaErUQ6/U6kGbTDnGgwZg==",
"peer": true,
"dependencies": {
"@discordjs/builders": "^1.2.0",
"@discordjs/collection": "^1.1.0",
- "@discordjs/rest": "^1.1.0",
+ "@discordjs/rest": "^1.2.0",
"@sapphire/snowflake": "^3.2.2",
"@types/ws": "^8.5.3",
- "discord-api-types": "^0.37.3",
+ "discord-api-types": "^0.37.10",
"fast-deep-equal": "^3.1.3",
"lodash.snakecase": "^4.1.1",
"tslib": "^2.4.0",
- "undici": "^5.9.1",
- "ws": "^8.8.1"
+ "undici": "^5.10.0",
+ "ws": "^8.9.0"
},
"engines": {
"node": ">=16.9.0"
@@ -1579,17 +1663,17 @@
}
},
"node_modules/file-type": {
- "version": "17.1.6",
- "resolved": "https://registry.npmjs.org/file-type/-/file-type-17.1.6.tgz",
- "integrity": "sha512-hlDw5Ev+9e883s0pwUsuuYNu4tD7GgpUnOvykjv1Gya0ZIjuKumthDRua90VUn6/nlRKAjcxLUnHNTIUWwWIiw==",
+ "version": "18.0.0",
+ "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.0.0.tgz",
+ "integrity": "sha512-jjMwFpnW8PKofLE/4ohlhqwDk5k0NC6iy0UHAJFKoY1fQeGMN0GDdLgHQrvCbSpMwbqzoCZhRI5dETCZna5qVA==",
"peer": true,
"dependencies": {
"readable-web-to-node-stream": "^3.0.2",
- "strtok3": "^7.0.0-alpha.9",
- "token-types": "^5.0.0-alpha.2"
+ "strtok3": "^7.0.0",
+ "token-types": "^5.0.1"
},
"engines": {
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
+ "node": ">=14.16"
},
"funding": {
"url": "https://github.com/sindresorhus/file-type?sponsor=1"
@@ -2842,27 +2926,6 @@
"node": ">=8"
}
},
- "node_modules/tsutils": {
- "version": "3.21.0",
- "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
- "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
- "dev": true,
- "dependencies": {
- "tslib": "^1.8.1"
- },
- "engines": {
- "node": ">= 6"
- },
- "peerDependencies": {
- "typescript": ">=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta"
- }
- },
- "node_modules/tsutils/node_modules/tslib": {
- "version": "1.14.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
- "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
- "dev": true
- },
"node_modules/type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -2888,9 +2951,9 @@
}
},
"node_modules/typescript": {
- "version": "4.7.4",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
- "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
+ "version": "4.8.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
+ "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true,
"bin": {
"tsc": "bin/tsc",
@@ -2978,9 +3041,9 @@
"dev": true
},
"node_modules/ws": {
- "version": "8.8.1",
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz",
- "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==",
+ "version": "8.9.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz",
+ "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==",
"peer": true,
"engines": {
"node": ">=10.0.0"
@@ -3047,18 +3110,18 @@
"peer": true
},
"@discordjs/rest": {
- "version": "1.1.0",
- "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.1.0.tgz",
- "integrity": "sha512-yCrthRTQeUyNThQEpCk7bvQJlwQmz6kU0tf3dcWBv2WX3Bncl41x7Wc+v5b5OsIxfNYq38PvVtWircu9jtYZug==",
+ "version": "1.2.0",
+ "resolved": "https://registry.npmjs.org/@discordjs/rest/-/rest-1.2.0.tgz",
+ "integrity": "sha512-WX79uzMdnBzFNgsDdA440Ia2q7SMk6F8bNaPMmV4i6qcUNJpg+Sgb2spKuQmQPlNTX4HCntR609xHqUkK1tnVQ==",
"peer": true,
"requires": {
- "@discordjs/collection": "^1.0.1",
+ "@discordjs/collection": "^1.1.0",
"@sapphire/async-queue": "^1.5.0",
"@sapphire/snowflake": "^3.2.2",
- "discord-api-types": "^0.37.3",
- "file-type": "^17.1.6",
+ "discord-api-types": "^0.37.10",
+ "file-type": "^18.0.0",
"tslib": "^2.4.0",
- "undici": "^5.9.1"
+ "undici": "^5.10.0"
}
},
"@esbuild/linux-loong64": {
@@ -3198,6 +3261,23 @@
"regexpp": "^3.2.0",
"semver": "^7.3.7",
"tsutils": "^3.21.0"
+ },
+ "dependencies": {
+ "tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "requires": {
+ "tslib": "^1.8.1"
+ }
+ }
}
},
"@typescript-eslint/parser": {
@@ -3284,6 +3364,21 @@
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
+ },
+ "tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "requires": {
+ "tslib": "^1.8.1"
+ }
}
}
},
@@ -3317,6 +3412,21 @@
"@typescript-eslint/types": "5.36.2",
"eslint-visitor-keys": "^3.3.0"
}
+ },
+ "tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "requires": {
+ "tslib": "^1.8.1"
+ }
}
}
},
@@ -3354,6 +3464,21 @@
"semver": "^7.3.7",
"tsutils": "^3.21.0"
}
+ },
+ "tslib": {
+ "version": "1.14.1",
+ "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
+ "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
+ "dev": true
+ },
+ "tsutils": {
+ "version": "3.21.0",
+ "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
+ "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
+ "dev": true,
+ "requires": {
+ "tslib": "^1.8.1"
+ }
}
}
},
@@ -3595,28 +3720,28 @@
}
},
"discord-api-types": {
- "version": "0.37.8",
- "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.8.tgz",
- "integrity": "sha512-uhol9KQ2moExZItMpuDMkf0R7sqqNHqcJBFN7S5iSdXBVCMRO7sC0GoyuRrv6ZDBYxoFU6nDy4dv0nld/aysqA==",
+ "version": "0.37.10",
+ "resolved": "https://registry.npmjs.org/discord-api-types/-/discord-api-types-0.37.10.tgz",
+ "integrity": "sha512-NvDh2Puc3wZQzQt2zLavlI5ewBnLFjI46/NJmvWIs6OC0JOkq7KcmH4s80X2+22mSQ3wUyge2mxq3cGYRT2noQ==",
"peer": true
},
"discord.js": {
- "version": "14.3.0",
- "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.3.0.tgz",
- "integrity": "sha512-CpIwoAAuELiHSgVKRMzsCADS6ZlJwAZ9RlvcJYdEgS00aW36dSvXyBgE+S3pigkc7G+jU6BEalMUWIJFveqrBQ==",
+ "version": "14.5.0",
+ "resolved": "https://registry.npmjs.org/discord.js/-/discord.js-14.5.0.tgz",
+ "integrity": "sha512-Kd5OqdeiXe3t9eHUHCzf1r3LmKpeJJ7lKqwlWX1qdC0WfsbO2K3kucIDLfe0INnZVZaErUQ6/U6kGbTDnGgwZg==",
"peer": true,
"requires": {
"@discordjs/builders": "^1.2.0",
"@discordjs/collection": "^1.1.0",
- "@discordjs/rest": "^1.1.0",
+ "@discordjs/rest": "^1.2.0",
"@sapphire/snowflake": "^3.2.2",
"@types/ws": "^8.5.3",
- "discord-api-types": "^0.37.3",
+ "discord-api-types": "^0.37.10",
"fast-deep-equal": "^3.1.3",
"lodash.snakecase": "^4.1.1",
"tslib": "^2.4.0",
- "undici": "^5.9.1",
- "ws": "^8.8.1"
+ "undici": "^5.10.0",
+ "ws": "^8.9.0"
}
},
"doctrine": {
@@ -4035,14 +4160,14 @@
}
},
"file-type": {
- "version": "17.1.6",
- "resolved": "https://registry.npmjs.org/file-type/-/file-type-17.1.6.tgz",
- "integrity": "sha512-hlDw5Ev+9e883s0pwUsuuYNu4tD7GgpUnOvykjv1Gya0ZIjuKumthDRua90VUn6/nlRKAjcxLUnHNTIUWwWIiw==",
+ "version": "18.0.0",
+ "resolved": "https://registry.npmjs.org/file-type/-/file-type-18.0.0.tgz",
+ "integrity": "sha512-jjMwFpnW8PKofLE/4ohlhqwDk5k0NC6iy0UHAJFKoY1fQeGMN0GDdLgHQrvCbSpMwbqzoCZhRI5dETCZna5qVA==",
"peer": true,
"requires": {
"readable-web-to-node-stream": "^3.0.2",
- "strtok3": "^7.0.0-alpha.9",
- "token-types": "^5.0.0-alpha.2"
+ "strtok3": "^7.0.0",
+ "token-types": "^5.0.1"
}
},
"fill-range": {
@@ -4894,23 +5019,6 @@
}
}
},
- "tsutils": {
- "version": "3.21.0",
- "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-3.21.0.tgz",
- "integrity": "sha512-mHKK3iUXL+3UF6xL5k0PEhKRUBKPBCv/+RkEOpjRWxxx27KKRBmmA60A9pgOUvMi8GKhRMPEmjBRPzs2W7O1OA==",
- "dev": true,
- "requires": {
- "tslib": "^1.8.1"
- },
- "dependencies": {
- "tslib": {
- "version": "1.14.1",
- "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz",
- "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==",
- "dev": true
- }
- }
- },
"type-check": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz",
@@ -4927,9 +5035,9 @@
"dev": true
},
"typescript": {
- "version": "4.7.4",
- "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.7.4.tgz",
- "integrity": "sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ==",
+ "version": "4.8.3",
+ "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.8.3.tgz",
+ "integrity": "sha512-goMHfm00nWPa8UvR/CPSvykqf6dVV8x/dp0c5mFTMTIu0u0FlGWRioyy7Nn0PGAdHxpJZnuO/ut+PpQ8UiHAig==",
"dev": true
},
"undici": {
@@ -4998,9 +5106,9 @@
"dev": true
},
"ws": {
- "version": "8.8.1",
- "resolved": "https://registry.npmjs.org/ws/-/ws-8.8.1.tgz",
- "integrity": "sha512-bGy2JzvzkPowEJV++hF07hAD6niYSr0JzBNo/J29WsB57A2r7Wlc1UFcTR9IzrPvuNVO4B8LGqF8qcpsVOhJCA==",
+ "version": "8.9.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-8.9.0.tgz",
+ "integrity": "sha512-Ja7nszREasGaYUYCI2k4lCKIRTt+y7XuqVoHR44YpI49TtryyqbqvDMn5eqfW7e6HzTukDRIsXqzVHScqRcafg==",
"peer": true,
"requires": {}
},
diff --git a/package.json b/package.json
index 14a91ecf..194d757b 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@sern/handler",
- "version": "1.1.0",
+ "version": "1.2.0",
"description": "A customizable, batteries-included, powerful discord.js framework to automate and streamline bot development.",
"main": "dist/cjs/index.cjs",
"module": "dist/esm/index.mjs",
@@ -41,10 +41,10 @@
"eslint": "8.22.0",
"prettier": "2.7.1",
"tsup": "^6.1.3",
- "typescript": "4.7.4"
+ "typescript": "^4.8.3"
},
"peerDependencies": {
- "discord.js": "^14.2.x"
+ "discord.js": "^14.5.x"
},
"repository": {
"type": "git",
diff --git a/src/handler/sern.ts b/src/handler/sern.ts
index 71b20037..9c8c201e 100644
--- a/src/handler/sern.ts
+++ b/src/handler/sern.ts
@@ -3,8 +3,13 @@ import { Err, Ok } from 'ts-results-es';
import { ExternalEventEmitters } from './utilities/readFile';
import type { EventEmitter } from 'events';
import { processEvents } from './events/userDefinedEventsHandling';
-import type { CommandModule, EventModule } from './structures/module';
-import { EventType, PluginType } from './structures/enums';
+import type {
+ CommandModule,
+ CommandModuleDefs,
+ EventModule,
+ EventModuleDefs,
+} from './structures/module';
+import { CommandType, EventType, PluginType } from './structures/enums';
import type {
CommandPlugin,
EventModuleCommandPluginDefs,
@@ -42,7 +47,7 @@ export function init(wrapper: Wrapper) {
}
/**
- *
+ * @deprecated - use Sern#makeDependencies instead
* @param emitter Any external event emitter.
* The object will be stored in a map, and then fetched by the name of the instance's class.
* As there are infinite possibilities to adding external event emitters,
@@ -119,3 +124,17 @@ export function eventModule(mod: InputEventModule): EventModule {
plugins,
} as EventModule;
}
+
+export abstract class CommandExecutable
{
+ abstract type: Type;
+ plugins: CommandPlugin[] = [];
+ onEvent: EventPlugin[] = [];
+ abstract execute: CommandModuleDefs[Type]['execute'];
+}
+
+export abstract class EventExecutable {
+ abstract type: Type;
+ plugins: EventModuleCommandPluginDefs[Type][] = [];
+ onEvent: EventModuleEventPluginDefs[Type][] = [];
+ abstract execute: EventModuleDefs[Type]['execute'];
+}
diff --git a/src/handler/structures/context.ts b/src/handler/structures/context.ts
index 6d3987cf..9513af22 100644
--- a/src/handler/structures/context.ts
+++ b/src/handler/structures/context.ts
@@ -6,13 +6,13 @@ import type {
GuildMember,
InteractionReplyOptions,
Message,
- ReplyMessageOptions,
Snowflake,
TextBasedChannel,
+ MessageReplyOptions,
User,
} from 'discord.js';
import { type Option, None, Some } from 'ts-results-es';
-import type { Nullish } from '../../types/handler';
+import type { Nullish, ReplyOptions } from '../../types/handler';
import { SernError } from './errors';
function firstSome(...args: Option[]): Nullish {
@@ -130,9 +130,7 @@ export default class Context {
return this.oMsg.none && this.oInterac.none;
}
//Make queueable
- public reply(
- content: string | Omit | ReplyMessageOptions,
- ) {
+ public reply(content: ReplyOptions) {
return firstSome(
this.oInterac.map(i => {
return i
@@ -140,7 +138,7 @@ export default class Context {
.then(() => i.fetchReply());
}),
this.oMsg.map(m => {
- return m.reply(content as string | ReplyMessageOptions);
+ return m.reply(content as string | MessageReplyOptions);
}),
)!;
}
diff --git a/src/handler/structures/wrapper.ts b/src/handler/structures/wrapper.ts
index 73009057..60301070 100644
--- a/src/handler/structures/wrapper.ts
+++ b/src/handler/structures/wrapper.ts
@@ -7,13 +7,17 @@ import type { EventModule } from './module';
* @typedef {object} Wrapper
*/
interface Wrapper {
+ //@deprecated - Use Sern#makeDependencies instead
readonly client: Client;
+ //@deprecated - Use Sern#makeDependencies instead
readonly sernEmitter?: SernEmitter;
readonly defaultPrefix?: string;
readonly commands: string;
readonly events?:
| string
+ //@deprecated - array and function options will be removed
| { mod: EventModule; absPath: string }[]
+ //@deprecated - array and function options will be removed
| (() => { mod: EventModule; absPath: string }[]);
}
diff --git a/src/handler/utilities/readFile.ts b/src/handler/utilities/readFile.ts
index 1f12eeef..ea25ab36 100644
--- a/src/handler/utilities/readFile.ts
+++ b/src/handler/utilities/readFile.ts
@@ -73,9 +73,13 @@ export function buildData(commandDir: string): Observable<
} catch {
mod = (await import(`file:///` + absPath)).default;
}
- if (mod !== undefined) {
- return Ok({ mod, absPath });
- } else return Err(SernError.UndefinedModule);
+ if (mod === undefined) {
+ return Err(SernError.UndefinedModule);
+ }
+ try {
+ mod = new (mod as unknown as new () => T)();
+ } catch {}
+ return Ok({ mod, absPath });
}),
),
).pipe(concatAll());
diff --git a/src/index.ts b/src/index.ts
index 8adcc3a2..1fa49c4b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,5 +1,5 @@
import SernEmitter from './handler/sernEmitter';
-export { eventModule, commandModule } from './handler/sern';
+export { eventModule, commandModule, EventExecutable, CommandExecutable } from './handler/sern';
export * as Sern from './handler/sern';
export * from './types/handler';
export * from './handler/structures/structxports';
diff --git a/src/types/handler.ts b/src/types/handler.ts
index 3c4cb131..46fd9544 100644
--- a/src/types/handler.ts
+++ b/src/types/handler.ts
@@ -1,6 +1,7 @@
import type { CommandInteractionOptionResolver } from 'discord.js';
import type { CommandModule, EventModule, Module } from '../handler/structures/module';
import type { PayloadType } from '../handler/structures/enums';
+import type { InteractionReplyOptions, MessageReplyOptions } from 'discord.js';
export type Nullish = T | undefined | null;
// Thanks to @kelsny
@@ -26,12 +27,6 @@ export type EventInput =
| { mod: EventModule; absPath: string }[]
| (() => { mod: EventModule; absPath: string }[]);
-export type Reconstruct = T extends Omit ? O & Reconstruct : T;
-
-export type IsOptional = {
- [K in keyof T]-?: T[K] extends Required[K] ? false : true;
-};
-
/**
* Turns a function with a union of array of args into a single union
* [ T , V , B ] | [ A ] => T | V | B | A
@@ -56,3 +51,8 @@ export type SernEventsMapping = {
['error']: [Payload];
['warning']: [string];
};
+
+export type ReplyOptions =
+ | string
+ | Omit
+ | MessageReplyOptions;