meocord 1.2.1 → 1.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/README.md +152 -140
  3. package/dist/cjs/_shared/meocord.app-CHjdCAA_.cjs +496 -0
  4. package/dist/cjs/_shared/theme-BdtbtMZX.cjs +176 -0
  5. package/dist/cjs/common/index.cjs +16 -0
  6. package/dist/cjs/core/index.cjs +35 -0
  7. package/dist/cjs/decorator/index.cjs +360 -0
  8. package/dist/cjs/enum/index.cjs +20 -0
  9. package/dist/cjs/interface/index.cjs +2 -0
  10. package/dist/esm/bin/generator.js +92 -0
  11. package/dist/esm/bin/helper/controller-generator.helper.js +105 -0
  12. package/dist/esm/bin/helper/guard-generator.helper.js +33 -0
  13. package/dist/esm/bin/helper/service-generator.helper.js +33 -0
  14. package/dist/esm/bin/meocord.js +333 -0
  15. package/dist/esm/common/index.js +2 -0
  16. package/dist/esm/common/logger.js +72 -0
  17. package/dist/{core/index.d.ts → esm/common/theme.js} +8 -2
  18. package/dist/esm/core/index.js +1 -0
  19. package/dist/esm/core/meocord-factory.js +28 -0
  20. package/dist/esm/core/meocord.app.js +267 -0
  21. package/dist/esm/decorator/app.decorator.js +99 -0
  22. package/dist/esm/decorator/command-builder.decorator.js +32 -0
  23. package/dist/esm/decorator/container.js +6 -0
  24. package/dist/esm/decorator/controller.decorator.js +218 -0
  25. package/dist/esm/decorator/guard.decorator.js +165 -0
  26. package/dist/esm/decorator/index.js +6 -0
  27. package/dist/esm/decorator/service.decorator.js +58 -0
  28. package/dist/esm/enum/controller.enum.js +43 -0
  29. package/dist/esm/enum/index.js +1 -0
  30. package/dist/esm/interface/index.js +1 -0
  31. package/dist/esm/package.json.js +5 -0
  32. package/dist/esm/util/common.util.js +68 -0
  33. package/dist/esm/util/embed.util.js +13 -0
  34. package/dist/esm/util/generator-cli.util.js +107 -0
  35. package/dist/{util → esm/util}/json.util.js +10 -6
  36. package/dist/esm/util/meocord-cli.util.js +172 -0
  37. package/dist/esm/util/meocord-config-loader.util.js +48 -0
  38. package/dist/esm/util/tsconfig.util.js +83 -0
  39. package/dist/{util → esm/util}/wait.util.js +5 -1
  40. package/dist/{common/logger.d.ts → types/common/index.d.ts} +30 -1
  41. package/dist/{core/meocord.app.d.ts → types/core/index.d.ts} +30 -2
  42. package/dist/types/decorator/index.d.ts +425 -0
  43. package/dist/types/enum/index.d.ts +18 -0
  44. package/dist/{interface → types/interface}/index.d.ts +11 -7
  45. package/package.json +64 -48
  46. package/webpack.config.js +2 -2
  47. package/dist/bin/generator.d.ts +0 -29
  48. package/dist/bin/generator.js +0 -17
  49. package/dist/bin/helper/controller-generator.helper.d.ts +0 -67
  50. package/dist/bin/helper/controller-generator.helper.js +0 -50
  51. package/dist/bin/helper/guard-generator.helper.d.ts +0 -32
  52. package/dist/bin/helper/guard-generator.helper.js +0 -25
  53. package/dist/bin/helper/service-generator.helper.d.ts +0 -32
  54. package/dist/bin/helper/service-generator.helper.js +0 -25
  55. package/dist/bin/meocord.d.ts +0 -19
  56. package/dist/bin/meocord.js +0 -34
  57. package/dist/common/index.d.ts +0 -19
  58. package/dist/common/index.js +0 -17
  59. package/dist/common/logger.js +0 -17
  60. package/dist/common/theme.d.ts +0 -24
  61. package/dist/common/theme.js +0 -17
  62. package/dist/core/index.js +0 -17
  63. package/dist/core/meocord-factory.d.ts +0 -24
  64. package/dist/core/meocord-factory.js +0 -17
  65. package/dist/core/meocord.app.js +0 -17
  66. package/dist/decorator/app.decorator.d.ts +0 -59
  67. package/dist/decorator/app.decorator.js +0 -61
  68. package/dist/decorator/command-builder.decorator.d.ts +0 -39
  69. package/dist/decorator/command-builder.decorator.js +0 -35
  70. package/dist/decorator/container.d.ts +0 -20
  71. package/dist/decorator/container.js +0 -17
  72. package/dist/decorator/controller.decorator.d.ts +0 -125
  73. package/dist/decorator/controller.decorator.js +0 -113
  74. package/dist/decorator/guard.decorator.d.ts +0 -101
  75. package/dist/decorator/guard.decorator.js +0 -94
  76. package/dist/decorator/index.d.ts +0 -23
  77. package/dist/decorator/index.js +0 -17
  78. package/dist/decorator/service.decorator.d.ts +0 -36
  79. package/dist/decorator/service.decorator.js +0 -36
  80. package/dist/enum/controller.enum.d.ts +0 -42
  81. package/dist/enum/controller.enum.js +0 -19
  82. package/dist/enum/index.d.ts +0 -18
  83. package/dist/enum/index.js +0 -17
  84. package/dist/interface/command-decorator.interface.d.ts +0 -43
  85. package/dist/interface/command-decorator.interface.js +0 -1
  86. package/dist/interface/index.js +0 -1
  87. package/dist/util/common.util.d.ts +0 -40
  88. package/dist/util/common.util.js +0 -38
  89. package/dist/util/embed.util.d.ts +0 -19
  90. package/dist/util/embed.util.js +0 -17
  91. package/dist/util/generator-cli.util.d.ts +0 -65
  92. package/dist/util/generator-cli.util.js +0 -49
  93. package/dist/util/index.d.ts +0 -18
  94. package/dist/util/index.js +0 -17
  95. package/dist/util/json.util.d.ts +0 -27
  96. package/dist/util/meocord-cli.util.d.ts +0 -62
  97. package/dist/util/meocord-cli.util.js +0 -50
  98. package/dist/util/meocord-config-loader.util.d.ts +0 -32
  99. package/dist/util/meocord-config-loader.util.js +0 -34
  100. package/dist/util/tsconfig.util.d.ts +0 -29
  101. package/dist/util/tsconfig.util.js +0 -32
  102. package/dist/util/wait.util.d.ts +0 -18
  103. /package/dist/{bin → esm/bin}/builder-template/builder/context-menu.builder.template +0 -0
  104. /package/dist/{bin → esm/bin}/builder-template/builder/slash.builder.template +0 -0
  105. /package/dist/{bin → esm/bin}/builder-template/controller/button.controller.template +0 -0
  106. /package/dist/{bin → esm/bin}/builder-template/controller/context-menu.controller.template +0 -0
  107. /package/dist/{bin → esm/bin}/builder-template/controller/message.controller.template +0 -0
  108. /package/dist/{bin → esm/bin}/builder-template/controller/modal-submit.controller.template +0 -0
  109. /package/dist/{bin → esm/bin}/builder-template/controller/reaction.controller.template +0 -0
  110. /package/dist/{bin → esm/bin}/builder-template/controller/select-menu.controller.template +0 -0
  111. /package/dist/{bin → esm/bin}/builder-template/controller/slash.controller.template +0 -0
  112. /package/dist/{bin → esm/bin}/builder-template/guard.template +0 -0
  113. /package/dist/{bin → esm/bin}/builder-template/service.template +0 -0
@@ -1,34 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * MeoCord Framework
4
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
5
- *
6
- * This program is free software: you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation, either version 3 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
18
- */function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function ownKeys(a,b){var c=Object.keys(a);if(Object.getOwnPropertySymbols){var d=Object.getOwnPropertySymbols(a);b&&(d=d.filter(function(b){return Object.getOwnPropertyDescriptor(a,b).enumerable})),c.push.apply(c,d)}return c}function _objectSpread(a){for(var b,c=1;c<arguments.length;c++)b=null==arguments[c]?{}:arguments[c],c%2?ownKeys(Object(b),!0).forEach(function(c){_defineProperty(a,c,b[c])}):Object.getOwnPropertyDescriptors?Object.defineProperties(a,Object.getOwnPropertyDescriptors(b)):ownKeys(Object(b)).forEach(function(c){Object.defineProperty(a,c,Object.getOwnPropertyDescriptor(b,c))});return a}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}import path from"path";import webpack from"webpack";import{Logger}from"../common/index.js";import{spawn}from"node:child_process";import{capitalize}from"lodash-es";import wait from"../util/wait.util.js";import{GeneratorCLI}from"./generator.js";import*as fs from"node:fs";import{compileAndValidateConfig,setEnvironment}from"../util/common.util.js";import{Command}from"commander";import{compileMeoCordConfig}from"../util/meocord-config-loader.util.js";import{simpleGit}from"simple-git";import chalk from"chalk";import{execSync}from"child_process";import{configureCommandHelp,ensureReady}from"../util/meocord-cli.util.js";import packageJson from"../../package.json"with{type:"json"};import{fileURLToPath}from"url";var __filename=fileURLToPath(import.meta.url),__dirname=path.dirname(__filename),MeoCordCLI=/*#__PURE__*/function(){function MeoCordCLI(){_classCallCheck(this,MeoCordCLI),_defineProperty(this,"appName","MeoCord"),_defineProperty(this,"logger",new Logger(this.appName)),_defineProperty(this,"projectRoot",process.cwd()),_defineProperty(this,"mainJSPath",path.join(this.projectRoot,"dist","main.js")),_defineProperty(this,"webpackConfigPath",path.resolve(__dirname,"..","..","webpack.config.js")),_defineProperty(this,"generatorCLI",new GeneratorCLI(this.appName)),_defineProperty(this,"version",packageJson.version)}return _createClass(MeoCordCLI,[{key:"run",value:(/**
19
- * Configures and runs the MeoCord CLI.
20
- */function(){function run(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(){var a,b=this;return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:a=new Command,a.name(this.appName.toLowerCase()).description("CLI for managing the ".concat(this.appName," application")).version(this.version),a.command("show").description("Display information").option("-w, --warranty","Display warranty disclaimer").option("-c, --license","Display licensing conditions and usage rights").action(function(b){if(!b.warranty&&!b.license){var c;null===(c=a.commands.find(function(a){return"show"===a.name()}))||void 0===c||c.outputHelp(),process.exit(1)}b.warranty&&console.log("\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\nThe authors of this software are not responsible for damages caused\nby the usage, misuse, or inability to use the software.\n\nSee the GNU General Public License for full details:\n<https://www.gnu.org/licenses/>.\n "),b.license&&console.log("\nThis program is free software: you can redistribute it and/or\nmodify it under the terms of the GNU General Public License as\npublished by the Free Software Foundation, either version 3 of\nthe License, or (at your option) any later version.\n\nKey conditions of the GNU GPL v3:\n- You can use this software for personal, academic, or commercial purposes.\n- If you distribute modified versions, you must share the source code under the same GPL v3 license.\n- The original copyright must be retained.\n\nFor full license details, refer to:\n<https://www.gnu.org/licenses/gpl-3.0.txt>\n ")}),a.command("create <app-name>").description("Create a new MeoCord application").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.createApp(a);case 1:return c.a(2,c.v)}},_callee)}));return function(b){return a.apply(this,arguments)}}()),a.command("build").description("Build the application").option("-d, --dev","Build in development mode").option("-p, --prod","Build in production mode").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(a){var c;return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,ensureReady();case 1:return c=a.prod?"production":"development",setEnvironment(c),d.n=2,compileAndValidateConfig();case 2:return d.n=3,b.build(c);case 3:return d.a(2)}},_callee2)}));return function(b){return a.apply(this,arguments)}}()),a.command("start").description("Start the application").option("-b, --build","Pre-build before starting").option("-d, --dev","Start in development mode").option("-p, --prod","Start in production mode").action(/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(a){var c;return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,ensureReady();case 1:if(c=a.prod?"production":"development",setEnvironment(c),!(a.build||a.dev)){d.n=2;break}return d.n=2,compileAndValidateConfig();case 2:if(!a.build){d.n=3;break}return d.n=3,b.build(c);case 3:if(!a.prod){d.n=5;break}return d.n=4,b.startProd();case 4:d.n=6;break;case 5:return d.n=6,b.startDev();case 6:return d.a(2)}},_callee3)}));return function(b){return a.apply(this,arguments)}}()),a=this.generatorCLI.register(a),configureCommandHelp(a),a.showHelpAfterError().parse(process.argv);case 1:return c.a(2)}},_callee4,this)}));return run}())},{key:"createApp",value:function(){function createApp(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q;return _regenerator().w(function(r){for(;1;)switch(r.p=r.n){case 0:if(b=a.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),c=path.resolve(process.cwd(),b),d="https://github.com/l7aromeo/meocord-template.git",console.info(chalk.blueBright("\uD83D\uDE80 Creating a new MeoCord app: ".concat(chalk.bold(b)))),r.p=1,!fs.existsSync(c)){r.n=3;break}return console.error(chalk.red("\u274C Directory \"".concat(chalk.bold(b),"\" already exists."))),r.n=2,wait(100);case 2:process.exit(1);case 3:if(e="22.14.0",f=process.version.slice(1).split(".").map(Number),g=_slicedToArray(f,3),h=g[0],i=g[1],j=g[2],k=e.split(".").map(Number),l=_slicedToArray(k,3),m=l[0],n=l[1],o=l[2],!(h<m||h===m&&i<n||h===m&&i===n&&j<o)){r.n=5;break}return console.error(chalk.red("\u274C Node.js v".concat(e," or higher is required. Current version: v").concat(process.version,"."))),r.n=4,wait(100);case 4:process.exit(1);case 5:return console.info(chalk.blueBright("\uD83D\uDCE6 Fetching template...")),r.n=6,simpleGit().clone(d,c);case 6:return console.log(chalk.green("\u2714 App successfully created at: ".concat(chalk.bold(c)))),fs.rmSync(path.join(c,".git"),{recursive:!0,force:!0}),console.info(chalk.blueBright("\uD83D\uDD27 Initializing Git repository...")),p=simpleGit(c),r.n=7,p.init();case 7:return r.n=8,p.add("./*");case 8:return r.n=9,p.commit("Initial commit");case 9:console.log(chalk.green("\u2714 Git repository initialized.")),console.info(chalk.blueBright("\uD83D\uDCE6 Installing dependencies...")),execSync("cd ".concat(b," && corepack enable && yarn install"),{stdio:"inherit"}),console.log(chalk.green("\u2714 Dependencies installed successfully.")),console.log(chalk.greenBright("\uD83C\uDF89 MeoCord app \"".concat(chalk.bold(b),"\" is ready!"))),r.n=12;break;case 10:return r.p=10,q=r.v,console.error(chalk.red("\u274C Failed to create app: ".concat(q instanceof Error?q.message:q+""))),r.n=11,wait(100);case 11:process.exit(1);case 12:return r.a(2)}},_callee5,null,[[1,10]])}));return createApp}()/**
21
- * Builds the MeoCord application in the specified mode.
22
- *
23
- * @param mode - The build mode ('production' or 'development').
24
- */},{key:"build",value:(function(){function build(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(a){var b,c,d,e,f=this;return _regenerator().w(function(g){for(;1;)switch(g.p=g.n){case 0:return g.p=0,this.clearConsole(),this.logger.info("Building ".concat(a," version...")),g.n=1,import(this.webpackConfigPath);case 1:if(b=g.v["default"],c=webpack(_objectSpread(_objectSpread({},b),{},{mode:a})),c){g.n=2;break}throw this.logger.error("Failed to create webpack compiler instance."),new Error("Failed to create webpack compiler instance.");case 2:return d=null,g.n=3,new Promise(function(b,e){d=setInterval(function(){// Keeps event loop active
25
- },100),c.run(function(g,h){return d&&(clearInterval(d),d=null),g?(f.logger.error("Build encountered an error: ".concat(g.message)),e("Build encountered an error: ".concat(g.message))):void(null!==h&&void 0!==h&&h.hasErrors()?f.logger.error("Build failed due to errors in the compilation process:",h.compilation.errors):f.logger.info("".concat(capitalize(a)," build completed successfully.")),c.close(function(a){return a?(f.logger.error("Error occurred while closing the compiler: ".concat(a.message)),e("Error occurred while closing the compiler: ".concat(a.message))):void b()}))})});case 3:g.n=6;break;case 4:return g.p=4,e=g.v,this.logger.error("Build process failed: ".concat(e.message)),g.n=5,wait(100);case 5:process.exit(1);case 6:return g.a(2)}},_callee6,this,[[0,4]])}));return build}()/**
26
- * Starts the MeoCord application in development mode with live updates.
27
- */)},{key:"startDev",value:(function(){function startDev(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(){var a,b,c,d,e,f,g,h,i,j=this;return _regenerator().w(function(k){for(;1;)switch(k.p=k.n){case 0:return k.p=0,this.clearConsole(),this.logger.log("Starting watch mode..."),k.n=1,import(this.webpackConfigPath);case 1:if(a=k.v["default"],b=webpack(_objectSpread(_objectSpread({},a),{},{mode:"development"})),b){k.n=3;break}return this.logger.error("Failed to create webpack compiler instance."),k.n=2,wait(100);case 2:process.exit(1);case 3:c=null,d=!1,e=function watch(){return b.watch({},function(a,b){return a?void j.logger.error("Webpack Error: ".concat(a.message)):void(null!==b&&void 0!==b&&b.hasErrors()?j.logger.error("Build failed due to errors in the compilation process:",b.compilation.errors):(c&&(c.kill(),c=null),c=spawn("npx -y nodemon",["-q",j.mainJSPath],{shell:!0,cwd:j.projectRoot,stdio:"inherit"}),d=!0))})},e(),g=fs.watch(path.resolve(process.cwd(),"meocord.config.ts"),function(){clearTimeout(f),f=setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(){return _regenerator().w(function(a){for(;1;)switch(a.n){case 0:if(!(d&&c)){a.n=3;break}return d=!1,j.logger.log("MeoCord config change detected, recompiling config..."),c&&!c.killed&&(c.kill(),c=null),a.n=1,new Promise(function(a){return b.close(a)});case 1:return a.n=2,compileMeoCordConfig();case 2:e();case 3:return a.a(2)}},_callee7)})),300)}),h=!1,process.on("SIGINT",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(){return _regenerator().w(function(a){for(;1;)switch(a.n){case 0:if(h&&(c&&!c.killed&&c.kill("SIGKILL"),process.exit(1)),h=!0,g.close(),!c||c.killed){a.n=1;break}c.on("exit",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(){return _regenerator().w(function(a){for(;1;)switch(a.n){case 0:return a.n=1,new Promise(function(a){return b.close(a)});case 1:process.exit(0);case 2:return a.a(2)}},_callee8)}))),a.n=3;break;case 1:return a.n=2,new Promise(function(a){return b.close(a)});case 2:process.exit(0);case 3:return a.a(2)}},_callee9)}))),k.n=5;break;case 4:k.p=4,i=k.v,this.logger.error("Failed to start: ".concat(i.message));case 5:return k.a(2)}},_callee0,this,[[0,4]])}));return startDev}()/**
28
- * Starts the MeoCord application in production mode.
29
- */)},{key:"startProd",value:(function(){function startProd(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(){var a,b,c;return _regenerator().w(function(d){for(;1;)switch(d.p=d.n){case 0:if(d.p=0,fs.existsSync(this.mainJSPath)){d.n=2;break}return this.logger.error("Main entry file (main.js) not found! You might need to build before running in production mode."),d.n=1,wait(100);case 1:process.exit(1);case 2:this.clearConsole(),this.logger.log("Starting..."),a=spawn("node ".concat(this.mainJSPath),{shell:!0,cwd:this.projectRoot,stdio:"inherit"}).on("spawn",this.clearConsole),a.on("exit",function(a){process.exit(null!==a&&void 0!==a?a:0)}),b=!1,process.on("SIGINT",function(){b&&(!a.killed&&a.kill("SIGKILL"),process.exit(1)),b=!0}),d.n=5;break;case 3:return d.p=3,c=d.v,this.logger.error("Failed to start:",c instanceof Error?c.message:c+""),d.n=4,wait(100);case 4:process.exit(1);case 5:return d.a(2)}},_callee1,this,[[0,3]])}));return startProd}()/**
30
- * Clears the console on all platforms.
31
- */)},{key:"clearConsole",value:function clearConsole(){process.stdout.write("\x1B[3J\x1B[2J\x1B[H")}}])}(),cli=new MeoCordCLI;/**
32
- * A Command Line Interface (CLI) for managing the MeoCord application.
33
- */// Create an instance of the CLI and run it
34
- cli.run()["catch"](/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee10(a){return _regenerator().w(function(b){for(;1;)switch(b.n){case 0:return cli.logger.error("Failed to initialize CLI:",(null===a||void 0===a?void 0:a.message)||a),b.n=1,wait(100);case 1:process.exit(1);case 2:return b.a(2)}},_callee10)}));return function(b){return a.apply(this,arguments)}}());
@@ -1,19 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
- export { Logger } from '../common/logger.js';
19
- export { Theme } from '../common/theme.js';
@@ -1,17 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */export{Logger}from"./logger.js";export{Theme}from"./theme.js";
@@ -1,17 +0,0 @@
1
- function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */import{inspect}from"node:util";import dayjs from"dayjs";import utc from"dayjs/plugin/utc.js";import timezone from"dayjs/plugin/timezone.js";import{loadMeoCordConfig}from"../util/meocord-config-loader.util.js";import chalk from"chalk";dayjs.extend(utc),dayjs.extend(timezone);export var Logger=/*#__PURE__*/function(){function Logger(a){_classCallCheck(this,Logger),_defineProperty(this,"colorMap",{LOG:chalk.green,INFO:chalk.cyan,WARN:chalk.yellow,ERROR:chalk.red,DEBUG:chalk.magenta}),this.context=a}return _createClass(Logger,[{key:"log",value:function log(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("log",b)}},{key:"info",value:function info(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("log",b)}},{key:"warn",value:function warn(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("warn",b)}},{key:"error",value:function error(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("error",b)}},{key:"debug",value:function debug(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("debug",b)}},{key:"verbose",value:function verbose(){for(var a=arguments.length,b=Array(a),c=0;c<a;c++)b[c]=arguments[c];this.logWithContext("log",b)}},{key:"formatMessage",value:function formatMessage(a,b){return"object"===_typeof(a)&&null!==a?inspect(a,{showHidden:!0,depth:null,colors:!0,compact:!1,showProxy:!0}):(this.colorMap[b]||function(a){return a})(a)}},{key:"logWithContext",value:function logWithContext(a,b){var c,d=this;if(0!==b.length){var e=loadMeoCordConfig(),f=a.toUpperCase(),g=this.colorMap[f]||function(a){return a},h=b.map(function(a){return d.formatMessage(a,f)}),i=null!==e&&void 0!==e&&e.appName?g(chalk.bold("[".concat(e.appName,"]"))):void 0,j=chalk.bold(dayjs().format("dddd, MMMM D, YYYY HH:mm:ss [UTC]Z")),k=g(chalk.bold("[".concat(f,"]"))),l=this.context?chalk.yellow.bold("[".concat(this.context,"]")):"",m=[i,j,k,l].concat(_toConsumableArray(h)).filter(function(a){return!!a});(c=console)[a].apply(c,_toConsumableArray(m))}}}])}();
@@ -1,24 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
- import { type ColorResolvable } from 'discord.js';
19
- export declare class Theme {
20
- static successColor: ColorResolvable;
21
- static infoColor: ColorResolvable;
22
- static errorColor: ColorResolvable;
23
- static warningColor: ColorResolvable;
24
- }
@@ -1,17 +0,0 @@
1
- function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */export var Theme=/*#__PURE__*/_createClass(function Theme(){_classCallCheck(this,Theme)});_defineProperty(Theme,"successColor","#28A745"),_defineProperty(Theme,"infoColor","#17A2B8"),_defineProperty(Theme,"errorColor","#DC3545"),_defineProperty(Theme,"warningColor","#FFC107");
@@ -1,17 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */export{MeoCordFactory}from"./meocord-factory.js";
@@ -1,24 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
- import 'reflect-metadata';
19
- import { type ServiceIdentifier } from 'inversify';
20
- import { MeoCordApp } from '../core/meocord.app.js';
21
- export declare class MeoCordFactory {
22
- private static logger;
23
- static create(target: ServiceIdentifier): MeoCordApp;
24
- }
@@ -1,17 +0,0 @@
1
- function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */import"reflect-metadata";import{Logger}from"../common/index.js";import{MeoCordApp}from"./meocord.app.js";import{mainContainer}from"../decorator/index.js";export var MeoCordFactory=/*#__PURE__*/function(){function MeoCordFactory(){_classCallCheck(this,MeoCordFactory)}return _createClass(MeoCordFactory,null,[{key:"create",value:function create(a){var b=Reflect.getMetadata("inversify:container",a);if(!b)throw a instanceof Function?this.logger.error("No container found for class: ".concat(a.name)):this.logger.error("No container found for the provided target."),new Error("No container found on the target class.");return mainContainer.get(MeoCordApp)}}])}();_defineProperty(MeoCordFactory,"logger",new Logger);
@@ -1,17 +0,0 @@
1
- function _typeof(a){"@babel/helpers - typeof";return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},_typeof(a)}function _regeneratorValues(a){if(null!=a){var b=a["function"==typeof Symbol&&Symbol.iterator||"@@iterator"],c=0;if(b)return b.call(a);if("function"==typeof a.next)return a;if(!isNaN(a.length))return{next:function next(){return a&&c>=a.length&&(a=void 0),{value:a&&a[c++],done:!a}}}}throw new TypeError(_typeof(a)+" is not iterable")}function _slicedToArray(a,b){return _arrayWithHoles(a)||_iterableToArrayLimit(a,b)||_unsupportedIterableToArray(a,b)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _iterableToArrayLimit(b,c){var d=null==b?null:"undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(null!=d){var g,h,j,k,l=[],a=!0,m=!1;try{if(j=(d=d.call(b)).next,0===c){if(Object(d)!==d)return;a=!1}else for(;!(a=(g=j.call(d)).done)&&(l.push(g.value),l.length!==c);a=!0);}catch(a){m=!0,h=a}finally{try{if(!a&&null!=d["return"]&&(k=d["return"](),Object(k)!==k))return}finally{if(m)throw h}}return l}}function _arrayWithHoles(a){if(Array.isArray(a))return a}function _regeneratorKeys(a){var b=Object(a),c=[];for(var d in b)c.unshift(d);return function e(){for(;c.length;)if((d=c.pop())in b)return e.value=d,e.done=!1,e;return e.done=!0,e}}function _createForOfIteratorHelper(b,c){var d="undefined"!=typeof Symbol&&b[Symbol.iterator]||b["@@iterator"];if(!d){if(Array.isArray(b)||(d=_unsupportedIterableToArray(b))||c&&b&&"number"==typeof b.length){d&&(b=d);var e=0,f=function F(){};return{s:f,n:function n(){return e>=b.length?{done:!0}:{done:!1,value:b[e++]}},e:function e(a){throw a},f:f}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var g,h=!0,i=!1;return{s:function s(){d=d.call(b)},n:function n(){var a=d.next();return h=a.done,a},e:function e(a){i=!0,g=a},f:function f(){try{h||null==d["return"]||d["return"]()}finally{if(i)throw g}}}}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}function _regenerator(){function i(a,d,f,g){var h=d&&d.prototype instanceof Generator?d:Generator,c=Object.create(h.prototype);return _regeneratorDefine2(c,"_invoke",function(a,g,h){function d(a,c){for(m=a,q=c,e=0;!v&&s&&!f&&e<t.length;e++){var f,g=t[e],h=p.p,k=g[2];3<a?(f=k===c)&&(q=g[(m=g[4])?5:(m=3,3)],g[4]=g[5]=b):g[0]<=h&&((f=2>a&&h<g[1])?(m=0,p.v=c,p.n=g[1]):h<k&&(f=3>a||g[0]>c||c>k)&&(g[4]=a,g[5]=c,p.n=k,m=0))}if(f||1<a)return j;throw v=!0,c}var k,m,q,s=0,t=h||[],v=!1,p={p:0,n:0,v:b,a:d,f:d.bind(b,4),d:function d(a,c){return k=a,m=0,q=b,p.n=c,j}};return function(c,f,h){if(1<s)throw TypeError("Generator is already running");for(v&&1===f&&d(f,h),m=f,q=h;(e=2>m?b:q)||!v;){k||(m?3>m?(1<m&&(p.n=-1),d(m,q)):p.n=q:p.v=q);try{if(s=2,k){if(m||(c="next"),e=k[c]){if(!(e=e.call(k,q)))throw TypeError("iterator result is not an object");if(!e.done)return e;q=e.value,2>m&&(m=0)}else 1===m&&(e=k["return"])&&e.call(k),2>m&&(q=TypeError("The iterator does not provide a '"+c+"' method"),m=1);k=b}else if((e=(v=0>p.n)?q:a.call(g,p))!==j)break}catch(a){k=b,m=1,q=a}finally{s=1}}return{value:e,done:v}}}(a,f,g),!0),c}function Generator(){}function GeneratorFunction(){}function GeneratorFunctionPrototype(){}function f(a){return Object.setPrototypeOf?Object.setPrototypeOf(a,GeneratorFunctionPrototype):(a.__proto__=GeneratorFunctionPrototype,_regeneratorDefine2(a,h,"GeneratorFunction")),a.prototype=Object.create(c),a}/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */var b,e,d="function"==typeof Symbol?Symbol:{},g=d.iterator||"@@iterator",h=d.toStringTag||"@@toStringTag",j={};e=Object.getPrototypeOf;var a=[][g]?e(e([][g]())):(_regeneratorDefine2(e={},g,function(){return this}),e),c=GeneratorFunctionPrototype.prototype=Generator.prototype=Object.create(a);return GeneratorFunction.prototype=GeneratorFunctionPrototype,_regeneratorDefine2(c,"constructor",GeneratorFunctionPrototype),_regeneratorDefine2(GeneratorFunctionPrototype,"constructor",GeneratorFunction),GeneratorFunction.displayName="GeneratorFunction",_regeneratorDefine2(GeneratorFunctionPrototype,h,"GeneratorFunction"),_regeneratorDefine2(c),_regeneratorDefine2(c,h,"Generator"),_regeneratorDefine2(c,g,function(){return this}),_regeneratorDefine2(c,"toString",function(){return"[object Generator]"}),(_regenerator=function _regenerator(){return{w:i,m:f}})()}function _regeneratorDefine2(a,b,c,d){var f=Object.defineProperty;try{f({},"",{})}catch(a){f=0}_regeneratorDefine2=function _regeneratorDefine(a,b,c,d){function o(b,c){_regeneratorDefine2(a,b,function(a){return this._invoke(b,c,a)})}b?f?f(a,b,{value:c,enumerable:!d,configurable:!d,writable:!d}):a[b]=c:(o("next",0),o("throw",1),o("return",2))},_regeneratorDefine2(a,b,c,d)}function asyncGeneratorStep(b,d,f,e,g,h,a){try{var c=b[h](a),i=c.value}catch(a){return void f(a)}c.done?d(i):Promise.resolve(i).then(e,g)}function _asyncToGenerator(b){return function(){var c=this,d=arguments;return new Promise(function(e,f){function _next(a){asyncGeneratorStep(g,e,f,_next,_throw,"next",a)}function _throw(a){asyncGeneratorStep(g,e,f,_next,_throw,"throw",a)}var g=b.apply(c,d);_next(void 0)})}}function _classCallCheck(b,a){if(!(b instanceof a))throw new TypeError("Cannot call a class as a function")}function _defineProperties(a,b){for(var c,d=0;d<b.length;d++)c=b[d],c.enumerable=c.enumerable||!1,c.configurable=!0,"value"in c&&(c.writable=!0),Object.defineProperty(a,_toPropertyKey(c.key),c)}function _createClass(a,b,c){return b&&_defineProperties(a.prototype,b),c&&_defineProperties(a,c),Object.defineProperty(a,"prototype",{writable:!1}),a}function _defineProperty(a,b,c){return(b=_toPropertyKey(b))in a?Object.defineProperty(a,b,{value:c,enumerable:!0,configurable:!0,writable:!0}):a[b]=c,a}function _toPropertyKey(a){var b=_toPrimitive(a,"string");return"symbol"==_typeof(b)?b:b+""}function _toPrimitive(a,b){if("object"!=_typeof(a)||!a)return a;var c=a[Symbol.toPrimitive];if(void 0!==c){var d=c.call(a,b||"default");if("object"!=_typeof(d))return d;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===b?String:Number)(a)}/**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */import{MessageFlagsBitField,SlashCommandBuilder}from"discord.js";import{Logger}from"../common/index.js";import{getCommandMap,getMessageHandlers,getReactionHandlers,mainContainer}from"../decorator/index.js";import{sample}from"lodash-es";import{EmbedUtil}from"../util/index.js";import{CommandType}from"../enum/index.js";import{ReactionHandlerAction}from"../enum/controller.enum.js";export var MeoCordApp=/*#__PURE__*/function(){function MeoCordApp(a,b,c,d){var e=this;_classCallCheck(this,MeoCordApp),_defineProperty(this,"logger",new Logger(MeoCordApp.name)),_defineProperty(this,"isShuttingDown",!1),_defineProperty(this,"activityInterval",null),_defineProperty(this,"controllerInstancesCache",new Map),this.controllers=a,this.discordClient=b,this.discordToken=c,this.activities=d,this.bot=this.discordClient,process.on("SIGINT",function(){return e.gracefulShutdown()}),process.on("SIGTERM",function(){return e.gracefulShutdown()})}return _createClass(MeoCordApp,[{key:"start",value:function(){function start(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6(){var a,b=this;return _regenerator().w(function(c){for(;1;)switch(c.p=c.n){case 0:return c.p=0,this.logger.log("Starting bot..."),this.bot.on("clientReady",/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(){return _regenerator().w(function(a){for(;1;)switch(a.n){case 0:return b.activityInterval=setInterval(function(){var a;null===(a=b.bot.user)||void 0===a||a.setActivity(sample(b.activities))},1e4),a.n=1,b.registerCommands();case 1:return a.a(2)}},_callee)}))),this.bot.on("interactionCreate",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.handleInteraction(a);case 1:return c.a(2)}},_callee2)}));return function(b){return a.apply(this,arguments)}}()),this.bot.on("messageCreate",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(a){return _regenerator().w(function(c){for(;1;)switch(c.n){case 0:return c.n=1,b.handleMessage(a);case 1:return c.a(2)}},_callee3)}));return function(b){return a.apply(this,arguments)}}()),this.bot.on("messageReactionAdd",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(a,c){return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,b.handleReaction(a,{user:c,action:ReactionHandlerAction.ADD});case 1:return d.a(2)}},_callee4)}));return function(b,c){return a.apply(this,arguments)}}()),this.bot.on("messageReactionRemove",/*#__PURE__*/function(){var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5(a,c){return _regenerator().w(function(d){for(;1;)switch(d.n){case 0:return d.n=1,b.handleReaction(a,{user:c,action:ReactionHandlerAction.REMOVE});case 1:return d.a(2)}},_callee5)}));return function(b,c){return a.apply(this,arguments)}}()),c.n=1,this.bot.login(this.discordToken);case 1:this.logger.log("Bot is online!"),c.n=3;break;case 2:c.p=2,a=c.v,this.logger.error("Error during bot startup:",a);case 3:return c.a(2)}},_callee6,this,[[0,2]])}));return start}()},{key:"registerCommands",value:function(){function registerCommands(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee7(){var a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p;return _regenerator().w(function(q){for(;1;)switch(q.p=q.n){case 0:a=[],b=_createForOfIteratorHelper(this.controllers),q.p=1,b.s();case 2:if((c=b.n()).done){q.n=6;break}d=c.value,e=getCommandMap(d),m=_regeneratorKeys(e);case 3:if((n=m()).done){q.n=5;break}if(f=n.value,g=e[f],Array.isArray(g)){q.n=4;break}return q.a(3,3);case 4:h=_createForOfIteratorHelper(g);try{for(h.s();!(i=h.n()).done;)j=i.value,k=j.builder,l=j.type,l in CommandType&&k&&a.push(k)}catch(a){h.e(a)}finally{h.f()}q.n=3;break;case 5:q.n=2;break;case 6:q.n=8;break;case 7:q.p=7,o=q.v,b.e(o);case 8:return q.p=8,b.f(),q.f(8);case 9:if(q.p=9,!this.bot.application){q.n=11;break}return q.n=10,this.bot.application.commands.set(a);case 10:this.logger.log("Registered ".concat(a.length," bot commands:"),a.map(function(a){var b="function"==typeof a.toJSON?a.toJSON():a,c=1===(null===b||void 0===b?void 0:b.type)?"SlashCommand":2===(null===b||void 0===b?void 0:b.type)?"UserContextMenu":3===(null===b||void 0===b?void 0:b.type)?"MessageContextMenu":a instanceof SlashCommandBuilder?"SlashCommand":"Command",d=Array.isArray(null===b||void 0===b?void 0:b.options)&&b.options.length?b.options.map(function(a){return{name:a.name,options:a.options.map(function(a){return a.name})}}):void 0,e=(null===b||void 0===b?void 0:b.name)||a.name;return d?{type:c,name:e,subCommands:d}:{type:c,name:e}}));case 11:q.n=13;break;case 12:q.p=12,p=q.v,this.logger.error("Error during command registration:",p);case 13:return q.a(2)}},_callee7,this,[[9,12],[1,7,8,9]])}));return registerCommands}()},{key:"handleInteraction",value:function(){function handleInteraction(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee8(a){var b,c,d,e,f,g,h=this;return _regenerator().w(function(i){for(;1;)switch(i.p=i.n){case 0:b=_createForOfIteratorHelper(this.controllers),i.p=1,d=/*#__PURE__*/_regenerator().m(function _loop(){var b,d,e,f,g,i,j,k,l,m,n,o;return _regenerator().w(function(p){for(;1;)switch(p.p=p.n){case 0:if(b=c.value,d=h.controllerInstancesCache.get(b),d||(d=mainContainer.get(b.constructor),h.controllerInstancesCache.set(b,d)),e=getCommandMap(d),e){p.n=1;break}return p.a(2,0);case 1:if(f=void 0,g=void 0,a.isChatInputCommand()||a.isContextMenuCommand()?(g=a.commandName,f=e[g]):(a.isButton()||a.isStringSelectMenu()||a.isModalSubmit())&&(g=a.customId,i=Object.entries(e).find(function(b){var c=_slicedToArray(b,2),d=c[0],e=c[1];return!!Array.isArray(e)&&e.some(function(b){if(!b.regex||!g)return!1;var c=b.regex.exec(g);return null!==c&&void 0!==c&&c.groups?(a.dynamicParams=c.groups,!0):g===d})}),i&&(f=i[1])),!(f&&0<f.length)){p.n=8;break}if(j=f[0],k=j.methodName,l=j.type,p.p=2,!(l===CommandType.SLASH&&a.isChatInputCommand()||l===CommandType.BUTTON&&a.isButton()||l===CommandType.SELECT_MENU&&a.isStringSelectMenu()||l===CommandType.CONTEXT_MENU&&a.isUserContextMenuCommand()||l===CommandType.CONTEXT_MENU&&a.isMessageContextMenuCommand()||l===CommandType.MODAL_SUBMIT&&a.isModalSubmit())){p.n=4;break}return h.logger.log("[INTERACTION]","[".concat(CommandType[l],"]"),"[".concat(k,"]")),m={},a.isChatInputCommand()&&a.options?m=a.options.data.reduce(function(a,b){return a[b.name]=b.value,a},{}):(a.isButton()||a.isStringSelectMenu()||a.isModalSubmit())&&(m=a.dynamicParams||{}),p.n=3,d[k](a,m);case 3:return p.a(2,{v:void 0});case 4:h.logger.debug(l,k,CommandType.BUTTON,a.isButton()),h.logger.warn("Interaction type mismatch for command \"".concat(g,"\". Interaction type: ").concat(a.type,"."));case 5:p.n=7;break;case 6:if(p.p=6,o=p.v,h.logger.error("Error executing command \"".concat(g,"\":"),o),!a.isRepliable()){p.n=7;break}return n=EmbedUtil.createErrorEmbed("An error occurred while executing the command."),p.n=7,a.reply({embeds:[n],flags:MessageFlagsBitField.Flags.Ephemeral});case 7:return p.a(2,{v:void 0});case 8:return p.a(2)}},_loop,null,[[2,6]])}),b.s();case 2:if((c=b.n()).done){i.n=6;break}return i.d(_regeneratorValues(d()),3);case 3:if(e=i.v,0!==e){i.n=4;break}return i.a(3,5);case 4:if(!e){i.n=5;break}return i.a(2,e.v);case 5:i.n=2;break;case 6:i.n=8;break;case 7:i.p=7,g=i.v,b.e(g);case 8:return i.p=8,b.f(),i.f(8);case 9:if(!a.isRepliable()){i.n=10;break}return f=EmbedUtil.createErrorEmbed("Command not found!"),i.n=10,a.reply({embeds:[f],flags:MessageFlagsBitField.Flags.Ephemeral});case 10:return i.a(2)}},_callee8,this,[[1,7,8,9]])}));return handleInteraction}()},{key:"handleMessage",value:function(){function handleMessage(b){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee9(a){var b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r;return _regenerator().w(function(s){for(;1;)switch(s.p=s.n){case 0:if(!a.author.bot&&null!==(b=a.content)&&void 0!==b&&b.trim()){s.n=1;break}return s.a(2);case 1:c=a.content.trim(),d=this.controllers.filter(function(a){var b=getMessageHandlers(a);return b.some(function(a){return!a.keyword||a.keyword===c})}),e=_createForOfIteratorHelper(d),s.p=2,e.s();case 3:if((f=e.n()).done){s.n=14;break}g=f.value,h=this.controllerInstancesCache.get(g.constructor),h||(i=Reflect.getMetadata("inversify:container",g.constructor),h=i.get(g.constructor,{autobind:!0}),this.controllerInstancesCache.set(g.constructor,h)),j=getMessageHandlers(g),j=j.sort(function(c,a){return c.keyword&&!a.keyword?-1:!c.keyword&&a.keyword?1:0}),k=_createForOfIteratorHelper(j),s.p=4,k.s();case 5:if((l=k.n()).done){s.n=10;break}if(m=l.value,n=m.keyword,o=m.method,n&&n!==c){s.n=9;break}return s.p=6,s.n=7,h[o](a);case 7:s.n=9;break;case 8:s.p=8,p=s.v,this.logger.error("Error handling message \"".concat(c,"\" for method \"").concat(o,"\":"),p);case 9:s.n=5;break;case 10:s.n=12;break;case 11:s.p=11,q=s.v,k.e(q);case 12:return s.p=12,k.f(),s.f(12);case 13:s.n=3;break;case 14:s.n=16;break;case 15:s.p=15,r=s.v,e.e(r);case 16:return s.p=16,e.f(),s.f(16);case 17:return s.a(2)}},_callee9,this,[[6,8],[4,11,12,13],[2,15,16,17]])}));return handleMessage}()},{key:"handleReaction",value:function(){function handleReaction(b,c){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee0(a,b){var c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s;return _regenerator().w(function(t){for(;1;)switch(t.p=t.n){case 0:return c=b.user,d=b.action,t.n=1,a.message.fetch();case 1:e=this.controllers.filter(function(b){var c=getReactionHandlers(b);return c.some(function(b){return!b.emoji||b.emoji===a.emoji.name})}),f=_createForOfIteratorHelper(e),t.p=2,f.s();case 3:if((g=f.n()).done){t.n=14;break}h=g.value,i=this.controllerInstancesCache.get(h.constructor),i||(j=Reflect.getMetadata("inversify:container",h.constructor),i=j.get(h.constructor,{autobind:!0}),this.controllerInstancesCache.set(h.constructor,i)),k=getReactionHandlers(h),k=k.sort(function(c,a){return c.emoji&&!a.emoji?-1:!c.emoji&&a.emoji?1:0}),l=_createForOfIteratorHelper(k),t.p=4,l.s();case 5:if((m=l.n()).done){t.n=10;break}if(n=m.value,o=n.emoji,p=n.method,o&&o!==a.emoji.name){t.n=9;break}return t.p=6,t.n=7,i[p](a,{user:c,action:d});case 7:t.n=9;break;case 8:t.p=8,q=t.v,this.logger.error("Error handling reaction \"".concat(a.emoji.name,"\" for method \"").concat(p,"\":"),q);case 9:t.n=5;break;case 10:t.n=12;break;case 11:t.p=11,r=t.v,l.e(r);case 12:return t.p=12,l.f(),t.f(12);case 13:t.n=3;break;case 14:t.n=16;break;case 15:t.p=15,s=t.v,f.e(s);case 16:return t.p=16,f.f(),t.f(16);case 17:return t.a(2)}},_callee0,this,[[6,8],[4,11,12,13],[2,15,16,17]])}));return handleReaction}()},{key:"gracefulShutdown",value:function(){function gracefulShutdown(){return a.apply(this,arguments)}var a=_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee1(){var a;return _regenerator().w(function(b){for(;1;)switch(b.p=b.n){case 0:if(this.isShuttingDown&&process.exit(1),!this.bot){b.n=4;break}return b.p=1,this.isShuttingDown=!0,this.logger.log("Shutting down bot..."),this.activityInterval&&clearInterval(this.activityInterval),this.bot.removeAllListeners(),b.n=2,this.bot.destroy();case 2:this.logger.log("Bot has shut down"),process.exit(0),b.n=4;break;case 3:b.p=3,a=b.v,this.logger.error("Error during shutdown:",a),process.exit(1);case 4:return b.a(2)}},_callee1,this,[[1,3]])}));return gracefulShutdown}()}])}();
@@ -1,59 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
- import 'reflect-metadata';
19
- import { type ServiceIdentifier } from 'inversify';
20
- import { type ActivityOptions, type ClientOptions } from 'discord.js';
21
- /**
22
- * `@MeoCord()` decorator for initializing and setting up the MeoCord application.
23
- *
24
- * @param {Object} options - The decorator options.
25
- * @param {ServiceIdentifier[]} options.controllers - The list of controllers to be registered.
26
- * @param {ClientOptions} options.clientOptions - The Discord client options for initializing the bot.
27
- * @param {ActivityOptions[]} [options.activities] - Optional activities for the bot.
28
- * @param {ServiceIdentifier[]} [options.services] - Optional services to be registered.
29
- *
30
- * @example
31
- * ```typescript
32
- * @MeoCord({
33
- * controllers: [PingSlashController],
34
- * clientOptions: {
35
- * intents: [
36
- * GatewayIntentBits.Guilds,
37
- * GatewayIntentBits.GuildMembers,
38
- * GatewayIntentBits.GuildMessages,
39
- * GatewayIntentBits.GuildMessageReactions,
40
- * GatewayIntentBits.MessageContent,
41
- * ],
42
- * partials: [Partials.Message, Partials.Channel, Partials.Reaction],
43
- * },
44
- * activities: [{
45
- * name: `${sample(['Genshin', 'ZZZ'])} with Romeo`,
46
- * type: ActivityType.Playing,
47
- * url: 'https://enka.network/u/824957678/',
48
- * }],
49
- * services: [MyStandaloneService],
50
- * })
51
- * class MyApp {}
52
- * ```
53
- **/
54
- export declare function MeoCord(options: {
55
- controllers: ServiceIdentifier[];
56
- clientOptions: ClientOptions;
57
- activities?: ActivityOptions[];
58
- services?: ServiceIdentifier[];
59
- }): (target: any) => void;
@@ -1,61 +0,0 @@
1
- function _construct(a,b,c){if(_isNativeReflectConstruct())return Reflect.construct.apply(null,arguments);var d=[null];d.push.apply(d,b);var e=new(a.bind.apply(a,d));return c&&_setPrototypeOf(e,c.prototype),e}function _setPrototypeOf(a,b){return _setPrototypeOf=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(a,b){return a.__proto__=b,a},_setPrototypeOf(a,b)}function _isNativeReflectConstruct(){try{var a=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(a){}return(_isNativeReflectConstruct=function _isNativeReflectConstruct(){return!!a})()}function _toConsumableArray(a){return _arrayWithoutHoles(a)||_iterableToArray(a)||_unsupportedIterableToArray(a)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(b,c){if(b){if("string"==typeof b)return _arrayLikeToArray(b,c);var a={}.toString.call(b).slice(8,-1);return"Object"===a&&b.constructor&&(a=b.constructor.name),"Map"===a||"Set"===a?Array.from(b):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?_arrayLikeToArray(b,c):void 0}}function _iterableToArray(a){if("undefined"!=typeof Symbol&&null!=a[Symbol.iterator]||null!=a["@@iterator"])return Array.from(a)}function _arrayWithoutHoles(a){if(Array.isArray(a))return _arrayLikeToArray(a)}function _arrayLikeToArray(b,c){(null==c||c>b.length)&&(c=b.length);for(var d=0,f=Array(c);d<c;d++)f[d]=b[d];return f}/**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */import"reflect-metadata";import{mainContainer}from"./container.js";import{injectable}from"inversify";import{Client}from"discord.js";import{MeoCordApp}from"../core/meocord.app.js";import{loadMeoCordConfig}from"../util/meocord-config-loader.util.js";/**
18
- * Binds a class and its dependencies to the Inversify container in singleton scope.
19
- *
20
- * @param {Container} container - The Inversify container instance.
21
- * @param {any} cls - The class to be bound to the container.
22
- */function bindDependencies(a,b){if(!a.isBound(b)){a.bind(b).toSelf().inSingletonScope();var c=Reflect.getMetadata("design:paramtypes",b)||[];c.forEach(function(b){return bindDependencies(a,b)})}}/**
23
- * Resolves dependencies for a given class by binding them to the container and returning the resolved instances.
24
- *
25
- * @param {Container} container - The Inversify container instance.
26
- * @param {any} target - The target class whose dependencies are to be resolved.
27
- * @returns {any[]} - An array of resolved instances of the target's dependencies.
28
- */function resolveDependencies(a,b){var c=Reflect.getMetadata("design:paramtypes",b)||[];return c.map(function(b){return bindDependencies(a,b),a.get(b)})}/**
29
- * `@MeoCord()` decorator for initializing and setting up the MeoCord application.
30
- *
31
- * @param {Object} options - The decorator options.
32
- * @param {ServiceIdentifier[]} options.controllers - The list of controllers to be registered.
33
- * @param {ClientOptions} options.clientOptions - The Discord client options for initializing the bot.
34
- * @param {ActivityOptions[]} [options.activities] - Optional activities for the bot.
35
- * @param {ServiceIdentifier[]} [options.services] - Optional services to be registered.
36
- *
37
- * @example
38
- * ```typescript
39
- * @MeoCord({
40
- * controllers: [PingSlashController],
41
- * clientOptions: {
42
- * intents: [
43
- * GatewayIntentBits.Guilds,
44
- * GatewayIntentBits.GuildMembers,
45
- * GatewayIntentBits.GuildMessages,
46
- * GatewayIntentBits.GuildMessageReactions,
47
- * GatewayIntentBits.MessageContent,
48
- * ],
49
- * partials: [Partials.Message, Partials.Channel, Partials.Reaction],
50
- * },
51
- * activities: [{
52
- * name: `${sample(['Genshin', 'ZZZ'])} with Romeo`,
53
- * type: ActivityType.Playing,
54
- * url: 'https://enka.network/u/824957678/',
55
- * }],
56
- * services: [MyStandaloneService],
57
- * })
58
- * class MyApp {}
59
- * ```
60
- **/export function MeoCord(a){return function(b){Reflect.hasMetadata("inversify:injectable",b)||injectable()(b);var c=loadMeoCordConfig();if(c){var d=new Client(a.clientOptions);mainContainer.bind(Client).toConstantValue(d)// Bind controllers and services to the container
61
- ,[].concat(_toConsumableArray(a.controllers),_toConsumableArray(a.services||[])).forEach(function(a){bindDependencies(mainContainer,a)}),mainContainer.bind(b).toConstantValue(a.clientOptions),a.activities&&mainContainer.bind(b).toConstantValue(a.activities),a.services&&mainContainer.bind(b).toConstantValue(a.services.map(function(a){return mainContainer.get(a)}));var e=new MeoCordApp(a.controllers.map(function(a){return mainContainer.get(a)}),d,c.discordToken,null===a||void 0===a?void 0:a.activities);mainContainer.bind(MeoCordApp).toConstantValue(e),mainContainer.bind(b).toDynamicValue(function(){var a=resolveDependencies(mainContainer,b);return _construct(b,_toConsumableArray(a))}).inSingletonScope(),Reflect.defineMetadata("inversify:container",mainContainer,b)}}}
@@ -1,39 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
- import 'reflect-metadata';
19
- import { CommandType } from '../enum/index.js';
20
- import { type CommandBuilderBase } from '../interface/command-decorator.interface.js';
21
- /**
22
- * This decorator is used to mark a class as a Discord command builder that later can be registered on the `@Command` decorator.
23
- * It defines the command type using metadata and dynamically makes the class injectable if it isn't already.
24
- *
25
- * @example
26
- * ```typescript
27
- * @CommandBuilder(CommandType.SLASH)
28
- * export class MySlashCommand implements CommandBuilderBase {
29
- * build(commandName: string): SlashCommandBuilder {
30
- * return new SlashCommandBuilder().setName(commandName).setDescription('A sample slash command')
31
- * }
32
- * }
33
- *```
34
- *
35
- * @param commandType - The type of the command, specified from the `CommandType` enum.
36
- * @returns A decorator function that makes the target class injectable
37
- * and assigns the `commandType` metadata.
38
- */
39
- export declare function CommandBuilder<T extends CommandType.SLASH | CommandType.CONTEXT_MENU>(commandType: T): (target: new () => CommandBuilderBase<T>) => void;
@@ -1,35 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */import"reflect-metadata";import{injectable}from"inversify";/**
18
- * This decorator is used to mark a class as a Discord command builder that later can be registered on the `@Command` decorator.
19
- * It defines the command type using metadata and dynamically makes the class injectable if it isn't already.
20
- *
21
- * @example
22
- * ```typescript
23
- * @CommandBuilder(CommandType.SLASH)
24
- * export class MySlashCommand implements CommandBuilderBase {
25
- * build(commandName: string): SlashCommandBuilder {
26
- * return new SlashCommandBuilder().setName(commandName).setDescription('A sample slash command')
27
- * }
28
- * }
29
- *```
30
- *
31
- * @param commandType - The type of the command, specified from the `CommandType` enum.
32
- * @returns A decorator function that makes the target class injectable
33
- * and assigns the `commandType` metadata.
34
- */export function CommandBuilder(a){return function(b){// Define the command type metadata for the target class
35
- Reflect.hasMetadata("inversify:injectable",b)||injectable()(b),Reflect.defineMetadata("commandType",a,b)}}
@@ -1,20 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */
18
- import 'reflect-metadata';
19
- import { Container } from 'inversify';
20
- export declare const mainContainer: Container;
@@ -1,17 +0,0 @@
1
- /**
2
- * MeoCord Framework
3
- * Copyright (C) 2025 Ukasyah Rahmatullah Zada
4
- *
5
- * This program is free software: you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation, either version 3 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
17
- */import"reflect-metadata";import{Container}from"inversify";export var mainContainer=new Container;