@pikokr/command.ts 5.6.2-dev.4 → 5.7.0-dev.1

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.
package/.envrc ADDED
@@ -0,0 +1 @@
1
+ use nix
@@ -15,6 +15,6 @@
15
15
  "typescript.tsdk": "node_modules/typescript/lib",
16
16
  "typescript.enablePromptUseWorkspaceTsdk": true,
17
17
  "editor.codeActionsOnSave": {
18
- "source.fixAll": true
18
+ "source.fixAll": "explicit"
19
19
  }
20
20
  }
package/dist/index.d.ts CHANGED
@@ -208,4 +208,4 @@ declare const applicationCommand: (options: Options) => MethodDecorator;
208
208
 
209
209
  declare const option: (options: ApplicationCommandOptionData) => ParameterDecorator;
210
210
 
211
- export { ApplicationCommandComponent, Options as ApplicationCommandComponentOptions, ApplicationCommandExtension, ApplicationCommandExtensionConfig, Options$2 as ArgumentConvertOptions, OptionsArg$1 as ArgumentConvertOptionsArg, BaseComponent, CommandClient, ComponentArgument, ComponentArgumentDecorator, ComponentArgumentStore, ComponentHookFn, ComponentHookStore, ComponentStore, ConverterComponent, Extension, ListenerComponent, Options$1 as ListenerOptions, OptionsArg as ListenerOptionsArg, ModuleHookStore, OwnerOnlyError, Registry, SubCommandGroup, SubCommandGroupChild, TextCommandComponent, TextCommandConfig, TextCommandOptions, TextCommandRestOption, applicationCommand, argConverter, command, createArgumentDecorator, createCheckDecorator, createComponentDecorator, createComponentHook, getComponent, getComponentArgumentStore, getComponentStore, getModuleHookStore, listener, mergeMethodDecorators, moduleHook, option, ownerOnly, rest };
211
+ export { ApplicationCommandComponent, type Options as ApplicationCommandComponentOptions, ApplicationCommandExtension, type ApplicationCommandExtensionConfig, type Options$2 as ArgumentConvertOptions, type OptionsArg$1 as ArgumentConvertOptionsArg, BaseComponent, CommandClient, ComponentArgument, ComponentArgumentDecorator, type ComponentArgumentStore, type ComponentHookFn, type ComponentHookStore, type ComponentStore, ConverterComponent, Extension, ListenerComponent, type Options$1 as ListenerOptions, type OptionsArg as ListenerOptionsArg, type ModuleHookStore, OwnerOnlyError, Registry, SubCommandGroup, SubCommandGroupChild, TextCommandComponent, type TextCommandConfig, type TextCommandOptions, TextCommandRestOption, applicationCommand, argConverter, command, createArgumentDecorator, createCheckDecorator, createComponentDecorator, createComponentHook, getComponent, getComponentArgumentStore, getComponentStore, getModuleHookStore, listener, mergeMethodDecorators, moduleHook, option, ownerOnly, rest };
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var Eo=Object.create;var D=Object.defineProperty,Fo=Object.defineProperties,$o=Object.getOwnPropertyDescriptor,Oo=Object.getOwnPropertyDescriptors,Wo=Object.getOwnPropertyNames,rt=Object.getOwnPropertySymbols,Do=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty,io=Object.prototype.propertyIsEnumerable;var yt=(r,o,t)=>o in r?D(r,o,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[o]=t,S=(r,o)=>{for(var t in o||(o={}))xt.call(o,t)&&yt(r,t,o[t]);if(rt)for(var t of rt(o))io.call(o,t)&&yt(r,t,o[t]);return r},A=(r,o)=>Fo(r,Oo(o)),a=(r,o)=>D(r,"name",{value:o,configurable:!0});var ao=(r,o)=>{var t={};for(var e in r)xt.call(r,e)&&o.indexOf(e)<0&&(t[e]=r[e]);if(r!=null&&rt)for(var e of rt(r))o.indexOf(e)<0&&io.call(r,e)&&(t[e]=r[e]);return t};var h=(r,o)=>()=>(r&&(o=r(r=0)),o);var co=(r,o)=>{for(var t in o)D(r,t,{get:o[t],enumerable:!0})},mo=(r,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of Wo(o))!xt.call(r,n)&&n!==t&&D(r,n,{get:()=>o[n],enumerable:!(e=$o(o,n))||e.enumerable});return r};var v=(r,o,t)=>(t=r!=null?Eo(Do(r)):{},mo(o||!r||!r.__esModule?D(t,"default",{value:r,enumerable:!0}):t,r)),Po=r=>mo(D({},"__esModule",{value:!0}),r);var p=(r,o,t)=>(yt(r,typeof o!="symbol"?o+"":o,t),t);var d=(r,o,t)=>new Promise((e,n)=>{var s=i=>{try{l(t.next(i))}catch(u){n(u)}},m=i=>{try{l(t.throw(i))}catch(u){n(u)}},l=i=>i.done?e(i.value):Promise.resolve(i.value).then(s,m);l((t=t.apply(r,o)).next())});var K,Qo,bt,st,Ct,it,P=h(()=>{"use strict";K=Symbol(),Qo=Symbol(),bt=Symbol(),st=Symbol(),Ct=Symbol(),it=Symbol()});var po,wt,at,St=h(()=>{"use strict";po=require("discord.js");P();wt=a((r,o)=>{let t=Reflect.getMetadata(Ct,r,o);return t||(t=new po.Collection,Reflect.defineMetadata(Ct,t,r,o)),t},"getComponentHookStore"),at=a((r,o)=>(t,e)=>{let n=wt(t,e),s=n.get(r);s||(s=[],n.set(r,s)),s.unshift(o)},"createComponentHook")});var Mt,Q,No,M,kt,V,N=h(()=>{"use strict";Mt=require("discord.js");St();P();Q=a(r=>{let o=Reflect.getMetadata(K,r);return o||(o=new Mt.Collection,Reflect.defineMetadata(K,o,r)),o},"getComponentStore"),No=a((r,o)=>Q(r).get(o),"getComponent"),M=a(r=>(o,t)=>{r._init(Reflect.get(o,t),Reflect.getMetadata("design:paramtypes",o,t));let e=wt(o,t);r.hooks=e;let n=Q(o);kt(o,t).forEach((m,l)=>{var i;(i=r.argTypes.get(l))==null||i.decorators.push(m)}),n.set(t,r)},"createComponentDecorator"),kt=a((r,o)=>{let t=Reflect.getMetadata(K,r,o);return t||(t=new Mt.Collection,Reflect.defineMetadata(K,t,r,o)),t},"getComponentArgumentStore"),V=a(r=>o=>(t,e,n)=>{if(!e)return;let s=new r(o);kt(t,e).set(n,s)},"createArgumentDecorator")});var vt,X,Ht=h(()=>{"use strict";vt=class vt{constructor(o){p(this,"type");p(this,"decorators");this.type=o,this.decorators=[]}};a(vt,"ComponentArgument");X=vt});var lo,Gt,O,fo=h(()=>{"use strict";lo=v(require("lodash")),Gt=class Gt{constructor(o){p(this,"options");typeof o=="object"?this.options=lo.default.merge(this.defaultOptions(),o):this.options=o}defaultOptions(){return{}}};a(Gt,"ComponentArgumentDecorator");O=Gt});var Rt,C,qo,ct=h(()=>{"use strict";N();q();Rt=class Rt extends H{constructor(t){super();p(this,"options");p(this,"subcommandGroup");p(this,"subcommandGroupChild");this.options=t}};a(Rt,"ApplicationCommandComponent");C=Rt,qo=a(r=>M(new C(r)),"applicationCommand")});var It,E,uo,Tt=h(()=>{"use strict";L();It=class It extends O{};a(It,"ApplicationCommandOption");E=It,uo=V(E)});var jt,U,R,Lt=h(()=>{"use strict";q();N();jt=class jt extends H{constructor(t){super();p(this,"options");this.options=t}};a(jt,"ConverterComponent");U=jt,R=a(r=>M(new U(r)),"argConverter")});var go,mt,Uo,ho=h(()=>{"use strict";go=require("discord.js");P();mt=a(r=>{let o=Reflect.getMetadata(bt,r);return o||(o=new go.Collection,Reflect.defineMetadata(bt,o,r)),o},"getModuleHookStore"),Uo=a(r=>(o,t)=>{let e=mt(o),n=e.get(r);n||(n=[],e.set(r,n)),n.push(Reflect.get(o,t))},"moduleHook")});var pt=h(()=>{"use strict";ho();St()});var yo,At,W,Y,lt=h(()=>{"use strict";yo=v(require("lodash"));q();N();At=class At extends H{constructor(t){super();p(this,"options");this.options=yo.default.merge({emitter:"discord"},t)}};a(At,"ListenerComponent");W=At,Y=a(r=>M(new W(r)),"listener")});var B,xo,bo,Co,wo,Et,tt,Ft=h(()=>{"use strict";B=v(require("chalk")),xo=require("discord.js"),bo=v(require("lodash"));$t();pt();lt();P();Co=v(require("walk-sync")),wo=v(require("path")),Et=class Et{constructor(o,t){p(this,"client");p(this,"extensions");p(this,"emitters");p(this,"logger");p(this,"globalHooks");this.client=t,this.extensions=[],this.emitters=new xo.Collection,this.globalHooks={},this.logger=o.getSubLogger({name:B.default.green("Registry")})}addGlobalHook(o,t){let e=this.globalHooks[o];e||(e=[],this.globalHooks[o]=e),e.push(t)}getComponentsWithTypeGlobal(o){let t=[];for(let e of this.extensions)t.push(...this.getComponentsWithType(e,o));return t}getComponentsWithType(o,t){let e=Q(o);return Array.from(e.filter(n=>n.constructor===t).values())}registerEventListeners(o){let t=this.getComponentsWithType(o,W);for(let e of t){let n=this.emitters.get(e.options.emitter);if(n){let s=e.method.bind(o);Reflect.defineMetadata("bound",s,e),n.addListener(e.options.event,s)}}}unregisterEventListeners(o){let t=this.getComponentsWithType(o,W);for(let e of t){let n=this.emitters.get(e.options.emitter),s=Reflect.getMetadata("bound",e);n&&s&&n.removeListener(e.options.event,s)}}loadAllModulesInDirectory(o,t){return d(this,null,function*(){let e=[],n=(0,Co.default)(o).filter(s=>(s.endsWith(".ts")||s.endsWith(".js"))&&(!t||t.test(s)));for(let s of n){if(s.endsWith(".d.ts"))continue;let m=wo.default.join(o,s);e.push(...yield this.loadModulesAtPath(m))}return e})}loadModulesAtPath(o){return d(this,null,function*(){this.logger.info(`Loading module at path ${B.default.green(o)}`);let t=require.resolve(o),e=require(t);if(typeof e.setup!="function")throw new Error("Extension must have a setup function");let n=yield e.setup(this.client);return this.registerModules(n,t)})}registerModules(o,t){return d(this,null,function*(){let e=[];if(o instanceof Array)for(let n of o)yield this.registerModule(n),Reflect.defineMetadata(it,t,n),e.push(n);else yield this.registerModule(o),Reflect.defineMetadata(it,t,o),e.push(o);return e})}reloadModules(){return d(this,null,function*(){let o=[],t=new Set,e=[...this.extensions];for(let n of e){let s=Reflect.getMetadata(it,n);s&&(this.logger.info(`Unloading module: ${B.default.green(n.constructor.name)}`),t.add(s),yield this.unregisterModule(n),delete require.cache[require.resolve(s)])}for(let n of t)try{let s=yield this.loadModulesAtPath(n);o.push({file:n,result:!0,extensions:s})}catch(s){o.push({file:n,result:!1,error:s})}return o})}registerModule(o){return d(this,null,function*(){Reflect.defineMetadata(st,this.client,o),this.registerEventListeners(o),yield this.runModuleHook(o,"load"),this.extensions.push(o),this.logger.info(`Module registered: ${B.default.green(o.constructor.name)}`)})}unregisterModule(o){return d(this,null,function*(){this.unregisterEventListeners(o),yield this.runModuleHook(o,"unload"),bo.default.remove(this.extensions,t=>t===o),this.logger.info(`Module unregistered: ${B.default.green(o.constructor.name)}`)})}runModuleHook(o,t,...e){let s=mt(o).get(t);if(s)for(let m of s)m.call(o,...e)}registerEventEmitter(o,t){this.emitters.set(o,t)}};a(Et,"Registry");tt=Et});var Ot=h(()=>{"use strict";Ft();ft()});var So,Mo,Wt,ot,Dt=h(()=>{"use strict";So=v(require("chalk")),Mo=require("discord.js");Lt();Ot();Wt=class Wt{constructor(){p(this,"_logger")}get commandClient(){return z.getFromModule(this)}get client(){return this.commandClient.discord}get logger(){return this._logger||(this._logger=this.commandClient.logger.getSubLogger({name:So.default.green(`${this.constructor.name}`)})),this._logger}convertArguments(o,t,e,n){return d(this,null,function*(){let s=new Mo.Collection;for(let m of this.commandClient.registry.extensions)for(let l of this.commandClient.registry.getComponentsWithType(m,U))l.options.component==o&&s.set(l.options.type,{component:l,ext:m});for(let[m,l]of e){let i=s.get(l.type);if(!i){t[m]=void 0;continue}let u=yield n(l,m,i.component);t[m]=yield i.component.execute(i.ext,u)}})}};a(Wt,"Extension");ot=Wt});var ko,Pt,_,Nt=h(()=>{"use strict";ko=v(require("chalk"));Dt();Pt=class Pt extends ot{get logger(){return this._logger||(this._logger=this.commandClient.ctsLogger.getSubLogger({name:ko.default.green(`${this.constructor.name}`)})),this._logger}};a(Pt,"CTSExtension");_=Pt});function et(r,o,t,e){var n=arguments.length,s=n<3?o:e===null?e=Object.getOwnPropertyDescriptor(o,t):e,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,o,t,e);else for(var l=r.length-1;l>=0;l--)(m=r[l])&&(s=(n<3?m(s):n>3?m(o,t,s):m(o,t))||s);return n>3&&s&&Object.defineProperty(o,t,s),s}function T(r,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,o)}var I,x,k,qt,G,Ut=h(()=>{"use strict";I=v(require("chalk")),x=require("discord.js"),k=require("discord-api-types/v10");ct();Tt();L();L();Nt();a(et,"_ts_decorate");a(T,"_ts_metadata");qt=class qt extends _{constructor(t){super();p(this,"config");p(this,"unmanagedCommands");this.config=t,this.unmanagedCommands=[]}registerUnmanagedCommand(t){this.unmanagedCommands.push(t)}interactionCreate(t){return d(this,null,function*(){var e;try{if(!t.isCommand())return;let n=null,s=null,m=this.commandClient.registry.extensions,l=null,i=null;t.isChatInputCommand()&&(l=t.options.getSubcommand(!1),i=t.options.getSubcommandGroup(!1));t:for(let u of m){let f=this.commandClient.registry.getComponentsWithType(u,C);if(l){for(let c of f)if(!(!c.subcommandGroup&&!c.subcommandGroupChild)){if(c.subcommandGroupChild&&c.subcommandGroupChild.parent.options.name===t.commandName&&c.subcommandGroupChild.options.name===i&&c.options.name===l){s=u,n=c;break t}if(c.subcommandGroup&&!i&&c.subcommandGroup.options.name===t.commandName&&c.options.name===l){s=u,n=c;break t}}}else for(let c of f)if(c.options.name===t.commandName){s=u,n=c;break t}}if(n&&s){let u=[];yield this.convertArguments(C,u,n.argTypes,()=>[t]);for(let[f,c]of n.argTypes){let g=null;for(let y of c.decorators)if(y instanceof E){if([k.ApplicationCommandOptionType.Subcommand,k.ApplicationCommandOptionType.SubcommandGroup].includes(y.options.type)&&t.isChatInputCommand()){if(y.options.type===k.ApplicationCommandOptionType.Subcommand){g=t.options.getSubcommand()===y.options.name;break}if(y.options.type===k.ApplicationCommandOptionType.SubcommandGroup){g=t.options.getSubcommandGroup()===y.options.name;break}}g=(e=t.options.get(y.options.name,!1))==null?void 0:e.value;break}g&&(u[f]=g)}try{yield n.executeGlobalHook(s,"beforeApplicationCommandCall",[t]),yield n.execute(s,u,[t])}finally{yield n.executeGlobalHook(s,"afterApplicationCommandCall",[t])}}}catch(n){this.commandClient.emit("applicationCommandInvokeError",n,t)}})}sync(){return d(this,null,function*(){let t=this.commandClient;this.logger.info("Trying to sync commands...");let e=[],n=new x.Collection,s=new x.Collection;for(let i of t.registry.getComponentsWithTypeGlobal(C)){if(i.subcommandGroup){let f=s.get(i.subcommandGroup.options.name);if(!f){if(f=A(S({},i.subcommandGroup.options),{type:k.ApplicationCommandType.ChatInput}),i.subcommandGroup.guilds)for(let g of i.subcommandGroup.guilds){let y=n.get(g);y||(y=[],n.set(g,y))}else e.push(f);s.set(i.subcommandGroup.options.name,f)}f.options||(f.options=[]);let c=[];for(let[,g]of i.argTypes){let y=g.decorators.find(b=>b.constructor===E);y&&c.push(y.options)}f.options.push(A(S({},i.options),{type:k.ApplicationCommandOptionType.Subcommand,options:c}));continue}else if(i.subcommandGroupChild){let f=i.subcommandGroupChild.parent,c=s.get(f.options.name);if(!c){if(c=A(S({},f.options),{type:k.ApplicationCommandType.ChatInput}),f.guilds)for(let b of f.guilds){let w=n.get(b);w||(w=[],n.set(b,w))}else e.push(c);s.set(f.options.name,c)}c.options||(c.options=[]);let g=c.options.find(b=>{var w;return b.name===((w=i.subcommandGroupChild)==null?void 0:w.options.name)});g||(g=A(S({},i.subcommandGroupChild.options),{type:k.ApplicationCommandOptionType.SubcommandGroup}),c.options.push(g)),g.options||(g.options=[]);let y=[];for(let[,b]of i.argTypes){let w=b.decorators.find(Ao=>Ao.constructor===E);w&&y.push(w.options)}g.options.push(A(S({},i.options),{type:k.ApplicationCommandOptionType.Subcommand,options:y}));continue}let u=S({},i.options);if(u.type===k.ApplicationCommandType.ChatInput){u.options=[];for(let[,f]of i.argTypes){let c=f.decorators.find(g=>g.constructor===E);c&&u.options.push(c.options)}}if(yield i.executeHook(this,"beforeSync",[u,i]),i.options.guilds){for(let f of i.options.guilds){let c=n.get(f);c||(c=[],n.set(f,c)),c.push(u)}continue}e.push(u)}for(let m of this.unmanagedCommands){let l=m,{guilds:i}=l,u=ao(l,["guilds"]);if(i)for(let f of i){let c=n.get(f);c||(c=[],n.set(f,c)),c.push(u)}else e.push(u)}if(this.config.guilds){for(let i of this.config.guilds){let u=n.get(i);u||(u=[],n.set(i,u)),u.push(...e)}e=[]}if(n.size)for(let[i,u]of n)try{let f=yield this.client.guilds.fetch(i);yield f.fetch(),this.logger.info(`Processing ${I.default.green(u.length)} commands(${u.map(c=>I.default.blue(c.name)).join(", ")}) for guild ${I.default.green(f.name)}(${I.default.blue(f.id)})`),yield f.commands.set(u),this.logger.info(`Successfully registered commands for guild ${I.default.green(f.name)}(${I.default.blue(f.id)})`)}catch(f){this.logger.error(`Failed to register commands to guild ${I.default.green(i)}: ${f.message}`)}if(e.length)try{this.logger.info(`Processing ${I.default.green(e.length)} commands(${e.map(i=>I.default.blue(i.name)).join(", ")}) for application scope...`),this.client.application?(yield this.client.application.commands.set(e),this.logger.info("Successfully registered commands.")):this.logger.error("Client#application is not yet initialized.")}catch(i){this.logger.error(`Failed to register commands to global: ${i.message}`)}})}chatInteraction(t){return d(this,null,function*(){return t})}messageInteraction(t){return d(this,null,function*(){return t})}userInteraction(t){return d(this,null,function*(){return t})}commandInteraction(t){return d(this,null,function*(){return t})}};a(qt,"ApplicationCommandExtension");G=qt;et([Y({event:"interactionCreate"}),T("design:type",Function),T("design:paramtypes",[typeof Interaction=="undefined"?Object:Interaction])],G.prototype,"interactionCreate",null);et([R({component:C,parameterless:!0,type:x.ChatInputCommandInteraction}),T("design:type",Function),T("design:paramtypes",[typeof x.ChatInputCommandInteraction=="undefined"?Object:x.ChatInputCommandInteraction])],G.prototype,"chatInteraction",null);et([R({component:C,parameterless:!0,type:x.MessageContextMenuCommandInteraction}),T("design:type",Function),T("design:paramtypes",[typeof x.MessageContextMenuCommandInteraction=="undefined"?Object:x.MessageContextMenuCommandInteraction])],G.prototype,"messageInteraction",null);et([R({component:C,parameterless:!0,type:x.UserContextMenuCommandInteraction}),T("design:type",Function),T("design:paramtypes",[typeof x.UserContextMenuCommandInteraction=="undefined"?Object:x.UserContextMenuCommandInteraction])],G.prototype,"userInteraction",null);et([R({component:C,parameterless:!0,type:x.CommandInteraction}),T("design:type",Function),T("design:paramtypes",[typeof x.UserContextMenuCommandInteraction=="undefined"?Object:x.UserContextMenuCommandInteraction])],G.prototype,"commandInteraction",null)});var Bt,j,Bo,zt=h(()=>{"use strict";N();q();Bt=class Bt extends H{constructor(t){super();p(this,"options");this.options=t}};a(Bt,"TextCommandComponent");j=Bt,Bo=a(r=>M(new j(r)),"command")});var _t,Z,zo,Zt=h(()=>{"use strict";L();L();_t=class _t extends O{};a(_t,"TextCommandRestOption");Z=_t,zo=V(Z)});function ut(r,o,t,e){var n=arguments.length,s=n<3?o:e===null?e=Object.getOwnPropertyDescriptor(o,t):e,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,o,t,e);else for(var l=r.length-1;l>=0;l--)(m=r[l])&&(s=(n<3?m(s):n>3?m(o,t,s):m(o,t))||s);return n>3&&s&&Object.defineProperty(o,t,s),s}function F(r,o){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,o)}var J,Jt,$,vo=h(()=>{"use strict";lt();J=require("discord.js");Nt();zt();Zt();L();a(ut,"_ts_decorate");a(F,"_ts_metadata");Jt=class Jt extends _{constructor(t){super();p(this,"config");this.config=t}processPrefix(t){return d(this,null,function*(){let e=t.content,n=this.config.prefix;if(typeof n=="function"&&(n=yield n(t)),typeof n=="string")return e.startsWith(n)?n.length:null;if(n instanceof Array){let s=n.find(m=>e.startsWith(m));return s?s.length:null}return null})}messageCreate(t){return d(this,null,function*(){try{let e=yield this.processPrefix(t);if(e===null)return;let n=t.content.slice(e),s=[],m=new Map;for(let g of this.commandClient.registry.extensions)for(let y of this.commandClient.registry.getComponentsWithType(g,j))s.push(y),m.set(y,g);let l=0,i=s.find(g=>{let y=[g.options.name];g.options.aliases&&y.push(...g.options.aliases);for(let b of y)if(n.startsWith(b))return n.length===b.length?(l=b.length,!0):(l=b.length,n.startsWith(b+" "));return!1});if(!i)return;let u=m.get(i);if(!u)return;t.command=i;let f=[],c=n.slice(l+1).split(/ /g);yield this.convertArguments(j,f,i.argTypes,(g,y,b)=>d(this,null,function*(){if(b.options.parameterless)return[t];if(g.decorators.find(w=>w.constructor===Z)){let w=c.join(" ");return c=[],[w,t]}return[c.shift(),t]})),yield i.execute(u,f,[t])}catch(e){this.commandClient.emit("textCommandInvokeError",e,t)}})}mesage(t){return d(this,null,function*(){return t})}str(t){return d(this,null,function*(){return t})}num(t){return d(this,null,function*(){return Number(t)})}};a(Jt,"TextCommandExtension");$=Jt;ut([Y({event:"messageCreate",emitter:"discord"}),F("design:type",Function),F("design:paramtypes",[typeof J.Message=="undefined"?Object:J.Message])],$.prototype,"messageCreate",null);ut([R({component:j,type:J.Message,parameterless:!0}),F("design:type",Function),F("design:paramtypes",[typeof J.Message=="undefined"?Object:J.Message])],$.prototype,"mesage",null);ut([R({component:j,type:String}),F("design:type",Function),F("design:paramtypes",[String])],$.prototype,"str",null);ut([R({component:j,type:Number}),F("design:type",Function),F("design:paramtypes",[String])],$.prototype,"num",null)});var Qt={};co(Qt,{CommandClient:()=>z});var Kt,dt,Ho,Go,Vt,z,ft=h(()=>{"use strict";Kt=v(require("chalk")),dt=require("discord.js"),Ho=v(require("events")),Go=require("tslog");Ut();vo();P();Ft();Vt=class Vt extends Ho.default{constructor(t,e=new Go.Logger({prettyLogTimeZone:"local"}),n={}){super();p(this,"discord");p(this,"logger");p(this,"ctsLogger");p(this,"registry");p(this,"owners");this.discord=t,this.logger=e,this.owners=new Set,this.ctsLogger=e.getSubLogger(A(S({},n),{name:"command.ts"})),this.registry=new tt(this.ctsLogger,this),this.registry.registerEventEmitter("cts",this),this.registry.registerEventEmitter("discord",this.discord)}isOwner(t){return d(this,null,function*(){return this.owners.has(t.id)})}fetchOwners(){return d(this,null,function*(){if(!this.discord.application)throw new Error("The client is not logged in.");this.ctsLogger.info("Fetching owners..."),yield this.discord.application.fetch();let t=this.discord.application.owner;if(!t)throw new Error("Cannot find application owner");let e=[];if(t instanceof dt.User)this.owners.add(t.id),e.push(t.tag);else if(t instanceof dt.Team)for(let[n,s]of t.members)this.owners.add(n),e.push(s.user.tag);this.ctsLogger.info(`Fetched ${Kt.default.green(e.length)} owners(${e.map(n=>Kt.default.blue(n)).join(", ")})`)})}enableApplicationCommandsExtension(t){return d(this,null,function*(){yield this.registry.registerModule(new G(t)),this.ctsLogger.info("Application command extension enabled.")})}enableTextCommandsExtension(t){return d(this,null,function*(){yield this.registry.registerModule(new $(t)),this.ctsLogger.info("Text command extension enabled.")})}getApplicationCommandsExtension(){return this.registry.extensions.find(t=>t.constructor===G)}static getFromModule(t){return Reflect.getMetadata(st,t)}};a(Vt,"CommandClient");z=Vt});var Xt,Yt,H,q=h(()=>{"use strict";Xt=require("discord.js");Ht();Yt=class Yt{constructor(){p(this,"method");p(this,"hooks",new Xt.Collection);p(this,"argTypes",new Xt.Collection)}_init(o,t){this.method=o;for(let e=0;e<t.length;e++){let n=t[e];this.argTypes.set(e,new X(n))}}executeGlobalHook(o,t,e){return d(this,null,function*(){let{CommandClient:n}=yield Promise.resolve().then(()=>(ft(),Qt)),s=n.getFromModule(o),m=s.registry.globalHooks[t];if(m)for(let l of m)yield l.call(null,s,...e)})}executeHook(o,t,e){return d(this,null,function*(){let n=this.hooks.get(t);if(!n)return;let{CommandClient:s}=yield Promise.resolve().then(()=>(ft(),Qt)),m=s.getFromModule(o),l=m.registry.globalHooks[t];l&&n.unshift(...l);for(let i of n)yield i.call(null,m,...e)})}execute(n,s){return d(this,arguments,function*(o,t,e=t){yield this.executeHook(o,"beforeCall",e);let m;try{m=yield this.method.call(o,...t),yield this.executeHook(o,"afterCall",[...e,m])}catch(l){throw yield this.executeHook(o,"invokeError",[l,...e]),l}return m})}};a(Yt,"BaseComponent");H=Yt});var Mn,$t=h(()=>{"use strict";Mn=require("reflect-metadata");N();Ht();fo();q()});var to,nt,oo=h(()=>{"use strict";to=class to{};a(to,"OwnerOnlyError");nt=to});var gt,Ro,_o,Io=h(()=>{"use strict";gt=require("discord.js");pt();oo();Ro=a(r=>at("beforeCall",r),"createCheckDecorator"),_o=Ro((r,o)=>d(void 0,null,function*(){let t=!1;if(o instanceof gt.BaseInteraction?t=yield r.isOwner(o.user):o instanceof gt.Message&&(t=yield r.isOwner(o.author)),!t)throw new nt}))});var Zo,To=h(()=>{"use strict";Zo=a(r=>(o,t,e)=>{for(let n of r)n(o,t,e)},"mergeMethodDecorators")});var jo=h(()=>{"use strict";Io();oo();To()});var Lo=h(()=>{"use strict";Dt()});var L=h(()=>{"use strict";$t();pt();Lt();jo();lt();Ot();Lo()});var Jo={};co(Jo,{ApplicationCommandComponent:()=>C,ApplicationCommandExtension:()=>G,BaseComponent:()=>H,CommandClient:()=>z,ComponentArgument:()=>X,ComponentArgumentDecorator:()=>O,ConverterComponent:()=>U,Extension:()=>ot,ListenerComponent:()=>W,OwnerOnlyError:()=>nt,Registry:()=>tt,SubCommandGroup:()=>eo,SubCommandGroupChild:()=>ht,TextCommandComponent:()=>j,TextCommandRestOption:()=>Z,applicationCommand:()=>qo,argConverter:()=>R,command:()=>Bo,createArgumentDecorator:()=>V,createCheckDecorator:()=>Ro,createComponentDecorator:()=>M,createComponentHook:()=>at,getComponent:()=>No,getComponentArgumentStore:()=>kt,getComponentStore:()=>Q,getModuleHookStore:()=>mt,listener:()=>Y,mergeMethodDecorators:()=>Zo,moduleHook:()=>Uo,option:()=>uo,ownerOnly:()=>_o,rest:()=>zo});module.exports=Po(Jo);L();ct();Tt();var no=require("discord.js");L();ct();var ro=class ro{constructor(o,t){p(this,"options");p(this,"guilds");this.options=o,this.guilds=t}command(o){let t=new C(S({type:no.ApplicationCommandType.ChatInput},o));return t.subcommandGroup=this,M(t)}createChild(o){return new ht(o,this)}};a(ro,"SubCommandGroup");var eo=ro,so=class so{constructor(o,t){p(this,"options");p(this,"parent");this.options=o,this.parent=t}command(o){let t=new C(S({type:no.ApplicationCommandType.ChatInput},o));return t.subcommandGroupChild=this,M(t)}};a(so,"SubCommandGroupChild");var ht=so;Ut();zt();Zt();0&&(module.exports={ApplicationCommandComponent,ApplicationCommandExtension,BaseComponent,CommandClient,ComponentArgument,ComponentArgumentDecorator,ConverterComponent,Extension,ListenerComponent,OwnerOnlyError,Registry,SubCommandGroup,SubCommandGroupChild,TextCommandComponent,TextCommandRestOption,applicationCommand,argConverter,command,createArgumentDecorator,createCheckDecorator,createComponentDecorator,createComponentHook,getComponent,getComponentArgumentStore,getComponentStore,getModuleHookStore,listener,mergeMethodDecorators,moduleHook,option,ownerOnly,rest});
1
+ "use strict";var Le=Object.create;var W=Object.defineProperty,Ae=Object.defineProperties,Ee=Object.getOwnPropertyDescriptor,Fe=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertyNames,rt=Object.getOwnPropertySymbols,Oe=Object.getPrototypeOf,xt=Object.prototype.hasOwnProperty,ie=Object.prototype.propertyIsEnumerable;var yt=(r,e,t)=>e in r?W(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,M=(r,e)=>{for(var t in e||(e={}))xt.call(e,t)&&yt(r,t,e[t]);if(rt)for(var t of rt(e))ie.call(e,t)&&yt(r,t,e[t]);return r},A=(r,e)=>Ae(r,Fe(e)),a=(r,e)=>W(r,"name",{value:e,configurable:!0});var ae=(r,e)=>{var t={};for(var o in r)xt.call(r,o)&&e.indexOf(o)<0&&(t[o]=r[o]);if(r!=null&&rt)for(var o of rt(r))e.indexOf(o)<0&&ie.call(r,o)&&(t[o]=r[o]);return t};var h=(r,e)=>()=>(r&&(e=r(r=0)),e);var ce=(r,e)=>{for(var t in e)W(r,t,{get:e[t],enumerable:!0})},me=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of $e(e))!xt.call(r,n)&&n!==t&&W(r,n,{get:()=>e[n],enumerable:!(o=Ee(e,n))||o.enumerable});return r};var G=(r,e,t)=>(t=r!=null?Le(Oe(r)):{},me(e||!r||!r.__esModule?W(t,"default",{value:r,enumerable:!0}):t,r)),We=r=>me(W({},"__esModule",{value:!0}),r);var p=(r,e,t)=>(yt(r,typeof e!="symbol"?e+"":e,t),t);var d=(r,e,t)=>new Promise((o,n)=>{var s=i=>{try{l(t.next(i))}catch(u){n(u)}},m=i=>{try{l(t.throw(i))}catch(u){n(u)}},l=i=>i.done?o(i.value):Promise.resolve(i.value).then(s,m);l((t=t.apply(r,e)).next())});var K,Ke,bt,st,Ct,it,D=h(()=>{"use strict";K=Symbol(),Ke=Symbol(),bt=Symbol(),st=Symbol(),Ct=Symbol(),it=Symbol()});var pe,wt,at,St=h(()=>{"use strict";pe=require("discord.js");D();wt=a((r,e)=>{let t=Reflect.getMetadata(Ct,r,e);return t||(t=new pe.Collection,Reflect.defineMetadata(Ct,t,r,e)),t},"getComponentHookStore"),at=a((r,e)=>(t,o)=>{let n=wt(t,o),s=n.get(r);s||(s=[],n.set(r,s)),s.unshift(e)},"createComponentHook")});var Mt,Q,De,k,kt,V,N=h(()=>{"use strict";Mt=require("discord.js");St();D();Q=a(r=>{let e=Reflect.getMetadata(K,r);return e||(e=new Mt.Collection,Reflect.defineMetadata(K,e,r)),e},"getComponentStore"),De=a((r,e)=>Q(r).get(e),"getComponent"),k=a(r=>(e,t)=>{r._init(Reflect.get(e,t),Reflect.getMetadata("design:paramtypes",e,t));let o=wt(e,t);r.hooks=o;let n=Q(e);kt(e,t).forEach((m,l)=>{var i;(i=r.argTypes.get(l))==null||i.decorators.push(m)}),n.set(t,r)},"createComponentDecorator"),kt=a((r,e)=>{let t=Reflect.getMetadata(K,r,e);return t||(t=new Mt.Collection,Reflect.defineMetadata(K,t,r,e)),t},"getComponentArgumentStore"),V=a(r=>e=>(t,o,n)=>{if(!o)return;let s=new r(e);kt(t,o).set(n,s)},"createArgumentDecorator")});var vt,X,Ht=h(()=>{"use strict";vt=class vt{constructor(e){p(this,"type");p(this,"decorators");this.type=e,this.decorators=[]}};a(vt,"ComponentArgument");X=vt});var le,Gt,$,fe=h(()=>{"use strict";le=G(require("lodash")),Gt=class Gt{constructor(e){p(this,"options");typeof e=="object"?this.options=le.default.merge(this.defaultOptions(),e):this.options=e}defaultOptions(){return{}}};a(Gt,"ComponentArgumentDecorator");$=Gt});var Rt,C,Ne,ct=h(()=>{"use strict";N();q();Rt=class Rt extends R{constructor(t){super();p(this,"options");p(this,"subcommandGroup");p(this,"subcommandGroupChild");this.options=t}};a(Rt,"ApplicationCommandComponent");C=Rt,Ne=a(r=>k(new C(r)),"applicationCommand")});var It,E,ue,Tt=h(()=>{"use strict";L();It=class It extends ${};a(It,"ApplicationCommandOption");E=It,ue=V(E)});var jt,U,T,Pt=h(()=>{"use strict";q();N();jt=class jt extends R{constructor(t){super();p(this,"options");this.options=t}};a(jt,"ConverterComponent");U=jt,T=a(r=>k(new U(r)),"argConverter")});var de,mt,qe,ge=h(()=>{"use strict";de=require("discord.js");D();mt=a(r=>{let e=Reflect.getMetadata(bt,r);return e||(e=new de.Collection,Reflect.defineMetadata(bt,e,r)),e},"getModuleHookStore"),qe=a(r=>(e,t)=>{let o=mt(e),n=o.get(r);n||(n=[],o.set(r,n)),n.push(Reflect.get(e,t))},"moduleHook")});var pt=h(()=>{"use strict";ge();St()});var he,Lt,O,Y,lt=h(()=>{"use strict";he=G(require("lodash"));q();N();Lt=class Lt extends R{constructor(t){super();p(this,"options");this.options=he.default.merge({emitter:"discord"},t)}};a(Lt,"ListenerComponent");O=Lt,Y=a(r=>k(new O(r)),"listener")});var B,ye,xe,be,Ce,At,tt,Et=h(()=>{"use strict";B=G(require("chalk")),ye=require("discord.js"),xe=G(require("lodash"));Ft();pt();lt();D();be=G(require("walk-sync")),Ce=G(require("path")),At=class At{constructor(e,t){p(this,"client");p(this,"extensions");p(this,"emitters");p(this,"logger");p(this,"globalHooks");this.client=t,this.extensions=[],this.emitters=new ye.Collection,this.globalHooks={},this.logger=e.getSubLogger({name:B.default.green("Registry")})}addGlobalHook(e,t){let o=this.globalHooks[e];o||(o=[],this.globalHooks[e]=o),o.push(t)}getComponentsWithTypeGlobal(e){let t=[];for(let o of this.extensions)t.push(...this.getComponentsWithType(o,e));return t}getComponentsWithType(e,t){let o=Q(e);return Array.from(o.filter(n=>n.constructor===t).values())}registerEventListeners(e){let t=this.getComponentsWithType(e,O);for(let o of t){let n=this.emitters.get(o.options.emitter);if(n){let s=o.method.bind(e);Reflect.defineMetadata("bound",s,o),n.addListener(o.options.event,s)}}}unregisterEventListeners(e){let t=this.getComponentsWithType(e,O);for(let o of t){let n=this.emitters.get(o.options.emitter),s=Reflect.getMetadata("bound",o);n&&s&&n.removeListener(o.options.event,s)}}loadAllModulesInDirectory(e,t){return d(this,null,function*(){let o=[],n=(0,be.default)(e).filter(s=>(s.endsWith(".ts")||s.endsWith(".js"))&&(!t||t.test(s)));for(let s of n){if(s.endsWith(".d.ts"))continue;let m=Ce.default.join(e,s);o.push(...yield this.loadModulesAtPath(m))}return o})}loadModulesAtPath(e){return d(this,null,function*(){this.logger.info(`Loading module at path ${B.default.green(e)}`);let t=require.resolve(e),o=require(t);if(typeof o.setup!="function")throw new Error("Extension must have a setup function");let n=yield o.setup(this.client);return this.registerModules(n,t)})}registerModules(e,t){return d(this,null,function*(){let o=[];if(e instanceof Array)for(let n of e)yield this.registerModule(n),Reflect.defineMetadata(it,t,n),o.push(n);else yield this.registerModule(e),Reflect.defineMetadata(it,t,e),o.push(e);return o})}reloadModules(){return d(this,null,function*(){let e=[],t=new Set,o=[...this.extensions];for(let n of o){let s=Reflect.getMetadata(it,n);s&&(this.logger.info(`Unloading module: ${B.default.green(n.constructor.name)}`),t.add(s),yield this.unregisterModule(n),delete require.cache[require.resolve(s)])}for(let n of t)try{let s=yield this.loadModulesAtPath(n);e.push({file:n,result:!0,extensions:s})}catch(s){e.push({file:n,result:!1,error:s})}return e})}registerModule(e){return d(this,null,function*(){Reflect.defineMetadata(st,this.client,e),this.registerEventListeners(e),yield this.runModuleHook(e,"load"),this.extensions.push(e),this.logger.info(`Module registered: ${B.default.green(e.constructor.name)}`)})}unregisterModule(e){return d(this,null,function*(){this.unregisterEventListeners(e),yield this.runModuleHook(e,"unload"),xe.default.remove(this.extensions,t=>t===e),this.logger.info(`Module unregistered: ${B.default.green(e.constructor.name)}`)})}runModuleHook(e,t,...o){let s=mt(e).get(t);if(s)for(let m of s)m.call(e,...o)}registerEventEmitter(e,t){this.emitters.set(e,t)}};a(At,"Registry");tt=At});var $t=h(()=>{"use strict";Et();ft()});var we,Se,Ot,et,Wt=h(()=>{"use strict";we=G(require("chalk")),Se=require("discord.js");Pt();$t();Ot=class Ot{constructor(){p(this,"_logger")}get commandClient(){return z.getFromModule(this)}get client(){return this.commandClient.discord}get logger(){return this._logger||(this._logger=this.commandClient.logger.getSubLogger({name:we.default.green(`${this.constructor.name}`)})),this._logger}convertArguments(e,t,o,n){return d(this,null,function*(){let s=new Se.Collection;for(let m of this.commandClient.registry.extensions)for(let l of this.commandClient.registry.getComponentsWithType(m,U))l.options.component==e&&s.set(l.options.type,{component:l,ext:m});for(let[m,l]of o){let i=s.get(l.type);if(!i){t[m]=void 0;continue}let u=yield n(l,m,i.component);t[m]=yield i.component.execute(i.ext,u)}})}};a(Ot,"Extension");et=Ot});var Me,Dt,_,Nt=h(()=>{"use strict";Me=G(require("chalk"));Wt();Dt=class Dt extends et{get logger(){return this._logger||(this._logger=this.commandClient.ctsLogger.getSubLogger({name:Me.default.green(`${this.constructor.name}`)})),this._logger}};a(Dt,"CTSExtension");_=Dt});function ot(r,e,t,o){var n=arguments.length,s=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,o);else for(var l=r.length-1;l>=0;l--)(m=r[l])&&(s=(n<3?m(s):n>3?m(e,t,s):m(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function w(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}var j,x,v,qt,I,Ut=h(()=>{"use strict";j=G(require("chalk")),x=require("discord.js"),v=require("discord-api-types/v10");ct();Tt();L();L();Nt();a(ot,"_ts_decorate");a(w,"_ts_metadata");qt=class qt extends _{constructor(t){super();p(this,"config");p(this,"unmanagedCommands");this.config=t,this.unmanagedCommands=[]}registerUnmanagedCommand(t){this.unmanagedCommands.push(t)}interactionCreate(t){return d(this,null,function*(){var o;try{if(!t.isCommand())return;let n=null,s=null,m=this.commandClient.registry.extensions,l=null,i=null;t.isChatInputCommand()&&(l=t.options.getSubcommand(!1),i=t.options.getSubcommandGroup(!1));t:for(let u of m){let f=this.commandClient.registry.getComponentsWithType(u,C);if(l){for(let c of f)if(!(!c.subcommandGroup&&!c.subcommandGroupChild)){if(c.subcommandGroupChild&&c.subcommandGroupChild.parent.options.name===t.commandName&&c.subcommandGroupChild.options.name===i&&c.options.name===l){s=u,n=c;break t}if(c.subcommandGroup&&!i&&c.subcommandGroup.options.name===t.commandName&&c.options.name===l){s=u,n=c;break t}}}else for(let c of f)if(c.options.name===t.commandName){s=u,n=c;break t}}if(n&&s){let u=[];yield this.convertArguments(C,u,n.argTypes,()=>[t]);for(let[f,c]of n.argTypes){let g=null;for(let y of c.decorators)if(y instanceof E){if([v.ApplicationCommandOptionType.Subcommand,v.ApplicationCommandOptionType.SubcommandGroup].includes(y.options.type)&&t.isChatInputCommand()){if(y.options.type===v.ApplicationCommandOptionType.Subcommand){g=t.options.getSubcommand()===y.options.name;break}if(y.options.type===v.ApplicationCommandOptionType.SubcommandGroup){g=t.options.getSubcommandGroup()===y.options.name;break}}g=(o=t.options.get(y.options.name,!1))==null?void 0:o.value;break}g&&(u[f]=g)}try{yield n.executeGlobalHook(s,"beforeApplicationCommandCall",[t]),yield n.execute(s,u,[t])}finally{yield n.executeGlobalHook(s,"afterApplicationCommandCall",[t])}}}catch(n){this.commandClient.emit("applicationCommandInvokeError",n,t)}})}sync(){return d(this,null,function*(){let t=this.commandClient;this.logger.info("Trying to sync commands...");let o=[],n=new x.Collection,s=new x.Collection;for(let i of t.registry.getComponentsWithTypeGlobal(C)){if(i.subcommandGroup){let f=s.get(i.subcommandGroup.options.name);if(!f){if(f=A(M({},i.subcommandGroup.options),{type:v.ApplicationCommandType.ChatInput}),i.subcommandGroup.guilds)for(let g of i.subcommandGroup.guilds){let y=n.get(g);y||(y=[],n.set(g,y))}else o.push(f);s.set(i.subcommandGroup.options.name,f)}f.options||(f.options=[]);let c=[];for(let[,g]of i.argTypes){let y=g.decorators.find(b=>b.constructor===E);y&&c.push(y.options)}f.options.push(A(M({},i.options),{type:v.ApplicationCommandOptionType.Subcommand,options:c}));continue}else if(i.subcommandGroupChild){let f=i.subcommandGroupChild.parent,c=s.get(f.options.name);if(!c){if(c=A(M({},f.options),{type:v.ApplicationCommandType.ChatInput}),f.guilds)for(let b of f.guilds){let S=n.get(b);S||(S=[],n.set(b,S))}else o.push(c);s.set(f.options.name,c)}c.options||(c.options=[]);let g=c.options.find(b=>{var S;return b.name===((S=i.subcommandGroupChild)==null?void 0:S.options.name)});g||(g=A(M({},i.subcommandGroupChild.options),{type:v.ApplicationCommandOptionType.SubcommandGroup}),c.options.push(g)),g.options||(g.options=[]);let y=[];for(let[,b]of i.argTypes){let S=b.decorators.find(Pe=>Pe.constructor===E);S&&y.push(S.options)}g.options.push(A(M({},i.options),{type:v.ApplicationCommandOptionType.Subcommand,options:y}));continue}let u=M({},i.options);if(u.type===v.ApplicationCommandType.ChatInput){u.options=[];for(let[,f]of i.argTypes){let c=f.decorators.find(g=>g.constructor===E);c&&u.options.push(c.options)}}if(yield i.executeHook(this,"beforeSync",[u,i]),i.options.guilds){for(let f of i.options.guilds){let c=n.get(f);c||(c=[],n.set(f,c)),c.push(u)}continue}o.push(u)}for(let m of this.unmanagedCommands){let l=m,{guilds:i}=l,u=ae(l,["guilds"]);if(i)for(let f of i){let c=n.get(f);c||(c=[],n.set(f,c)),c.push(u)}else o.push(u)}if(this.config.guilds){for(let i of this.config.guilds){let u=n.get(i);u||(u=[],n.set(i,u)),u.push(...o)}o=[]}if(n.size)for(let[i,u]of n)try{let f=yield this.client.guilds.fetch(i);yield f.fetch(),this.logger.info(`Processing ${j.default.green(u.length)} commands(${u.map(c=>j.default.blue(c.name)).join(", ")}) for guild ${j.default.green(f.name)}(${j.default.blue(f.id)})`),yield f.commands.set(u),this.logger.info(`Successfully registered commands for guild ${j.default.green(f.name)}(${j.default.blue(f.id)})`)}catch(f){this.logger.error(`Failed to register commands to guild ${j.default.green(i)}: ${f.message}`)}if(o.length)try{this.logger.info(`Processing ${j.default.green(o.length)} commands(${o.map(i=>j.default.blue(i.name)).join(", ")}) for application scope...`),this.client.application?(yield this.client.application.commands.set(o),this.logger.info("Successfully registered commands.")):this.logger.error("Client#application is not yet initialized.")}catch(i){this.logger.error(`Failed to register commands to global: ${i.message}`)}})}chatInteraction(t){return d(this,null,function*(){return t})}messageInteraction(t){return d(this,null,function*(){return t})}userInteraction(t){return d(this,null,function*(){return t})}commandInteraction(t){return d(this,null,function*(){return t})}};a(qt,"ApplicationCommandExtension");I=qt;ot([Y({event:"interactionCreate"}),w("design:type",Function),w("design:paramtypes",[typeof Interaction=="undefined"?Object:Interaction]),w("design:returntype",Promise)],I.prototype,"interactionCreate",null);ot([T({component:C,parameterless:!0,type:x.ChatInputCommandInteraction}),w("design:type",Function),w("design:paramtypes",[typeof x.ChatInputCommandInteraction=="undefined"?Object:x.ChatInputCommandInteraction]),w("design:returntype",Promise)],I.prototype,"chatInteraction",null);ot([T({component:C,parameterless:!0,type:x.MessageContextMenuCommandInteraction}),w("design:type",Function),w("design:paramtypes",[typeof x.MessageContextMenuCommandInteraction=="undefined"?Object:x.MessageContextMenuCommandInteraction]),w("design:returntype",Promise)],I.prototype,"messageInteraction",null);ot([T({component:C,parameterless:!0,type:x.UserContextMenuCommandInteraction}),w("design:type",Function),w("design:paramtypes",[typeof x.UserContextMenuCommandInteraction=="undefined"?Object:x.UserContextMenuCommandInteraction]),w("design:returntype",Promise)],I.prototype,"userInteraction",null);ot([T({component:C,parameterless:!0,type:x.CommandInteraction}),w("design:type",Function),w("design:paramtypes",[typeof x.UserContextMenuCommandInteraction=="undefined"?Object:x.UserContextMenuCommandInteraction]),w("design:returntype",Promise)],I.prototype,"commandInteraction",null)});var Bt,P,Ue,zt=h(()=>{"use strict";N();q();Bt=class Bt extends R{constructor(t){super();p(this,"options");this.options=t}};a(Bt,"TextCommandComponent");P=Bt,Ue=a(r=>k(new P(r)),"command")});var _t,Z,Be,Zt=h(()=>{"use strict";L();L();_t=class _t extends ${};a(_t,"TextCommandRestOption");Z=_t,Be=V(Z)});function ut(r,e,t,o){var n=arguments.length,s=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(r,e,t,o);else for(var l=r.length-1;l>=0;l--)(m=r[l])&&(s=(n<3?m(s):n>3?m(e,t,s):m(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s}function H(r,e){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(r,e)}var J,Jt,F,ke=h(()=>{"use strict";lt();J=require("discord.js");Nt();zt();Zt();L();a(ut,"_ts_decorate");a(H,"_ts_metadata");Jt=class Jt extends _{constructor(t){super();p(this,"config");this.config=t}processPrefix(t){return d(this,null,function*(){let o=t.content,n=this.config.prefix;if(typeof n=="function"&&(n=yield n(t)),typeof n=="string")return o.startsWith(n)?n.length:null;if(n instanceof Array){let s=n.find(m=>o.startsWith(m));return s?s.length:null}return null})}messageCreate(t){return d(this,null,function*(){try{let o=yield this.processPrefix(t);if(o===null)return;let n=t.content.slice(o),s=[],m=new Map;for(let g of this.commandClient.registry.extensions)for(let y of this.commandClient.registry.getComponentsWithType(g,P))s.push(y),m.set(y,g);let l=0,i=s.find(g=>{let y=[g.options.name];g.options.aliases&&y.push(...g.options.aliases);for(let b of y)if(n.startsWith(b))return n.length===b.length?(l=b.length,!0):(l=b.length,n.startsWith(b+" "));return!1});if(!i)return;let u=m.get(i);if(!u)return;t.command=i;let f=[],c=n.slice(l+1).split(/ /g);yield this.convertArguments(P,f,i.argTypes,(g,y,b)=>d(this,null,function*(){if(b.options.parameterless)return[t];if(g.decorators.find(S=>S.constructor===Z)){let S=c.join(" ");return c=[],[S,t]}return[c.shift(),t]})),yield i.execute(u,f,[t])}catch(o){this.commandClient.emit("textCommandInvokeError",o,t)}})}mesage(t){return d(this,null,function*(){return t})}str(t){return d(this,null,function*(){return t})}num(t){return d(this,null,function*(){return Number(t)})}};a(Jt,"TextCommandExtension");F=Jt;ut([Y({event:"messageCreate",emitter:"discord"}),H("design:type",Function),H("design:paramtypes",[typeof J.Message=="undefined"?Object:J.Message]),H("design:returntype",Promise)],F.prototype,"messageCreate",null);ut([T({component:P,type:J.Message,parameterless:!0}),H("design:type",Function),H("design:paramtypes",[typeof J.Message=="undefined"?Object:J.Message]),H("design:returntype",Promise)],F.prototype,"mesage",null);ut([T({component:P,type:String}),H("design:type",Function),H("design:paramtypes",[String]),H("design:returntype",Promise)],F.prototype,"str",null);ut([T({component:P,type:Number}),H("design:type",Function),H("design:paramtypes",[String]),H("design:returntype",Promise)],F.prototype,"num",null)});var Qt={};ce(Qt,{CommandClient:()=>z});var Kt,dt,ve,He,Vt,z,ft=h(()=>{"use strict";Kt=G(require("chalk")),dt=require("discord.js"),ve=G(require("events")),He=require("tslog");Ut();ke();D();Et();Vt=class Vt extends ve.default{constructor(t,o=new He.Logger({prettyLogTimeZone:"local"}),n={}){super();p(this,"discord");p(this,"logger");p(this,"ctsLogger");p(this,"registry");p(this,"owners");this.discord=t,this.logger=o,this.owners=new Set,this.ctsLogger=o.getSubLogger(A(M({},n),{name:"command.ts"})),this.registry=new tt(this.ctsLogger,this),this.registry.registerEventEmitter("cts",this),this.registry.registerEventEmitter("discord",this.discord)}isOwner(t){return d(this,null,function*(){return this.owners.has(t.id)})}fetchOwners(){return d(this,null,function*(){if(!this.discord.application)throw new Error("The client is not logged in.");this.ctsLogger.info("Fetching owners..."),yield this.discord.application.fetch();let t=this.discord.application.owner;if(!t)throw new Error("Cannot find application owner");let o=[];if(t instanceof dt.User)this.owners.add(t.id),o.push(t.tag);else if(t instanceof dt.Team)for(let[n,s]of t.members)this.owners.add(n),o.push(s.user.tag);this.ctsLogger.info(`Fetched ${Kt.default.green(o.length)} owners(${o.map(n=>Kt.default.blue(n)).join(", ")})`)})}enableApplicationCommandsExtension(t){return d(this,null,function*(){yield this.registry.registerModule(new I(t)),this.ctsLogger.info("Application command extension enabled.")})}enableTextCommandsExtension(t){return d(this,null,function*(){yield this.registry.registerModule(new F(t)),this.ctsLogger.info("Text command extension enabled.")})}getApplicationCommandsExtension(){return this.registry.extensions.find(t=>t.constructor===I)}static getFromModule(t){return Reflect.getMetadata(st,t)}};a(Vt,"CommandClient");z=Vt});var Xt,Yt,R,q=h(()=>{"use strict";Xt=require("discord.js");Ht();Yt=class Yt{constructor(){p(this,"method");p(this,"hooks",new Xt.Collection);p(this,"argTypes",new Xt.Collection)}_init(e,t){this.method=e;for(let o=0;o<t.length;o++){let n=t[o];this.argTypes.set(o,new X(n))}}executeGlobalHook(e,t,o){return d(this,null,function*(){let{CommandClient:n}=yield Promise.resolve().then(()=>(ft(),Qt)),s=n.getFromModule(e),m=s.registry.globalHooks[t];if(m)for(let l of m)yield l.call(null,s,...o)})}executeHook(e,t,o){return d(this,null,function*(){let n=this.hooks.get(t);if(!n)return;let{CommandClient:s}=yield Promise.resolve().then(()=>(ft(),Qt)),m=s.getFromModule(e),l=m.registry.globalHooks[t];l&&n.unshift(...l);for(let i of n)yield i.call(null,m,...o)})}execute(n,s){return d(this,arguments,function*(e,t,o=t){yield this.executeHook(e,"beforeCall",o);let m;try{m=yield this.method.call(e,...t),yield this.executeHook(e,"afterCall",[...o,m])}catch(l){throw yield this.executeHook(e,"invokeError",[l,...o]),l}return m})}};a(Yt,"BaseComponent");R=Yt});var Mn,Ft=h(()=>{"use strict";Mn=require("reflect-metadata");N();Ht();fe();q()});var te,nt,ee=h(()=>{"use strict";te=class te{};a(te,"OwnerOnlyError");nt=te});var gt,Ge,ze,Re=h(()=>{"use strict";gt=require("discord.js");pt();ee();Ge=a(r=>at("beforeCall",r),"createCheckDecorator"),ze=Ge((r,e)=>d(void 0,null,function*(){let t=!1;if(e instanceof gt.BaseInteraction?t=yield r.isOwner(e.user):e instanceof gt.Message&&(t=yield r.isOwner(e.author)),!t)throw new nt}))});var _e,Ie=h(()=>{"use strict";_e=a(r=>(e,t,o)=>{for(let n of r)n(e,t,o)},"mergeMethodDecorators")});var Te=h(()=>{"use strict";Re();ee();Ie()});var je=h(()=>{"use strict";Wt()});var L=h(()=>{"use strict";Ft();pt();Pt();Te();lt();$t();je()});var Ze={};ce(Ze,{ApplicationCommandComponent:()=>C,ApplicationCommandExtension:()=>I,BaseComponent:()=>R,CommandClient:()=>z,ComponentArgument:()=>X,ComponentArgumentDecorator:()=>$,ConverterComponent:()=>U,Extension:()=>et,ListenerComponent:()=>O,OwnerOnlyError:()=>nt,Registry:()=>tt,SubCommandGroup:()=>oe,SubCommandGroupChild:()=>ht,TextCommandComponent:()=>P,TextCommandRestOption:()=>Z,applicationCommand:()=>Ne,argConverter:()=>T,command:()=>Ue,createArgumentDecorator:()=>V,createCheckDecorator:()=>Ge,createComponentDecorator:()=>k,createComponentHook:()=>at,getComponent:()=>De,getComponentArgumentStore:()=>kt,getComponentStore:()=>Q,getModuleHookStore:()=>mt,listener:()=>Y,mergeMethodDecorators:()=>_e,moduleHook:()=>qe,option:()=>ue,ownerOnly:()=>ze,rest:()=>Be});module.exports=We(Ze);L();ct();Tt();var ne=require("discord.js");L();ct();var re=class re{constructor(e,t){p(this,"options");p(this,"guilds");this.options=e,this.guilds=t}command(e){let t=new C(M({type:ne.ApplicationCommandType.ChatInput},e));return t.subcommandGroup=this,k(t)}createChild(e){return new ht(e,this)}};a(re,"SubCommandGroup");var oe=re,se=class se{constructor(e,t){p(this,"options");p(this,"parent");this.options=e,this.parent=t}command(e){let t=new C(M({type:ne.ApplicationCommandType.ChatInput},e));return t.subcommandGroupChild=this,k(t)}};a(se,"SubCommandGroupChild");var ht=se;Ut();zt();Zt();0&&(module.exports={ApplicationCommandComponent,ApplicationCommandExtension,BaseComponent,CommandClient,ComponentArgument,ComponentArgumentDecorator,ConverterComponent,Extension,ListenerComponent,OwnerOnlyError,Registry,SubCommandGroup,SubCommandGroupChild,TextCommandComponent,TextCommandRestOption,applicationCommand,argConverter,command,createArgumentDecorator,createCheckDecorator,createComponentDecorator,createComponentHook,getComponent,getComponentArgumentStore,getComponentStore,getModuleHookStore,listener,mergeMethodDecorators,moduleHook,option,ownerOnly,rest});
2
2
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/core/symbols.ts","../src/core/hooks/componentHook.ts","../src/core/components/decoratorCreator.ts","../src/core/components/ComponentArgument.ts","../src/core/components/ComponentArgumentDecorator.ts","../src/applicationCommand/ApplicationCommand.ts","../src/applicationCommand/ApplicationCommandOption.ts","../src/core/converter/index.ts","../src/core/hooks/moduleHook.ts","../src/core/hooks/index.ts","../src/core/listener/index.ts","../src/core/structures/Registry.ts","../src/core/structures/index.ts","../src/core/extensions/Extension.ts","../src/core/extensions/CTSExtension.ts","../src/applicationCommand/ApplicationCommandExtension.ts","../src/textCommand/TextCommand.ts","../src/textCommand/parameters.ts","../src/textCommand/TextCommandExtension.ts","../src/core/structures/CommandClient.ts","../src/core/components/BaseComponent.ts","../src/core/components/index.ts","../src/core/utils/errors.ts","../src/core/utils/checks.ts","../src/core/utils/decorators.ts","../src/core/utils/index.ts","../src/core/extensions/index.ts","../src/core/index.ts","../src/index.ts","../src/applicationCommand/index.ts","../src/applicationCommand/group.ts","../src/textCommand/index.ts"],"sourcesContent":["export const ComponentStoreSymbol = Symbol()\nexport const ComponentArgStoreSymbol = Symbol()\nexport const ModuleHookStoreSymbol = Symbol()\nexport const CommandClientSymbol = Symbol()\nexport const ComponentHookSymbol = Symbol()\nexport const FilePathSymbol = Symbol()\n","import { Collection } from 'discord.js'\nimport { ComponentHookSymbol } from '../symbols'\n\nexport type ComponentHookFn<T extends unknown[]> = (...args: T) => void | Promise<void>\n\nexport type ComponentHookStore = Collection<string, ComponentHookFn<unknown[]>[]>\n\nexport const getComponentHookStore = (target: object, property: string | symbol): ComponentHookStore => {\n let data = Reflect.getMetadata(ComponentHookSymbol, target, property) as ComponentHookStore\n\n if (!data) {\n data = new Collection()\n Reflect.defineMetadata(ComponentHookSymbol, data, target, property)\n }\n\n return data\n}\n\nexport const createComponentHook = <T extends unknown[]>(name: string, fn: ComponentHookFn<T>): MethodDecorator => {\n return (target, key) => {\n const store = getComponentHookStore(target, key)\n\n let hooks = store.get(name)\n\n if (!hooks) {\n hooks = []\n store.set(name, hooks)\n }\n\n // @ts-expect-error unknown type\n hooks.unshift(fn)\n }\n}\n","import { Collection } from 'discord.js'\nimport type { ComponentHookStore } from '../hooks'\nimport { getComponentHookStore } from '../hooks/componentHook'\nimport { ComponentStoreSymbol } from '../symbols'\nimport type { BaseComponent } from './BaseComponent'\nimport type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport type ComponentStore = Collection<string | symbol, BaseComponent>\nexport type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>\n\nexport const getComponentStore = (target: object): ComponentStore => {\n let result: ComponentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const getComponent = (target: object, key: string | symbol) => {\n const store = getComponentStore(target)\n\n return store.get(key)\n}\n\nexport const createComponentDecorator = (component: BaseComponent): MethodDecorator => {\n return (target, key) => {\n component._init(Reflect.get(target, key), Reflect.getMetadata('design:paramtypes', target, key))\n\n const componentHookStore: ComponentHookStore = getComponentHookStore(target, key)\n\n component.hooks = componentHookStore\n\n const store = getComponentStore(target)\n\n const decorators = getComponentArgumentStore(target, key)\n\n decorators.forEach((x, i) => {\n component.argTypes.get(i)?.decorators.push(x)\n })\n\n store.set(key, component)\n }\n}\n\nexport const getComponentArgumentStore = (target: object, key: string | symbol): ComponentArgumentStore => {\n let result: ComponentArgumentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target, key)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target, key)\n }\n\n return result\n}\n\nexport const createArgumentDecorator = <Options>(type: typeof ComponentArgumentDecorator<Options>) => {\n return (options: Options): ParameterDecorator => {\n return (target, key, idx) => {\n if (!key) return\n\n const arg: ComponentArgumentDecorator<Options> = new type(options)\n\n const store = getComponentArgumentStore(target, key)\n\n store.set(idx, arg)\n }\n }\n}\n","import type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport class ComponentArgument {\n decorators: ComponentArgumentDecorator[] = []\n\n constructor(public type: unknown) {}\n}\n","import _ from 'lodash'\n\nexport class ComponentArgumentDecorator<Options = unknown> {\n options: Options\n\n constructor(options: Partial<Options>) {\n if (typeof options === 'object') {\n this.options = _.merge(this.defaultOptions(), options)\n } else {\n this.options = options\n }\n }\n\n defaultOptions(): Options {\n return {} as unknown as Options\n }\n}\n","import type { ApplicationCommandType, ChatInputApplicationCommandData, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js'\nimport { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\nimport type { SubCommandGroup, SubCommandGroupChild } from './group'\n\ntype Options = (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {\n type: ApplicationCommandType\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandComponent extends BaseComponent {\n options: Options\n\n subcommandGroup?: SubCommandGroup\n subcommandGroupChild?: SubCommandGroupChild\n\n constructor(options: UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) {\n super()\n\n this.options = options as Options\n }\n}\n\nexport const applicationCommand = (options: Options) => createComponentDecorator(new ApplicationCommandComponent(options))\n\nexport type { Options as ApplicationCommandComponentOptions }\n","import type { ApplicationCommandOptionData } from 'discord.js'\nimport { createArgumentDecorator, ComponentArgumentDecorator } from '../core'\n\ntype Options = ApplicationCommandOptionData\n\nexport class ApplicationCommandOption extends ComponentArgumentDecorator<Options> {}\n\nexport const option = createArgumentDecorator(ApplicationCommandOption)\n","import { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options<T> = { component: unknown; type: T; parameterless: boolean }\n\ntype OptionsArg<T> = Omit<Options<T>, 'parameterless'> & { parameterless?: boolean }\n\nexport class ConverterComponent<T> extends BaseComponent {\n options: Options<T>\n\n constructor(options: OptionsArg<T>) {\n super()\n this.options = options as Options<T>\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const argConverter = <T>(options: OptionsArg<T>) => createComponentDecorator(new ConverterComponent(options))\n\nexport { Options as ArgumentConvertOptions, OptionsArg as ArgumentConvertOptionsArg }\n","import { Collection } from 'discord.js'\nimport { ModuleHookStoreSymbol } from '../symbols'\nimport type { ComponentHookFn } from './componentHook'\n\nexport type ModuleHookStore = Collection<string, ComponentHookFn<unknown[]>[]>\n\nexport const getModuleHookStore = (target: object) => {\n let result: ModuleHookStore | null = Reflect.getMetadata(ModuleHookStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ModuleHookStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const moduleHook = (name: string): MethodDecorator => {\n return (target, key) => {\n const store = getModuleHookStore(target)\n\n let v = store.get(name)\n\n if (!v) {\n v = []\n store.set(name, v)\n }\n\n v.push(Reflect.get(target, key))\n }\n}\n","export * from './moduleHook'\nexport { createComponentHook, type ComponentHookFn } from './componentHook'\nexport type { ComponentHookStore } from './componentHook'\n","import _ from 'lodash'\nimport { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options = { emitter: string; event: string }\n\ntype OptionsArg = { emitter?: string; event: string }\n\nexport class ListenerComponent extends BaseComponent {\n options: Options\n\n constructor(options: OptionsArg) {\n super()\n\n this.options = _.merge({ emitter: 'discord' }, options)\n }\n}\n\nexport const listener = (options: OptionsArg) => createComponentDecorator(new ListenerComponent(options))\n\nexport { Options as ListenerOptions, OptionsArg as ListenerOptionsArg }\n","import chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport type EventEmitter from 'events'\nimport _ from 'lodash'\nimport type { Logger } from 'tslog'\nimport { getComponentStore } from '../components'\nimport { getModuleHookStore } from '../hooks'\nimport { ListenerComponent } from '../listener'\nimport { CommandClientSymbol, FilePathSymbol } from '../symbols'\nimport type { CommandClient } from './CommandClient'\nimport walkSync from 'walk-sync'\nimport path from 'path'\nimport type { ComponentHookFn } from '../hooks/componentHook'\n\nexport class Registry {\n extensions: object[] = []\n\n emitters: Collection<string, EventEmitter> = new Collection()\n\n logger: Logger<unknown>\n\n globalHooks: Record<string, ComponentHookFn<unknown[]>[]> = {}\n\n constructor(\n logger: Logger<unknown>,\n public client: CommandClient,\n ) {\n this.logger = logger.getSubLogger({\n name: chalk.green('Registry'),\n })\n }\n\n addGlobalHook(name: string, fn: ComponentHookFn<unknown[]>) {\n let hooks = this.globalHooks[name]\n\n if (!hooks) {\n hooks = []\n this.globalHooks[name] = hooks\n }\n\n hooks.push(fn)\n }\n\n getComponentsWithTypeGlobal<T>(type: unknown): T[] {\n const result: T[] = []\n\n for (const ext of this.extensions) {\n result.push(...this.getComponentsWithType<T>(ext, type))\n }\n\n return result\n }\n\n getComponentsWithType<T>(ext: object, type: unknown): T[] {\n const componentStore = getComponentStore(ext)\n\n return Array.from(componentStore.filter((x) => (x.constructor as unknown) === type).values() as Iterable<T>)\n }\n\n registerEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n\n if (emitter) {\n const bound = listener.method.bind(ext)\n\n Reflect.defineMetadata('bound', bound, listener)\n\n emitter.addListener(listener.options.event, bound)\n }\n }\n }\n\n unregisterEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n const bound = Reflect.getMetadata('bound', listener)\n\n if (emitter && bound) {\n emitter.removeListener(listener.options.event, bound)\n }\n }\n }\n\n async loadAllModulesInDirectory(dir: string, pattern?: RegExp): Promise<object[]> {\n const results: object[] = []\n\n const files = walkSync(dir).filter((x) => (x.endsWith('.ts') || x.endsWith('.js')) && (!pattern || pattern.test(x)))\n\n for (const file of files) {\n if (file.endsWith('.d.ts')) continue\n const p = path.join(dir, file)\n results.push(...(await this.loadModulesAtPath(p)))\n }\n\n return results\n }\n\n async loadModulesAtPath(file: string) {\n this.logger.info(`Loading module at path ${chalk.green(file)}`)\n\n const p = require.resolve(file)\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(p)\n\n if (typeof mod.setup !== 'function') throw new Error('Extension must have a setup function')\n\n const modules = await mod.setup(this.client)\n\n return this.registerModules(modules, p)\n }\n\n private async registerModules(modules: object | object[], p: string) {\n const results: object[] = []\n if (modules instanceof Array) {\n for (const module of modules) {\n await this.registerModule(module)\n Reflect.defineMetadata(FilePathSymbol, p, module)\n results.push(module)\n }\n } else {\n await this.registerModule(modules)\n Reflect.defineMetadata(FilePathSymbol, p, modules)\n results.push(modules)\n }\n\n return results\n }\n\n async reloadModules() {\n const result: { file: string; result: boolean; error?: Error; extensions?: object[] }[] = []\n const paths = new Set<string>()\n const extensions = [...this.extensions]\n for (const module of extensions) {\n const file = Reflect.getMetadata(FilePathSymbol, module)\n if (!file) continue\n\n this.logger.info(`Unloading module: ${chalk.green(module.constructor.name)}`)\n\n paths.add(file)\n\n await this.unregisterModule(module)\n\n delete require.cache[require.resolve(file)]\n }\n\n for (const path of paths) {\n try {\n const extensions = await this.loadModulesAtPath(path)\n\n result.push({\n file: path,\n result: true,\n extensions,\n })\n } catch (e) {\n result.push({\n file: path,\n result: false,\n error: e as Error,\n })\n }\n }\n\n return result\n }\n\n async registerModule(ext: object) {\n Reflect.defineMetadata(CommandClientSymbol, this.client, ext)\n\n this.registerEventListeners(ext)\n await this.runModuleHook(ext, 'load')\n this.extensions.push(ext)\n this.logger.info(`Module registered: ${chalk.green(ext.constructor.name)}`)\n }\n\n async unregisterModule(ext: object) {\n this.unregisterEventListeners(ext)\n await this.runModuleHook(ext, 'unload')\n _.remove(this.extensions, (x) => x === ext)\n this.logger.info(`Module unregistered: ${chalk.green(ext.constructor.name)}`)\n }\n\n runModuleHook(ext: object, hookName: string, ...args: unknown[]) {\n const hooks = getModuleHookStore(ext)\n\n const functions = hooks.get(hookName)\n\n if (functions) {\n for (const fn of functions) {\n fn.call(ext, ...args)\n }\n }\n }\n\n registerEventEmitter(name: string, emitter: EventEmitter) {\n this.emitters.set(name, emitter)\n }\n}\n","export * from './Registry'\nexport * from './CommandClient'\n","import chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport type { Logger } from 'tslog'\nimport type { ComponentArgument } from '../components/ComponentArgument'\nimport { ConverterComponent } from '../converter'\nimport { CommandClient } from '../structures'\n\nexport class Extension {\n protected get commandClient() {\n return CommandClient.getFromModule(this)\n }\n\n protected get client() {\n return this.commandClient.discord\n }\n\n protected _logger?: Logger<unknown>\n\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.logger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n\n protected async convertArguments(\n component: unknown,\n argList: unknown[],\n args: Collection<number, ComponentArgument>,\n getConverterArgs: (arg: ComponentArgument, index: number, converter: ConverterComponent<unknown>) => unknown[] | Promise<unknown[]>,\n ) {\n const items = new Collection<unknown, { ext: object; component: ConverterComponent<unknown> }>()\n\n for (const extension of this.commandClient.registry.extensions) {\n for (const converter of this.commandClient.registry.getComponentsWithType<ConverterComponent<unknown>>(extension, ConverterComponent)) {\n if (converter.options.component != component) continue\n\n items.set(converter.options.type, { component: converter, ext: extension })\n }\n }\n\n for (const [index, arg] of args) {\n const converter = items.get(arg.type)\n\n if (!converter) {\n argList[index] = undefined\n continue\n }\n\n const converterArgs = await getConverterArgs(arg, index, converter.component)\n\n argList[index] = await converter.component.execute(converter.ext, converterArgs)\n }\n }\n}\n","import chalk from 'chalk'\nimport { Extension } from './Extension'\n\nexport class CTSExtension extends Extension {\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.ctsLogger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n}\n","import chalk from 'chalk'\nimport type { Mutable } from 'utility-types'\nimport type {\n ApplicationCommandData,\n ApplicationCommandSubCommandData,\n ApplicationCommandSubGroupData,\n ChatInputApplicationCommandData,\n Interaction,\n Snowflake,\n ApplicationCommandOptionData,\n} from 'discord.js'\nimport { ChatInputCommandInteraction, Collection, CommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js'\nimport { ApplicationCommandOptionType, ApplicationCommandType } from 'discord-api-types/v10'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\nimport { ApplicationCommandOption } from './ApplicationCommandOption'\nimport { listener } from '../core'\nimport { argConverter } from '../core'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\n\ntype MutableGroup = ChatInputApplicationCommandData & {\n options: Mutable<ChatInputApplicationCommandData['options']>\n}\n\ntype MutableSubGroup = ApplicationCommandSubGroupData & {\n options: Mutable<ApplicationCommandSubGroupData['options']>\n}\n\ntype MutableCommand = ChatInputApplicationCommandData & {\n options: ApplicationCommandOptionData[]\n}\n\nexport type ApplicationCommandExtensionConfig = {\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandExtension extends CTSExtension {\n constructor(public config: ApplicationCommandExtensionConfig) {\n super()\n }\n\n unmanagedCommands: (ApplicationCommandData & { guilds?: Snowflake[] })[] = []\n\n // noinspection JSUnusedGlobalSymbols\n registerUnmanagedCommand(command: ApplicationCommandData & { guilds?: Snowflake[] }) {\n this.unmanagedCommands.push(command)\n }\n\n @listener({ event: 'interactionCreate' })\n async interactionCreate(i: Interaction) {\n try {\n if (!i.isCommand()) return\n\n let cmd: ApplicationCommandComponent | null = null\n let ext: object | null = null\n\n const extensions = this.commandClient.registry.extensions\n\n let subcommand: string | null = null\n let subcommandGroup: string | null = null\n\n if (i.isChatInputCommand()) {\n subcommand = i.options.getSubcommand(false)\n subcommandGroup = i.options.getSubcommandGroup(false)\n }\n\n extLoop: for (const extension of extensions) {\n const components = this.commandClient.registry.getComponentsWithType<ApplicationCommandComponent>(extension, ApplicationCommandComponent)\n\n if (subcommand) {\n for (const command of components) {\n if (!command.subcommandGroup && !command.subcommandGroupChild) continue\n\n if (\n command.subcommandGroupChild &&\n command.subcommandGroupChild.parent.options.name === i.commandName &&\n command.subcommandGroupChild.options.name === subcommandGroup &&\n command.options.name === subcommand\n ) {\n ext = extension\n cmd = command\n break extLoop\n }\n if (command.subcommandGroup && !subcommandGroup && command.subcommandGroup.options.name === i.commandName && command.options.name === subcommand) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n } else {\n for (const command of components) {\n if (command.options.name === i.commandName) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n }\n }\n\n if (cmd && ext) {\n const argList: unknown[] = []\n\n await this.convertArguments(ApplicationCommandComponent, argList, cmd.argTypes, () => [i])\n\n for (const [idx, arg] of cmd.argTypes) {\n let value: unknown = null\n\n for (const decorator of arg.decorators) {\n if (decorator instanceof ApplicationCommandOption) {\n if ([ApplicationCommandOptionType.Subcommand, ApplicationCommandOptionType.SubcommandGroup].includes(decorator.options.type) && i.isChatInputCommand()) {\n if (decorator.options.type === ApplicationCommandOptionType.Subcommand) {\n value = i.options.getSubcommand() === decorator.options.name\n break\n }\n if (decorator.options.type === ApplicationCommandOptionType.SubcommandGroup) {\n value = i.options.getSubcommandGroup() === decorator.options.name\n break\n }\n }\n\n value = i.options.get(decorator.options.name, false)?.value\n break\n }\n }\n\n if (value) {\n argList[idx] = value\n }\n }\n\n try {\n await cmd.executeGlobalHook(ext, 'beforeApplicationCommandCall', [i])\n await cmd.execute(ext, argList, [i])\n } finally {\n await cmd.executeGlobalHook(ext, 'afterApplicationCommandCall', [i])\n }\n }\n } catch (e) {\n this.commandClient.emit('applicationCommandInvokeError', e, i)\n }\n }\n\n async sync() {\n const client = this.commandClient\n\n this.logger.info('Trying to sync commands...')\n\n let commands: ApplicationCommandData[] = []\n\n const guildCommands = new Collection<Snowflake, ApplicationCommandData[]>()\n\n const subcommandGroups = new Collection<string, ChatInputApplicationCommandData>()\n\n for (const command of client.registry.getComponentsWithTypeGlobal<ApplicationCommandComponent>(ApplicationCommandComponent)) {\n if (command.subcommandGroup) {\n let group = subcommandGroups.get(command.subcommandGroup.options.name) as MutableGroup\n\n if (!group) {\n group = {\n ...command.subcommandGroup.options,\n type: ApplicationCommandType.ChatInput,\n } as MutableGroup\n\n if (command.subcommandGroup.guilds) {\n for (const guild of command.subcommandGroup.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(command.subcommandGroup.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n group.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as Mutable<ApplicationCommandSubCommandData>)\n\n continue\n } else if (command.subcommandGroupChild) {\n const parent = command.subcommandGroupChild.parent\n let group = subcommandGroups.get(parent.options.name) as MutableGroup\n\n if (!group) {\n group = {\n ...parent.options,\n type: ApplicationCommandType.ChatInput,\n } as MutableGroup\n\n if (parent.guilds) {\n for (const guild of parent.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(parent.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n let child = group.options.find((x) => x.name === command.subcommandGroupChild?.options.name) as MutableSubGroup\n\n if (!child) {\n child = {\n ...(command.subcommandGroupChild.options as Omit<ApplicationCommandSubGroupData, 'type'>),\n type: ApplicationCommandOptionType.SubcommandGroup,\n } as MutableSubGroup\n group.options.push(child)\n }\n\n if (!child.options) child.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n child.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as Mutable<ApplicationCommandSubCommandData>)\n\n continue\n }\n\n const cmd = { ...command.options } as MutableCommand\n\n if (cmd.type === ApplicationCommandType.ChatInput) {\n cmd.options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n cmd.options.push(option.options)\n }\n }\n }\n\n await command.executeHook(this, 'beforeSync', [cmd, command])\n\n if (command.options.guilds) {\n for (const guild of command.options.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(cmd)\n }\n continue\n }\n\n commands.push(cmd)\n }\n\n for (const { guilds, ...rest } of this.unmanagedCommands) {\n if (guilds) {\n for (const guild of guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(rest)\n }\n } else {\n commands.push(rest)\n }\n }\n\n if (this.config.guilds) {\n for (const guild of this.config.guilds) {\n let g = guildCommands.get(guild)\n if (!g) {\n g = []\n guildCommands.set(guild, g)\n }\n g.push(...commands)\n }\n\n commands = []\n }\n\n if (guildCommands.size) {\n for (const [guild, commands] of guildCommands) {\n try {\n const g = await this.client.guilds.fetch(guild)\n await g.fetch()\n this.logger.info(\n `Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`,\n )\n\n await g.commands.set(commands)\n\n this.logger.info(`Successfully registered commands for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`)\n } catch (e) {\n this.logger.error(`Failed to register commands to guild ${chalk.green(guild)}: ${(e as Error).message}`)\n }\n }\n }\n if (commands.length) {\n try {\n this.logger.info(`Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for application scope...`)\n\n if (this.client.application) {\n await this.client.application.commands.set(commands)\n\n this.logger.info('Successfully registered commands.')\n } else {\n this.logger.error('Client#application is not yet initialized.')\n }\n } catch (e) {\n this.logger.error(`Failed to register commands to global: ${(e as Error).message}`)\n }\n }\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: ChatInputCommandInteraction,\n })\n async chatInteraction(i: ChatInputCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: MessageContextMenuCommandInteraction,\n })\n async messageInteraction(i: MessageContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: UserContextMenuCommandInteraction,\n })\n async userInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: CommandInteraction,\n })\n async commandInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n}\n","import { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\n\nexport type TextCommandOptions = {\n name: string\n aliases?: string[]\n description?: string\n}\n\nexport class TextCommandComponent extends BaseComponent {\n constructor(public options: TextCommandOptions) {\n super()\n }\n}\n\nexport const command = (options: TextCommandOptions) => createComponentDecorator(new TextCommandComponent(options))\n","import { ComponentArgumentDecorator } from '../core'\nimport { createArgumentDecorator } from '../core'\n\nexport class TextCommandRestOption extends ComponentArgumentDecorator<void> {}\n\nexport const rest = createArgumentDecorator(TextCommandRestOption)\n","import { listener } from '../core/listener'\nimport { Message } from 'discord.js'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\nimport { TextCommandComponent } from './TextCommand'\nimport { TextCommandRestOption } from './parameters'\nimport { argConverter } from '../core'\n\nexport type TextCommandConfig = {\n prefix: string | string[] | ((msg: Message) => Promise<string | string[]> | string | string[])\n}\n\ndeclare module 'discord.js' {\n interface Message {\n command: TextCommandComponent\n }\n}\n\nexport class TextCommandExtension extends CTSExtension {\n constructor(private config: TextCommandConfig) {\n super()\n }\n\n private async processPrefix(msg: Message): Promise<number | null> {\n const content = msg.content\n let prefix = this.config.prefix\n\n if (typeof prefix === 'function') {\n prefix = await prefix(msg)\n }\n\n if (typeof prefix === 'string') {\n if (content.startsWith(prefix)) return prefix.length\n return null\n }\n\n if (prefix instanceof Array) {\n const p = prefix.find((x) => content.startsWith(x))\n\n if (p) return p.length\n return null\n }\n\n return null\n }\n\n @listener({ event: 'messageCreate', emitter: 'discord' })\n private async messageCreate(msg: Message) {\n try {\n const startIndex = await this.processPrefix(msg)\n\n if (startIndex === null) return\n\n const content = msg.content.slice(startIndex)\n\n const commands: TextCommandComponent[] = []\n\n const extensions = new Map<TextCommandComponent, object>()\n\n for (const ext of this.commandClient.registry.extensions) {\n for (const cmd of this.commandClient.registry.getComponentsWithType<TextCommandComponent>(ext, TextCommandComponent)) {\n commands.push(cmd)\n extensions.set(cmd, ext)\n }\n }\n\n let commandNameLength = 0\n\n const command = commands.find((x) => {\n const names = [x.options.name]\n\n if (x.options.aliases) {\n names.push(...x.options.aliases)\n }\n\n for (const name of names) {\n if (content.startsWith(name)) {\n if (content.length === name.length) {\n commandNameLength = name.length\n return true\n }\n commandNameLength = name.length\n return content.startsWith(name + ' ')\n }\n }\n\n return false\n })\n\n if (!command) return\n\n const ext = extensions.get(command)\n\n if (!ext) return\n\n msg.command = command\n\n const args: unknown[] = []\n\n let argStrings = content.slice(commandNameLength + 1).split(/ /g)\n\n await this.convertArguments(TextCommandComponent, args, command.argTypes, async (arg, i, converter) => {\n if (converter.options.parameterless) return [msg]\n\n if (arg.decorators.find((x) => x.constructor === TextCommandRestOption)) {\n const text = argStrings.join(' ')\n argStrings = []\n return [text, msg]\n }\n return [argStrings.shift(), msg]\n })\n\n await command.execute(ext, args, [msg])\n } catch (e) {\n this.commandClient.emit('textCommandInvokeError', e, msg)\n }\n }\n\n @argConverter({\n component: TextCommandComponent,\n type: Message,\n parameterless: true,\n })\n async mesage(msg: Message) {\n return msg\n }\n\n @argConverter({ component: TextCommandComponent, type: String })\n async str(value: string) {\n return value\n }\n\n @argConverter({ component: TextCommandComponent, type: Number })\n async num(value: string) {\n return Number(value)\n }\n}\n","import chalk from 'chalk'\nimport type { Client, Snowflake } from 'discord.js'\nimport { Team, User } from 'discord.js'\nimport EventEmitter from 'events'\nimport type { ISettingsParam } from 'tslog'\nimport { Logger } from 'tslog'\nimport type { ApplicationCommandExtensionConfig } from '../../applicationCommand/ApplicationCommandExtension'\nimport { ApplicationCommandExtension } from '../../applicationCommand/ApplicationCommandExtension'\nimport type { TextCommandConfig } from '../../textCommand'\nimport { TextCommandExtension } from '../../textCommand/TextCommandExtension'\nimport { CommandClientSymbol } from '../symbols'\nimport { Registry } from './Registry'\nexport class CommandClient extends EventEmitter {\n ctsLogger: Logger<unknown>\n registry: Registry\n\n owners: Set<Snowflake> = new Set()\n\n constructor(\n public discord: Client,\n public logger: Logger<unknown> = new Logger({ prettyLogTimeZone: 'local' }),\n loggerOptions: ISettingsParam<unknown> = {},\n ) {\n super()\n\n this.ctsLogger = logger.getSubLogger({\n ...loggerOptions,\n name: 'command.ts',\n })\n\n this.registry = new Registry(this.ctsLogger, this)\n\n this.registry.registerEventEmitter('cts', this)\n this.registry.registerEventEmitter('discord', this.discord)\n }\n\n async isOwner(user: User): Promise<boolean> {\n return this.owners.has(user.id)\n }\n\n async fetchOwners() {\n if (!this.discord.application) throw new Error('The client is not logged in.')\n\n this.ctsLogger.info('Fetching owners...')\n\n await this.discord.application.fetch()\n\n const owner = this.discord.application.owner\n\n if (!owner) throw new Error('Cannot find application owner')\n\n const owners: string[] = []\n\n if (owner instanceof User) {\n this.owners.add(owner.id)\n owners.push(owner.tag)\n } else if (owner instanceof Team) {\n for (const [id, member] of owner.members) {\n this.owners.add(id)\n owners.push(member.user.tag)\n }\n }\n\n this.ctsLogger.info(`Fetched ${chalk.green(owners.length)} owners(${owners.map((x) => chalk.blue(x)).join(', ')})`)\n }\n\n async enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig) {\n await this.registry.registerModule(new ApplicationCommandExtension(config))\n this.ctsLogger.info('Application command extension enabled.')\n }\n\n async enableTextCommandsExtension(config: TextCommandConfig) {\n await this.registry.registerModule(new TextCommandExtension(config))\n this.ctsLogger.info('Text command extension enabled.')\n }\n\n getApplicationCommandsExtension() {\n return this.registry.extensions.find((x) => x.constructor === ApplicationCommandExtension) as ApplicationCommandExtension | undefined\n }\n\n static getFromModule(ext: object): CommandClient {\n return Reflect.getMetadata(CommandClientSymbol, ext)\n }\n}\n","import { Collection } from 'discord.js'\nimport type { AnyFunction } from '../../utils/types'\nimport type { ComponentHookStore } from '../hooks'\nimport { ComponentArgument } from './ComponentArgument'\n\nexport class BaseComponent {\n method!: AnyFunction\n\n hooks: ComponentHookStore = new Collection()\n\n argTypes: Collection<number, ComponentArgument> = new Collection()\n\n _init(method: AnyFunction, argTypes: unknown[]) {\n this.method = method\n for (let i = 0; i < argTypes.length; i++) {\n const element = argTypes[i]\n this.argTypes.set(i, new ComponentArgument(element))\n }\n }\n\n async executeGlobalHook(target: object, name: string, args: unknown[]) {\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n for (const fn of globalHooks) {\n await fn.call(null, client, ...args)\n }\n }\n }\n\n async executeHook(target: object, name: string, args: unknown[]) {\n const hook = this.hooks.get(name)\n\n if (!hook) return\n\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n hook.unshift(...globalHooks)\n }\n\n for (const fn of hook) {\n await fn.call(null, client, ...args)\n }\n }\n\n async execute(target: object, args: unknown[], beforeCallArgs: unknown[] = args) {\n await this.executeHook(target, 'beforeCall', beforeCallArgs)\n let result\n try {\n result = await this.method.call(target, ...args)\n await this.executeHook(target, 'afterCall', [...beforeCallArgs, result])\n } catch (e) {\n await this.executeHook(target, 'invokeError', [e, ...beforeCallArgs])\n throw e\n }\n\n return result\n }\n}\n","import 'reflect-metadata'\nexport * from './decoratorCreator'\nexport * from './ComponentArgument'\nexport * from './ComponentArgumentDecorator'\nexport * from './BaseComponent'\n","export class OwnerOnlyError {}\n","import type { Interaction } from 'discord.js'\nimport { BaseInteraction, Message } from 'discord.js'\nimport { createComponentHook } from '../hooks'\nimport type { ComponentHookFn } from '../hooks/componentHook'\nimport type { CommandClient } from '../structures'\nimport { OwnerOnlyError } from './errors'\n\nexport const createCheckDecorator = (fn: ComponentHookFn<[CommandClient, Interaction | Message]>) => createComponentHook('beforeCall', fn)\n\nexport const ownerOnly = createCheckDecorator(async (client: CommandClient, i: Interaction | Message) => {\n let isOwner = false\n\n if (i instanceof BaseInteraction) {\n client\n isOwner = await client.isOwner(i.user)\n } else if (i instanceof Message) {\n isOwner = await client.isOwner(i.author)\n }\n\n if (!isOwner) throw new OwnerOnlyError()\n})\n","export const mergeMethodDecorators = (decorators: MethodDecorator[]): MethodDecorator => {\n return (target, key, descriptor) => {\n for (const decorator of decorators) {\n decorator(target, key, descriptor)\n }\n }\n}\n","export * from './checks'\nexport * from './errors'\nexport * from './decorators'\n","export * from './Extension'\n","export * from './components'\nexport * from './hooks'\nexport * from './converter'\nexport * from './utils'\nexport * from './listener'\nexport * from './structures'\nexport * from './extensions'\n","export * from './core'\nexport * from './applicationCommand'\nexport * from './textCommand'\n","export * from './ApplicationCommand'\nexport { option } from './ApplicationCommandOption'\nexport * from './group'\nexport * from './ApplicationCommandExtension'\n","import type { ApplicationCommandSubGroupData, ChatInputApplicationCommandData } from 'discord.js'\nimport { ApplicationCommandType } from 'discord.js'\nimport { createComponentDecorator } from '../core'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\n\nexport class SubCommandGroup {\n constructor(\n public options: Omit<ChatInputApplicationCommandData, 'type'>,\n public guilds?: string[],\n ) {}\n\n command(options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroup = this\n return createComponentDecorator(cmd)\n }\n\n createChild(options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>) {\n return new SubCommandGroupChild(options, this)\n }\n}\n\nexport class SubCommandGroupChild {\n constructor(\n public options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>,\n public parent: SubCommandGroup,\n ) {}\n\n command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroupChild = this\n return createComponentDecorator(cmd)\n }\n}\n","export * from './TextCommand'\nexport type { TextCommandConfig } from './TextCommandExtension'\nexport * from './parameters'\n"],"mappings":"w6CAAA,IAAaA,EACAC,GACAC,GACAC,GACAC,GACAC,GALbC,EAAAC,EAAA,kBAAaP,EAAuBQ,OAAAA,EACvBP,GAA0BO,OAAAA,EAC1BN,GAAwBM,OAAAA,EACxBL,GAAsBK,OAAAA,EACtBJ,GAAsBI,OAAAA,EACtBH,GAAiBG,OAAAA,ICL9B,IAAAC,GAOaC,GAWAC,GAlBbC,GAAAC,EAAA,kBAAAJ,GAA2B,sBAC3BK,IAMaJ,GAAwBK,EAAA,CAACC,EAAgBC,IAAAA,CACpD,IAAIC,EAAOC,QAAQC,YAAYC,GAAqBL,EAAQC,CAAAA,EAE5D,OAAKC,IACHA,EAAO,IAAII,cACXH,QAAQI,eAAeF,GAAqBH,EAAMF,EAAQC,CAAAA,GAGrDC,CACT,EATqC,yBAWxBP,GAAsBI,EAAA,CAAsBS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WAAAC,GAAA,cAAAC,GAAA,SAAAC,KAAA,eAAAC,GAAAlC,IAAAmC,ICAAC,KACAC,KCAA,IAAAC,GAAuC,sBACvCC,IACAC,KAEO,IAAMC,GAAN,MAAMA,EAAAA,CACXC,YACSC,EACAC,EACP,CAFOD,EAAAA,gBACAC,EAAAA,4BADAD,cACAC,CACN,CAEHC,QAAQF,EAAoF,CAC1F,IAAMG,EAAM,IAAIC,EAA4BC,EAAA,CAC1CC,KAAMC,0BAAuBC,WAC1BR,EACL,EACAG,OAAAA,EAAIM,gBAAkB,KACfC,EAAyBP,CAAAA,CAClC,CAEAQ,YAAYX,EAAmE,CAC7E,OAAO,IAAIY,GAAqBZ,EAAS,IAAI,CAC/C,CACF,EAlBaF,EAAAA,GAAAA,mBAAN,IAAMA,GAANe,GAoBMD,GAAN,MAAMA,EAAAA,CACXb,YACSC,EACAc,EACP,CAFOd,EAAAA,gBACAc,EAAAA,4BADAd,cACAc,CACN,CAEHZ,QAAQF,EAAqF,CAC3F,IAAMG,EAAM,IAAIC,EAA4BC,EAAA,CAC1CC,KAAMC,0BAAuBC,WAC1BR,EACL,EACAG,OAAAA,EAAIY,qBAAuB,KACpBL,EAAyBP,CAAAA,CAClC,CACF,EAdaS,EAAAA,GAAAA,wBAAN,IAAMA,GAANI,GDtBPC,KEHAC,KAEAC","names":["ComponentStoreSymbol","ComponentArgStoreSymbol","ModuleHookStoreSymbol","CommandClientSymbol","ComponentHookSymbol","FilePathSymbol","init_symbols","__esmMin","Symbol","import_discord","getComponentHookStore","createComponentHook","init_componentHook","__esmMin","init_symbols","__name","target","property","data","Reflect","getMetadata","ComponentHookSymbol","Collection","defineMetadata","name","fn","key","store","hooks","get","set","unshift","import_discord","getComponentStore","getComponent","createComponentDecorator","getComponentArgumentStore","createArgumentDecorator","init_decoratorCreator","__esmMin","init_componentHook","init_symbols","__name","target","result","Reflect","getMetadata","ComponentStoreSymbol","Collection","defineMetadata","key","get","component","_init","componentHookStore","getComponentHookStore","hooks","store","forEach","x","i","_a","argTypes","decorators","push","set","type","options","idx","arg","ComponentArgument","init_ComponentArgument","__esmMin","constructor","type","decorators","_ComponentArgument","import_lodash","ComponentArgumentDecorator","init_ComponentArgumentDecorator","__esmMin","constructor","options","_","merge","defaultOptions","_ComponentArgumentDecorator","ApplicationCommandComponent","applicationCommand","init_ApplicationCommand","__esmMin","init_decoratorCreator","init_BaseComponent","BaseComponent","constructor","options","subcommandGroup","subcommandGroupChild","_ApplicationCommandComponent","__name","createComponentDecorator","ApplicationCommandOption","option","init_ApplicationCommandOption","__esmMin","init_core","ComponentArgumentDecorator","_ApplicationCommandOption","createArgumentDecorator","ConverterComponent","argConverter","init_converter","__esmMin","init_BaseComponent","init_decoratorCreator","BaseComponent","constructor","options","_ConverterComponent","__name","createComponentDecorator","import_discord","getModuleHookStore","moduleHook","init_moduleHook","__esmMin","init_symbols","__name","target","result","Reflect","getMetadata","ModuleHookStoreSymbol","Collection","defineMetadata","name","key","store","v","get","set","push","init_hooks","__esmMin","init_moduleHook","init_componentHook","import_lodash","ListenerComponent","listener","init_listener","__esmMin","init_BaseComponent","init_decoratorCreator","BaseComponent","constructor","options","_","merge","emitter","_ListenerComponent","__name","createComponentDecorator","import_chalk","import_discord","import_lodash","import_walk_sync","import_path","Registry","init_Registry","__esmMin","init_components","init_hooks","init_listener","init_symbols","constructor","logger","client","extensions","emitters","globalHooks","Collection","getSubLogger","name","chalk","green","addGlobalHook","fn","hooks","push","getComponentsWithTypeGlobal","type","result","ext","getComponentsWithType","componentStore","getComponentStore","Array","from","filter","x","values","registerEventListeners","listeners","ListenerComponent","listener","emitter","get","options","bound","method","bind","Reflect","defineMetadata","addListener","event","unregisterEventListeners","getMetadata","removeListener","loadAllModulesInDirectory","dir","pattern","__async","results","files","walkSync","endsWith","test","file","p","path","join","loadModulesAtPath","info","require","resolve","mod","setup","Error","modules","registerModules","module","registerModule","FilePathSymbol","reloadModules","paths","Set","add","unregisterModule","cache","e","error","CommandClientSymbol","runModuleHook","_","remove","hookName","args","functions","getModuleHookStore","call","registerEventEmitter","set","_Registry","init_structures","__esmMin","init_Registry","init_CommandClient","import_chalk","import_discord","Extension","init_Extension","__esmMin","init_converter","init_structures","_logger","commandClient","CommandClient","getFromModule","client","discord","logger","getSubLogger","name","chalk","green","constructor","convertArguments","component","argList","args","getConverterArgs","__async","items","Collection","extension","registry","extensions","converter","getComponentsWithType","ConverterComponent","options","set","type","ext","index","arg","get","undefined","converterArgs","execute","_Extension","import_chalk","CTSExtension","init_CTSExtension","__esmMin","init_Extension","Extension","logger","_logger","commandClient","ctsLogger","getSubLogger","name","chalk","green","constructor","_CTSExtension","import_chalk","import_discord","import_v10","ApplicationCommandExtension","init_ApplicationCommand","init_ApplicationCommandOption","init_core","init_CTSExtension","CTSExtension","constructor","config","unmanagedCommands","registerUnmanagedCommand","command","push","interactionCreate","i","__async","isCommand","cmd","ext","extensions","commandClient","registry","subcommand","subcommandGroup","isChatInputCommand","options","getSubcommand","getSubcommandGroup","extLoop","extension","components","getComponentsWithType","ApplicationCommandComponent","subcommandGroupChild","parent","name","commandName","argList","convertArguments","argTypes","idx","arg","value","decorator","decorators","ApplicationCommandOption","ApplicationCommandOptionType","Subcommand","SubcommandGroup","includes","type","get","executeGlobalHook","execute","e","emit","sync","client","logger","info","commands","guildCommands","Collection","subcommandGroups","getComponentsWithTypeGlobal","group","__spreadProps","__spreadValues","ApplicationCommandType","ChatInput","guilds","guild","set","option","find","x","child","executeHook","_a","_b","rest","g","size","fetch","chalk","green","length","map","blue","join","id","error","message","application","chatInteraction","messageInteraction","userInteraction","commandInteraction","_ApplicationCommandExtension","listener","event","argConverter","component","parameterless","ChatInputCommandInteraction","MessageContextMenuCommandInteraction","UserContextMenuCommandInteraction","CommandInteraction","TextCommandComponent","command","init_TextCommand","__esmMin","init_decoratorCreator","init_BaseComponent","BaseComponent","constructor","options","_TextCommandComponent","__name","createComponentDecorator","TextCommandRestOption","rest","init_parameters","__esmMin","init_core","ComponentArgumentDecorator","_TextCommandRestOption","createArgumentDecorator","import_discord","TextCommandExtension","init_listener","init_CTSExtension","init_TextCommand","init_parameters","init_core","CTSExtension","constructor","config","processPrefix","msg","__async","content","prefix","startsWith","length","Array","p","find","x","messageCreate","startIndex","slice","commands","extensions","Map","ext","commandClient","registry","cmd","getComponentsWithType","TextCommandComponent","push","set","commandNameLength","command","names","options","name","aliases","get","args","argStrings","split","convertArguments","argTypes","arg","i","converter","parameterless","decorators","TextCommandRestOption","text","join","shift","execute","e","emit","mesage","str","value","num","Number","_TextCommandExtension","listener","event","emitter","argConverter","component","type","Message","String","CommandClient_exports","__export","CommandClient","import_chalk","import_discord","import_events","import_tslog","init_CommandClient","__esmMin","init_ApplicationCommandExtension","init_TextCommandExtension","init_symbols","init_Registry","EventEmitter","constructor","discord","logger","Logger","prettyLogTimeZone","loggerOptions","ctsLogger","registry","owners","Set","getSubLogger","__spreadProps","__spreadValues","name","Registry","registerEventEmitter","isOwner","user","__async","has","id","fetchOwners","application","Error","info","fetch","owner","User","add","push","tag","Team","member","members","chalk","green","length","map","x","blue","join","enableApplicationCommandsExtension","config","registerModule","ApplicationCommandExtension","enableTextCommandsExtension","TextCommandExtension","getApplicationCommandsExtension","extensions","find","getFromModule","ext","Reflect","getMetadata","CommandClientSymbol","_CommandClient","import_discord","BaseComponent","init_BaseComponent","__esmMin","init_ComponentArgument","method","hooks","Collection","argTypes","_init","i","length","element","set","ComponentArgument","executeGlobalHook","target","name","args","__async","CommandClient","client","getFromModule","globalHooks","registry","fn","call","executeHook","hook","get","unshift","execute","beforeCallArgs","result","e","_BaseComponent","import_reflect_metadata","init_components","__esmMin","init_decoratorCreator","init_ComponentArgument","init_ComponentArgumentDecorator","init_BaseComponent","OwnerOnlyError","init_errors","__esmMin","_OwnerOnlyError","import_discord","createCheckDecorator","ownerOnly","init_checks","__esmMin","init_hooks","init_errors","__name","fn","createComponentHook","client","i","isOwner","BaseInteraction","user","Message","author","OwnerOnlyError","mergeMethodDecorators","init_decorators","__esmMin","__name","decorators","target","key","descriptor","decorator","init_utils","__esmMin","init_checks","init_errors","init_decorators","init_extensions","__esmMin","init_Extension","init_core","__esmMin","init_components","init_hooks","init_converter","init_utils","init_listener","init_structures","init_extensions","src_exports","__export","ApplicationCommandComponent","ApplicationCommandExtension","BaseComponent","CommandClient","ComponentArgument","ComponentArgumentDecorator","ConverterComponent","Extension","ListenerComponent","OwnerOnlyError","Registry","SubCommandGroup","SubCommandGroupChild","TextCommandComponent","TextCommandRestOption","applicationCommand","argConverter","command","createArgumentDecorator","createCheckDecorator","createComponentDecorator","createComponentHook","getComponent","getComponentArgumentStore","getComponentStore","getModuleHookStore","listener","mergeMethodDecorators","moduleHook","option","ownerOnly","rest","__toCommonJS","init_core","init_ApplicationCommand","init_ApplicationCommandOption","import_discord","init_core","init_ApplicationCommand","SubCommandGroup","constructor","options","guilds","command","cmd","ApplicationCommandComponent","__spreadValues","type","ApplicationCommandType","ChatInput","subcommandGroup","createComponentDecorator","createChild","SubCommandGroupChild","_SubCommandGroup","parent","subcommandGroupChild","_SubCommandGroupChild","init_ApplicationCommandExtension","init_TextCommand","init_parameters"]}
1
+ {"version":3,"sources":["../src/core/symbols.ts","../src/core/hooks/componentHook.ts","../src/core/components/decoratorCreator.ts","../src/core/components/ComponentArgument.ts","../src/core/components/ComponentArgumentDecorator.ts","../src/applicationCommand/ApplicationCommand.ts","../src/applicationCommand/ApplicationCommandOption.ts","../src/core/converter/index.ts","../src/core/hooks/moduleHook.ts","../src/core/hooks/index.ts","../src/core/listener/index.ts","../src/core/structures/Registry.ts","../src/core/structures/index.ts","../src/core/extensions/Extension.ts","../src/core/extensions/CTSExtension.ts","../src/applicationCommand/ApplicationCommandExtension.ts","../src/textCommand/TextCommand.ts","../src/textCommand/parameters.ts","../src/textCommand/TextCommandExtension.ts","../src/core/structures/CommandClient.ts","../src/core/components/BaseComponent.ts","../src/core/components/index.ts","../src/core/utils/errors.ts","../src/core/utils/checks.ts","../src/core/utils/decorators.ts","../src/core/utils/index.ts","../src/core/extensions/index.ts","../src/core/index.ts","../src/index.ts","../src/applicationCommand/index.ts","../src/applicationCommand/group.ts","../src/textCommand/index.ts"],"sourcesContent":["export const ComponentStoreSymbol = Symbol()\nexport const ComponentArgStoreSymbol = Symbol()\nexport const ModuleHookStoreSymbol = Symbol()\nexport const CommandClientSymbol = Symbol()\nexport const ComponentHookSymbol = Symbol()\nexport const FilePathSymbol = Symbol()\n","import { Collection } from 'discord.js'\nimport { ComponentHookSymbol } from '../symbols'\n\nexport type ComponentHookFn<T extends unknown[]> = (...args: T) => void | Promise<void>\n\nexport type ComponentHookStore = Collection<string, ComponentHookFn<unknown[]>[]>\n\nexport const getComponentHookStore = (target: object, property: string | symbol): ComponentHookStore => {\n let data = Reflect.getMetadata(ComponentHookSymbol, target, property) as ComponentHookStore\n\n if (!data) {\n data = new Collection()\n Reflect.defineMetadata(ComponentHookSymbol, data, target, property)\n }\n\n return data\n}\n\nexport const createComponentHook = <T extends unknown[]>(name: string, fn: ComponentHookFn<T>): MethodDecorator => {\n return (target, key) => {\n const store = getComponentHookStore(target, key)\n\n let hooks = store.get(name)\n\n if (!hooks) {\n hooks = []\n store.set(name, hooks)\n }\n\n // @ts-expect-error unknown type\n hooks.unshift(fn)\n }\n}\n","import { Collection } from 'discord.js'\nimport type { ComponentHookStore } from '../hooks'\nimport { getComponentHookStore } from '../hooks/componentHook'\nimport { ComponentStoreSymbol } from '../symbols'\nimport type { BaseComponent } from './BaseComponent'\nimport type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport type ComponentStore = Collection<string | symbol, BaseComponent>\nexport type ComponentArgumentStore = Collection<number, ComponentArgumentDecorator>\n\nexport const getComponentStore = (target: object): ComponentStore => {\n let result: ComponentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const getComponent = (target: object, key: string | symbol) => {\n const store = getComponentStore(target)\n\n return store.get(key)\n}\n\nexport const createComponentDecorator = (component: BaseComponent): MethodDecorator => {\n return (target, key) => {\n component._init(Reflect.get(target, key), Reflect.getMetadata('design:paramtypes', target, key))\n\n const componentHookStore: ComponentHookStore = getComponentHookStore(target, key)\n\n component.hooks = componentHookStore\n\n const store = getComponentStore(target)\n\n const decorators = getComponentArgumentStore(target, key)\n\n decorators.forEach((x, i) => {\n component.argTypes.get(i)?.decorators.push(x)\n })\n\n store.set(key, component)\n }\n}\n\nexport const getComponentArgumentStore = (target: object, key: string | symbol): ComponentArgumentStore => {\n let result: ComponentArgumentStore | null = Reflect.getMetadata(ComponentStoreSymbol, target, key)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ComponentStoreSymbol, result, target, key)\n }\n\n return result\n}\n\nexport const createArgumentDecorator = <Options>(type: typeof ComponentArgumentDecorator<Options>) => {\n return (options: Options): ParameterDecorator => {\n return (target, key, idx) => {\n if (!key) return\n\n const arg: ComponentArgumentDecorator<Options> = new type(options)\n\n const store = getComponentArgumentStore(target, key)\n\n store.set(idx, arg)\n }\n }\n}\n","import type { ComponentArgumentDecorator } from './ComponentArgumentDecorator'\n\nexport class ComponentArgument {\n decorators: ComponentArgumentDecorator[] = []\n\n constructor(public type: unknown) {}\n}\n","import _ from 'lodash'\n\nexport class ComponentArgumentDecorator<Options = unknown> {\n options: Options\n\n constructor(options: Partial<Options>) {\n if (typeof options === 'object') {\n this.options = _.merge(this.defaultOptions(), options)\n } else {\n this.options = options\n }\n }\n\n defaultOptions(): Options {\n return {} as unknown as Options\n }\n}\n","import type { ApplicationCommandType, ChatInputApplicationCommandData, MessageApplicationCommandData, Snowflake, UserApplicationCommandData } from 'discord.js'\nimport { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\nimport type { SubCommandGroup, SubCommandGroupChild } from './group'\n\ntype Options = (UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) & {\n type: ApplicationCommandType\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandComponent extends BaseComponent {\n options: Options\n\n subcommandGroup?: SubCommandGroup\n subcommandGroupChild?: SubCommandGroupChild\n\n constructor(options: UserApplicationCommandData | MessageApplicationCommandData | Omit<ChatInputApplicationCommandData, 'options'>) {\n super()\n\n this.options = options as Options\n }\n}\n\nexport const applicationCommand = (options: Options) => createComponentDecorator(new ApplicationCommandComponent(options))\n\nexport type { Options as ApplicationCommandComponentOptions }\n","import type { ApplicationCommandOptionData } from 'discord.js'\nimport { createArgumentDecorator, ComponentArgumentDecorator } from '../core'\n\ntype Options = ApplicationCommandOptionData\n\nexport class ApplicationCommandOption extends ComponentArgumentDecorator<Options> {}\n\nexport const option = createArgumentDecorator(ApplicationCommandOption)\n","import { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options<T> = { component: unknown; type: T; parameterless: boolean }\n\ntype OptionsArg<T> = Omit<Options<T>, 'parameterless'> & { parameterless?: boolean }\n\nexport class ConverterComponent<T> extends BaseComponent {\n options: Options<T>\n\n constructor(options: OptionsArg<T>) {\n super()\n this.options = options as Options<T>\n }\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const argConverter = <T>(options: OptionsArg<T>) => createComponentDecorator(new ConverterComponent(options))\n\nexport { Options as ArgumentConvertOptions, OptionsArg as ArgumentConvertOptionsArg }\n","import { Collection } from 'discord.js'\nimport { ModuleHookStoreSymbol } from '../symbols'\nimport type { ComponentHookFn } from './componentHook'\n\nexport type ModuleHookStore = Collection<string, ComponentHookFn<unknown[]>[]>\n\nexport const getModuleHookStore = (target: object) => {\n let result: ModuleHookStore | null = Reflect.getMetadata(ModuleHookStoreSymbol, target)\n\n if (!result) {\n result = new Collection()\n\n Reflect.defineMetadata(ModuleHookStoreSymbol, result, target)\n }\n\n return result\n}\n\nexport const moduleHook = (name: string): MethodDecorator => {\n return (target, key) => {\n const store = getModuleHookStore(target)\n\n let v = store.get(name)\n\n if (!v) {\n v = []\n store.set(name, v)\n }\n\n v.push(Reflect.get(target, key))\n }\n}\n","export * from './moduleHook'\nexport { createComponentHook, type ComponentHookFn } from './componentHook'\nexport type { ComponentHookStore } from './componentHook'\n","import _ from 'lodash'\nimport { BaseComponent } from '../components/BaseComponent'\nimport { createComponentDecorator } from '../components/decoratorCreator'\n\ntype Options = { emitter: string; event: string }\n\ntype OptionsArg = { emitter?: string; event: string }\n\nexport class ListenerComponent extends BaseComponent {\n options: Options\n\n constructor(options: OptionsArg) {\n super()\n\n this.options = _.merge({ emitter: 'discord' }, options)\n }\n}\n\nexport const listener = (options: OptionsArg) => createComponentDecorator(new ListenerComponent(options))\n\nexport { Options as ListenerOptions, OptionsArg as ListenerOptionsArg }\n","import chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport type EventEmitter from 'events'\nimport _ from 'lodash'\nimport type { Logger } from 'tslog'\nimport { getComponentStore } from '../components'\nimport { getModuleHookStore } from '../hooks'\nimport { ListenerComponent } from '../listener'\nimport { CommandClientSymbol, FilePathSymbol } from '../symbols'\nimport type { CommandClient } from './CommandClient'\nimport walkSync from 'walk-sync'\nimport path from 'path'\nimport type { ComponentHookFn } from '../hooks/componentHook'\n\nexport class Registry {\n extensions: object[] = []\n\n emitters: Collection<string, EventEmitter> = new Collection()\n\n logger: Logger<unknown>\n\n globalHooks: Record<string, ComponentHookFn<unknown[]>[]> = {}\n\n constructor(\n logger: Logger<unknown>,\n public client: CommandClient,\n ) {\n this.logger = logger.getSubLogger({\n name: chalk.green('Registry'),\n })\n }\n\n addGlobalHook(name: string, fn: ComponentHookFn<unknown[]>) {\n let hooks = this.globalHooks[name]\n\n if (!hooks) {\n hooks = []\n this.globalHooks[name] = hooks\n }\n\n hooks.push(fn)\n }\n\n getComponentsWithTypeGlobal<T>(type: unknown): T[] {\n const result: T[] = []\n\n for (const ext of this.extensions) {\n result.push(...this.getComponentsWithType<T>(ext, type))\n }\n\n return result\n }\n\n getComponentsWithType<T>(ext: object, type: unknown): T[] {\n const componentStore = getComponentStore(ext)\n\n return Array.from(componentStore.filter((x) => (x.constructor as unknown) === type).values() as Iterable<T>)\n }\n\n registerEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n\n if (emitter) {\n const bound = listener.method.bind(ext)\n\n Reflect.defineMetadata('bound', bound, listener)\n\n emitter.addListener(listener.options.event, bound)\n }\n }\n }\n\n unregisterEventListeners(ext: object) {\n const listeners = this.getComponentsWithType<ListenerComponent>(ext, ListenerComponent)\n\n for (const listener of listeners) {\n const emitter = this.emitters.get(listener.options.emitter)\n const bound = Reflect.getMetadata('bound', listener)\n\n if (emitter && bound) {\n emitter.removeListener(listener.options.event, bound)\n }\n }\n }\n\n async loadAllModulesInDirectory(dir: string, pattern?: RegExp): Promise<object[]> {\n const results: object[] = []\n\n const files = walkSync(dir).filter((x) => (x.endsWith('.ts') || x.endsWith('.js')) && (!pattern || pattern.test(x)))\n\n for (const file of files) {\n if (file.endsWith('.d.ts')) continue\n const p = path.join(dir, file)\n results.push(...(await this.loadModulesAtPath(p)))\n }\n\n return results\n }\n\n async loadModulesAtPath(file: string) {\n this.logger.info(`Loading module at path ${chalk.green(file)}`)\n\n const p = require.resolve(file)\n\n // eslint-disable-next-line @typescript-eslint/no-var-requires\n const mod = require(p)\n\n if (typeof mod.setup !== 'function') throw new Error('Extension must have a setup function')\n\n const modules = await mod.setup(this.client)\n\n return this.registerModules(modules, p)\n }\n\n private async registerModules(modules: object | object[], p: string) {\n const results: object[] = []\n if (modules instanceof Array) {\n for (const module of modules) {\n await this.registerModule(module)\n Reflect.defineMetadata(FilePathSymbol, p, module)\n results.push(module)\n }\n } else {\n await this.registerModule(modules)\n Reflect.defineMetadata(FilePathSymbol, p, modules)\n results.push(modules)\n }\n\n return results\n }\n\n async reloadModules() {\n const result: { file: string; result: boolean; error?: Error; extensions?: object[] }[] = []\n const paths = new Set<string>()\n const extensions = [...this.extensions]\n for (const module of extensions) {\n const file = Reflect.getMetadata(FilePathSymbol, module)\n if (!file) continue\n\n this.logger.info(`Unloading module: ${chalk.green(module.constructor.name)}`)\n\n paths.add(file)\n\n await this.unregisterModule(module)\n\n delete require.cache[require.resolve(file)]\n }\n\n for (const path of paths) {\n try {\n const extensions = await this.loadModulesAtPath(path)\n\n result.push({\n file: path,\n result: true,\n extensions,\n })\n } catch (e) {\n result.push({\n file: path,\n result: false,\n error: e as Error,\n })\n }\n }\n\n return result\n }\n\n async registerModule(ext: object) {\n Reflect.defineMetadata(CommandClientSymbol, this.client, ext)\n\n this.registerEventListeners(ext)\n await this.runModuleHook(ext, 'load')\n this.extensions.push(ext)\n this.logger.info(`Module registered: ${chalk.green(ext.constructor.name)}`)\n }\n\n async unregisterModule(ext: object) {\n this.unregisterEventListeners(ext)\n await this.runModuleHook(ext, 'unload')\n _.remove(this.extensions, (x) => x === ext)\n this.logger.info(`Module unregistered: ${chalk.green(ext.constructor.name)}`)\n }\n\n runModuleHook(ext: object, hookName: string, ...args: unknown[]) {\n const hooks = getModuleHookStore(ext)\n\n const functions = hooks.get(hookName)\n\n if (functions) {\n for (const fn of functions) {\n fn.call(ext, ...args)\n }\n }\n }\n\n registerEventEmitter(name: string, emitter: EventEmitter) {\n this.emitters.set(name, emitter)\n }\n}\n","export * from './Registry'\nexport * from './CommandClient'\n","import chalk from 'chalk'\nimport { Collection } from 'discord.js'\nimport type { Logger } from 'tslog'\nimport type { ComponentArgument } from '../components/ComponentArgument'\nimport { ConverterComponent } from '../converter'\nimport { CommandClient } from '../structures'\n\nexport class Extension {\n protected get commandClient() {\n return CommandClient.getFromModule(this)\n }\n\n protected get client() {\n return this.commandClient.discord\n }\n\n protected _logger?: Logger<unknown>\n\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.logger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n\n protected async convertArguments(\n component: unknown,\n argList: unknown[],\n args: Collection<number, ComponentArgument>,\n getConverterArgs: (arg: ComponentArgument, index: number, converter: ConverterComponent<unknown>) => unknown[] | Promise<unknown[]>,\n ) {\n const items = new Collection<unknown, { ext: object; component: ConverterComponent<unknown> }>()\n\n for (const extension of this.commandClient.registry.extensions) {\n for (const converter of this.commandClient.registry.getComponentsWithType<ConverterComponent<unknown>>(extension, ConverterComponent)) {\n if (converter.options.component != component) continue\n\n items.set(converter.options.type, { component: converter, ext: extension })\n }\n }\n\n for (const [index, arg] of args) {\n const converter = items.get(arg.type)\n\n if (!converter) {\n argList[index] = undefined\n continue\n }\n\n const converterArgs = await getConverterArgs(arg, index, converter.component)\n\n argList[index] = await converter.component.execute(converter.ext, converterArgs)\n }\n }\n}\n","import chalk from 'chalk'\nimport { Extension } from './Extension'\n\nexport class CTSExtension extends Extension {\n protected get logger() {\n if (!this._logger) this._logger = this.commandClient.ctsLogger.getSubLogger({ name: chalk.green(`${this.constructor.name}`) })\n return this._logger\n }\n}\n","import chalk from 'chalk'\nimport type { Mutable } from 'utility-types'\nimport type {\n ApplicationCommandData,\n ApplicationCommandSubCommandData,\n ApplicationCommandSubGroupData,\n ChatInputApplicationCommandData,\n Interaction,\n Snowflake,\n ApplicationCommandOptionData,\n} from 'discord.js'\nimport { ChatInputCommandInteraction, Collection, CommandInteraction, MessageContextMenuCommandInteraction, UserContextMenuCommandInteraction } from 'discord.js'\nimport { ApplicationCommandOptionType, ApplicationCommandType } from 'discord-api-types/v10'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\nimport { ApplicationCommandOption } from './ApplicationCommandOption'\nimport { listener } from '../core'\nimport { argConverter } from '../core'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\n\ntype MutableGroup = ChatInputApplicationCommandData & {\n options: Mutable<ChatInputApplicationCommandData['options']>\n}\n\ntype MutableSubGroup = ApplicationCommandSubGroupData & {\n options: Mutable<ApplicationCommandSubGroupData['options']>\n}\n\ntype MutableCommand = ChatInputApplicationCommandData & {\n options: ApplicationCommandOptionData[]\n}\n\nexport type ApplicationCommandExtensionConfig = {\n guilds?: Snowflake[]\n}\n\nexport class ApplicationCommandExtension extends CTSExtension {\n constructor(public config: ApplicationCommandExtensionConfig) {\n super()\n }\n\n unmanagedCommands: (ApplicationCommandData & { guilds?: Snowflake[] })[] = []\n\n // noinspection JSUnusedGlobalSymbols\n registerUnmanagedCommand(command: ApplicationCommandData & { guilds?: Snowflake[] }) {\n this.unmanagedCommands.push(command)\n }\n\n @listener({ event: 'interactionCreate' })\n async interactionCreate(i: Interaction) {\n try {\n if (!i.isCommand()) return\n\n let cmd: ApplicationCommandComponent | null = null\n let ext: object | null = null\n\n const extensions = this.commandClient.registry.extensions\n\n let subcommand: string | null = null\n let subcommandGroup: string | null = null\n\n if (i.isChatInputCommand()) {\n subcommand = i.options.getSubcommand(false)\n subcommandGroup = i.options.getSubcommandGroup(false)\n }\n\n extLoop: for (const extension of extensions) {\n const components = this.commandClient.registry.getComponentsWithType<ApplicationCommandComponent>(extension, ApplicationCommandComponent)\n\n if (subcommand) {\n for (const command of components) {\n if (!command.subcommandGroup && !command.subcommandGroupChild) continue\n\n if (\n command.subcommandGroupChild &&\n command.subcommandGroupChild.parent.options.name === i.commandName &&\n command.subcommandGroupChild.options.name === subcommandGroup &&\n command.options.name === subcommand\n ) {\n ext = extension\n cmd = command\n break extLoop\n }\n if (command.subcommandGroup && !subcommandGroup && command.subcommandGroup.options.name === i.commandName && command.options.name === subcommand) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n } else {\n for (const command of components) {\n if (command.options.name === i.commandName) {\n ext = extension\n cmd = command\n break extLoop\n }\n }\n }\n }\n\n if (cmd && ext) {\n const argList: unknown[] = []\n\n await this.convertArguments(ApplicationCommandComponent, argList, cmd.argTypes, () => [i])\n\n for (const [idx, arg] of cmd.argTypes) {\n let value: unknown = null\n\n for (const decorator of arg.decorators) {\n if (decorator instanceof ApplicationCommandOption) {\n if ([ApplicationCommandOptionType.Subcommand, ApplicationCommandOptionType.SubcommandGroup].includes(decorator.options.type) && i.isChatInputCommand()) {\n if (decorator.options.type === ApplicationCommandOptionType.Subcommand) {\n value = i.options.getSubcommand() === decorator.options.name\n break\n }\n if (decorator.options.type === ApplicationCommandOptionType.SubcommandGroup) {\n value = i.options.getSubcommandGroup() === decorator.options.name\n break\n }\n }\n\n value = i.options.get(decorator.options.name, false)?.value\n break\n }\n }\n\n if (value) {\n argList[idx] = value\n }\n }\n\n try {\n await cmd.executeGlobalHook(ext, 'beforeApplicationCommandCall', [i])\n await cmd.execute(ext, argList, [i])\n } finally {\n await cmd.executeGlobalHook(ext, 'afterApplicationCommandCall', [i])\n }\n }\n } catch (e) {\n this.commandClient.emit('applicationCommandInvokeError', e, i)\n }\n }\n\n async sync() {\n const client = this.commandClient\n\n this.logger.info('Trying to sync commands...')\n\n let commands: ApplicationCommandData[] = []\n\n const guildCommands = new Collection<Snowflake, ApplicationCommandData[]>()\n\n const subcommandGroups = new Collection<string, ChatInputApplicationCommandData>()\n\n for (const command of client.registry.getComponentsWithTypeGlobal<ApplicationCommandComponent>(ApplicationCommandComponent)) {\n if (command.subcommandGroup) {\n let group = subcommandGroups.get(command.subcommandGroup.options.name) as MutableGroup\n\n if (!group) {\n group = {\n ...command.subcommandGroup.options,\n type: ApplicationCommandType.ChatInput,\n } as MutableGroup\n\n if (command.subcommandGroup.guilds) {\n for (const guild of command.subcommandGroup.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(command.subcommandGroup.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n group.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as Mutable<ApplicationCommandSubCommandData>)\n\n continue\n } else if (command.subcommandGroupChild) {\n const parent = command.subcommandGroupChild.parent\n let group = subcommandGroups.get(parent.options.name) as MutableGroup\n\n if (!group) {\n group = {\n ...parent.options,\n type: ApplicationCommandType.ChatInput,\n } as MutableGroup\n\n if (parent.guilds) {\n for (const guild of parent.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n }\n } else {\n commands.push(group)\n }\n\n subcommandGroups.set(parent.options.name, group)\n }\n\n if (!group.options) group.options = []\n\n let child = group.options.find((x) => x.name === command.subcommandGroupChild?.options.name) as MutableSubGroup\n\n if (!child) {\n child = {\n ...(command.subcommandGroupChild.options as Omit<ApplicationCommandSubGroupData, 'type'>),\n type: ApplicationCommandOptionType.SubcommandGroup,\n } as MutableSubGroup\n group.options.push(child)\n }\n\n if (!child.options) child.options = []\n\n const options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n options.push(option.options)\n }\n }\n\n child.options.push({ ...command.options, type: ApplicationCommandOptionType.Subcommand, options } as Mutable<ApplicationCommandSubCommandData>)\n\n continue\n }\n\n const cmd = { ...command.options } as MutableCommand\n\n if (cmd.type === ApplicationCommandType.ChatInput) {\n cmd.options = []\n\n for (const [, arg] of command.argTypes) {\n const option = arg.decorators.find((x) => x.constructor === ApplicationCommandOption) as ApplicationCommandOption\n\n if (option) {\n cmd.options.push(option.options)\n }\n }\n }\n\n await command.executeHook(this, 'beforeSync', [cmd, command])\n\n if (command.options.guilds) {\n for (const guild of command.options.guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(cmd)\n }\n continue\n }\n\n commands.push(cmd)\n }\n\n for (const { guilds, ...rest } of this.unmanagedCommands) {\n if (guilds) {\n for (const guild of guilds) {\n let commands = guildCommands.get(guild)\n if (!commands) {\n commands = []\n guildCommands.set(guild, commands)\n }\n commands.push(rest)\n }\n } else {\n commands.push(rest)\n }\n }\n\n if (this.config.guilds) {\n for (const guild of this.config.guilds) {\n let g = guildCommands.get(guild)\n if (!g) {\n g = []\n guildCommands.set(guild, g)\n }\n g.push(...commands)\n }\n\n commands = []\n }\n\n if (guildCommands.size) {\n for (const [guild, commands] of guildCommands) {\n try {\n const g = await this.client.guilds.fetch(guild)\n await g.fetch()\n this.logger.info(\n `Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`,\n )\n\n await g.commands.set(commands)\n\n this.logger.info(`Successfully registered commands for guild ${chalk.green(g.name)}(${chalk.blue(g.id)})`)\n } catch (e) {\n this.logger.error(`Failed to register commands to guild ${chalk.green(guild)}: ${(e as Error).message}`)\n }\n }\n }\n if (commands.length) {\n try {\n this.logger.info(`Processing ${chalk.green(commands.length)} commands(${commands.map((x) => chalk.blue(x.name)).join(', ')}) for application scope...`)\n\n if (this.client.application) {\n await this.client.application.commands.set(commands)\n\n this.logger.info('Successfully registered commands.')\n } else {\n this.logger.error('Client#application is not yet initialized.')\n }\n } catch (e) {\n this.logger.error(`Failed to register commands to global: ${(e as Error).message}`)\n }\n }\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: ChatInputCommandInteraction,\n })\n async chatInteraction(i: ChatInputCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: MessageContextMenuCommandInteraction,\n })\n async messageInteraction(i: MessageContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: UserContextMenuCommandInteraction,\n })\n async userInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n\n @argConverter({\n component: ApplicationCommandComponent,\n parameterless: true,\n type: CommandInteraction,\n })\n async commandInteraction(i: UserContextMenuCommandInteraction) {\n return i\n }\n}\n","import { createComponentDecorator } from '../core/components/decoratorCreator'\nimport { BaseComponent } from '../core/components/BaseComponent'\n\nexport type TextCommandOptions = {\n name: string\n aliases?: string[]\n description?: string\n}\n\nexport class TextCommandComponent extends BaseComponent {\n constructor(public options: TextCommandOptions) {\n super()\n }\n}\n\nexport const command = (options: TextCommandOptions) => createComponentDecorator(new TextCommandComponent(options))\n","import { ComponentArgumentDecorator } from '../core'\nimport { createArgumentDecorator } from '../core'\n\nexport class TextCommandRestOption extends ComponentArgumentDecorator<void> {}\n\nexport const rest = createArgumentDecorator(TextCommandRestOption)\n","import { listener } from '../core/listener'\nimport { Message } from 'discord.js'\nimport { CTSExtension } from '../core/extensions/CTSExtension'\nimport { TextCommandComponent } from './TextCommand'\nimport { TextCommandRestOption } from './parameters'\nimport { argConverter } from '../core'\n\nexport type TextCommandConfig = {\n prefix: string | string[] | ((msg: Message) => Promise<string | string[]> | string | string[])\n}\n\ndeclare module 'discord.js' {\n interface Message {\n command: TextCommandComponent\n }\n}\n\nexport class TextCommandExtension extends CTSExtension {\n constructor(private config: TextCommandConfig) {\n super()\n }\n\n private async processPrefix(msg: Message): Promise<number | null> {\n const content = msg.content\n let prefix = this.config.prefix\n\n if (typeof prefix === 'function') {\n prefix = await prefix(msg)\n }\n\n if (typeof prefix === 'string') {\n if (content.startsWith(prefix)) return prefix.length\n return null\n }\n\n if (prefix instanceof Array) {\n const p = prefix.find((x) => content.startsWith(x))\n\n if (p) return p.length\n return null\n }\n\n return null\n }\n\n @listener({ event: 'messageCreate', emitter: 'discord' })\n private async messageCreate(msg: Message) {\n try {\n const startIndex = await this.processPrefix(msg)\n\n if (startIndex === null) return\n\n const content = msg.content.slice(startIndex)\n\n const commands: TextCommandComponent[] = []\n\n const extensions = new Map<TextCommandComponent, object>()\n\n for (const ext of this.commandClient.registry.extensions) {\n for (const cmd of this.commandClient.registry.getComponentsWithType<TextCommandComponent>(ext, TextCommandComponent)) {\n commands.push(cmd)\n extensions.set(cmd, ext)\n }\n }\n\n let commandNameLength = 0\n\n const command = commands.find((x) => {\n const names = [x.options.name]\n\n if (x.options.aliases) {\n names.push(...x.options.aliases)\n }\n\n for (const name of names) {\n if (content.startsWith(name)) {\n if (content.length === name.length) {\n commandNameLength = name.length\n return true\n }\n commandNameLength = name.length\n return content.startsWith(name + ' ')\n }\n }\n\n return false\n })\n\n if (!command) return\n\n const ext = extensions.get(command)\n\n if (!ext) return\n\n msg.command = command\n\n const args: unknown[] = []\n\n let argStrings = content.slice(commandNameLength + 1).split(/ /g)\n\n await this.convertArguments(TextCommandComponent, args, command.argTypes, async (arg, i, converter) => {\n if (converter.options.parameterless) return [msg]\n\n if (arg.decorators.find((x) => x.constructor === TextCommandRestOption)) {\n const text = argStrings.join(' ')\n argStrings = []\n return [text, msg]\n }\n return [argStrings.shift(), msg]\n })\n\n await command.execute(ext, args, [msg])\n } catch (e) {\n this.commandClient.emit('textCommandInvokeError', e, msg)\n }\n }\n\n @argConverter({\n component: TextCommandComponent,\n type: Message,\n parameterless: true,\n })\n async mesage(msg: Message) {\n return msg\n }\n\n @argConverter({ component: TextCommandComponent, type: String })\n async str(value: string) {\n return value\n }\n\n @argConverter({ component: TextCommandComponent, type: Number })\n async num(value: string) {\n return Number(value)\n }\n}\n","import chalk from 'chalk'\nimport type { Client, Snowflake } from 'discord.js'\nimport { Team, User } from 'discord.js'\nimport EventEmitter from 'events'\nimport type { ISettingsParam } from 'tslog'\nimport { Logger } from 'tslog'\nimport type { ApplicationCommandExtensionConfig } from '../../applicationCommand/ApplicationCommandExtension'\nimport { ApplicationCommandExtension } from '../../applicationCommand/ApplicationCommandExtension'\nimport type { TextCommandConfig } from '../../textCommand'\nimport { TextCommandExtension } from '../../textCommand/TextCommandExtension'\nimport { CommandClientSymbol } from '../symbols'\nimport { Registry } from './Registry'\nexport class CommandClient extends EventEmitter {\n ctsLogger: Logger<unknown>\n registry: Registry\n\n owners: Set<Snowflake> = new Set()\n\n constructor(\n public discord: Client,\n public logger: Logger<unknown> = new Logger({ prettyLogTimeZone: 'local' }),\n loggerOptions: ISettingsParam<unknown> = {},\n ) {\n super()\n\n this.ctsLogger = logger.getSubLogger({\n ...loggerOptions,\n name: 'command.ts',\n })\n\n this.registry = new Registry(this.ctsLogger, this)\n\n this.registry.registerEventEmitter('cts', this)\n this.registry.registerEventEmitter('discord', this.discord)\n }\n\n async isOwner(user: User): Promise<boolean> {\n return this.owners.has(user.id)\n }\n\n async fetchOwners() {\n if (!this.discord.application) throw new Error('The client is not logged in.')\n\n this.ctsLogger.info('Fetching owners...')\n\n await this.discord.application.fetch()\n\n const owner = this.discord.application.owner\n\n if (!owner) throw new Error('Cannot find application owner')\n\n const owners: string[] = []\n\n if (owner instanceof User) {\n this.owners.add(owner.id)\n owners.push(owner.tag)\n } else if (owner instanceof Team) {\n for (const [id, member] of owner.members) {\n this.owners.add(id)\n owners.push(member.user.tag)\n }\n }\n\n this.ctsLogger.info(`Fetched ${chalk.green(owners.length)} owners(${owners.map((x) => chalk.blue(x)).join(', ')})`)\n }\n\n async enableApplicationCommandsExtension(config: ApplicationCommandExtensionConfig) {\n await this.registry.registerModule(new ApplicationCommandExtension(config))\n this.ctsLogger.info('Application command extension enabled.')\n }\n\n async enableTextCommandsExtension(config: TextCommandConfig) {\n await this.registry.registerModule(new TextCommandExtension(config))\n this.ctsLogger.info('Text command extension enabled.')\n }\n\n getApplicationCommandsExtension() {\n return this.registry.extensions.find((x) => x.constructor === ApplicationCommandExtension) as ApplicationCommandExtension | undefined\n }\n\n static getFromModule(ext: object): CommandClient {\n return Reflect.getMetadata(CommandClientSymbol, ext)\n }\n}\n","import { Collection } from 'discord.js'\nimport type { AnyFunction } from '../../utils/types'\nimport type { ComponentHookStore } from '../hooks'\nimport { ComponentArgument } from './ComponentArgument'\n\nexport class BaseComponent {\n method!: AnyFunction\n\n hooks: ComponentHookStore = new Collection()\n\n argTypes: Collection<number, ComponentArgument> = new Collection()\n\n _init(method: AnyFunction, argTypes: unknown[]) {\n this.method = method\n for (let i = 0; i < argTypes.length; i++) {\n const element = argTypes[i]\n this.argTypes.set(i, new ComponentArgument(element))\n }\n }\n\n async executeGlobalHook(target: object, name: string, args: unknown[]) {\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n for (const fn of globalHooks) {\n await fn.call(null, client, ...args)\n }\n }\n }\n\n async executeHook(target: object, name: string, args: unknown[]) {\n const hook = this.hooks.get(name)\n\n if (!hook) return\n\n const { CommandClient } = await import('../structures/CommandClient')\n\n const client = CommandClient.getFromModule(target)\n\n const globalHooks = client.registry.globalHooks[name]\n\n if (globalHooks) {\n hook.unshift(...globalHooks)\n }\n\n for (const fn of hook) {\n await fn.call(null, client, ...args)\n }\n }\n\n async execute(target: object, args: unknown[], beforeCallArgs: unknown[] = args) {\n await this.executeHook(target, 'beforeCall', beforeCallArgs)\n let result\n try {\n result = await this.method.call(target, ...args)\n await this.executeHook(target, 'afterCall', [...beforeCallArgs, result])\n } catch (e) {\n await this.executeHook(target, 'invokeError', [e, ...beforeCallArgs])\n throw e\n }\n\n return result\n }\n}\n","import 'reflect-metadata'\nexport * from './decoratorCreator'\nexport * from './ComponentArgument'\nexport * from './ComponentArgumentDecorator'\nexport * from './BaseComponent'\n","export class OwnerOnlyError {}\n","import type { Interaction } from 'discord.js'\nimport { BaseInteraction, Message } from 'discord.js'\nimport { createComponentHook } from '../hooks'\nimport type { ComponentHookFn } from '../hooks/componentHook'\nimport type { CommandClient } from '../structures'\nimport { OwnerOnlyError } from './errors'\n\nexport const createCheckDecorator = (fn: ComponentHookFn<[CommandClient, Interaction | Message]>) => createComponentHook('beforeCall', fn)\n\nexport const ownerOnly = createCheckDecorator(async (client: CommandClient, i: Interaction | Message) => {\n let isOwner = false\n\n if (i instanceof BaseInteraction) {\n client\n isOwner = await client.isOwner(i.user)\n } else if (i instanceof Message) {\n isOwner = await client.isOwner(i.author)\n }\n\n if (!isOwner) throw new OwnerOnlyError()\n})\n","export const mergeMethodDecorators = (decorators: MethodDecorator[]): MethodDecorator => {\n return (target, key, descriptor) => {\n for (const decorator of decorators) {\n decorator(target, key, descriptor)\n }\n }\n}\n","export * from './checks'\nexport * from './errors'\nexport * from './decorators'\n","export * from './Extension'\n","export * from './components'\nexport * from './hooks'\nexport * from './converter'\nexport * from './utils'\nexport * from './listener'\nexport * from './structures'\nexport * from './extensions'\n","export * from './core'\nexport * from './applicationCommand'\nexport * from './textCommand'\n","export * from './ApplicationCommand'\nexport { option } from './ApplicationCommandOption'\nexport * from './group'\nexport * from './ApplicationCommandExtension'\n","import type { ApplicationCommandSubGroupData, ChatInputApplicationCommandData } from 'discord.js'\nimport { ApplicationCommandType } from 'discord.js'\nimport { createComponentDecorator } from '../core'\nimport { ApplicationCommandComponent } from './ApplicationCommand'\n\nexport class SubCommandGroup {\n constructor(\n public options: Omit<ChatInputApplicationCommandData, 'type'>,\n public guilds?: string[],\n ) {}\n\n command(options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroup = this\n return createComponentDecorator(cmd)\n }\n\n createChild(options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>) {\n return new SubCommandGroupChild(options, this)\n }\n}\n\nexport class SubCommandGroupChild {\n constructor(\n public options: Omit<ApplicationCommandSubGroupData, 'options' | 'type'>,\n public parent: SubCommandGroup,\n ) {}\n\n command(options: Omit<ChatInputApplicationCommandData, 'options' | 'type'>): MethodDecorator {\n const cmd = new ApplicationCommandComponent({\n type: ApplicationCommandType.ChatInput,\n ...options,\n })\n cmd.subcommandGroupChild = this\n return createComponentDecorator(cmd)\n }\n}\n","export * from './TextCommand'\nexport type { TextCommandConfig } from './TextCommandExtension'\nexport * from './parameters'\n"],"mappings":"w6CAAA,IAAaA,EACAC,GACAC,GACAC,GACAC,GACAC,GALbC,EAAAC,EAAA,kBAAaP,EAAuBQ,OAAAA,EACvBP,GA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ClientSymbol","ComponentHookSymbol","FilePathSymbol","init_symbols","__esmMin","Symbol","import_discord","getComponentHookStore","createComponentHook","init_componentHook","__esmMin","init_symbols","__name","target","property","data","Reflect","getMetadata","ComponentHookSymbol","Collection","defineMetadata","name","fn","key","store","hooks","get","set","unshift","import_discord","getComponentStore","getComponent","createComponentDecorator","getComponentArgumentStore","createArgumentDecorator","init_decoratorCreator","__esmMin","init_componentHook","init_symbols","__name","target","result","Reflect","getMetadata","ComponentStoreSymbol","Collection","defineMetadata","key","get","component","_init","componentHookStore","getComponentHookStore","hooks","store","forEach","x","i","_a","argTypes","decorators","push","set","type","options","idx","arg","ComponentArgument","init_ComponentArgument","__esmMin","constructor","type","decorators","_ComponentArgument","import_lodash","ComponentArgumentDecorator","init_ComponentArgumentDecorator","__esmMin","constructor","options","_","merge","defaultOptions","_ComponentArgumentDecorator","ApplicationCommandComponent","applicationCommand","init_ApplicationCommand","__esmMin","init_decoratorCreator","init_BaseComponent","BaseComponent","constructor","options","subcommandGroup","subcommandGroupChild","_ApplicationCommandComponent","__name","createComponentDecorator","ApplicationCommandOption","option","init_ApplicationCommandOption","__esmMin","init_core","ComponentArgumentDecorator","_ApplicationCommandOption","createArgumentDecorator","ConverterComponent","argConverter","init_converter","__esmMin","init_BaseComponent","init_decoratorCreator","BaseComponent","constructor","options","_ConverterComponent","__name","createComponentDecorator","import_discord","getModuleHookStore","moduleHook","init_moduleHook","__esmMin","init_symbols","__name","target","result","Reflect","getMetadata","ModuleHookStoreSymbol","Collection","defineMetadata","name","key","store","v","get","set","push","init_hooks","__esmMin","init_moduleHook","init_componentHook","import_lodash","ListenerComponent","listener","init_listener","__esmMin","init_BaseComponent","init_decoratorCreator","BaseComponent","constructor","options","_","merge","emitter","_ListenerComponent","__name","createComponentDecorator","import_chalk","import_discord","import_lodash","import_walk_sync","import_path","Registry","init_Registry","__esmMin","init_components","init_hooks","init_listener","init_symbols","constructor","logger","client","extensions","emitters","globalHooks","Collection","getSubLogger","name","chalk","green","addGlobalHook","fn","hooks","push","getComponentsWithTypeGlobal","type","result","ext","getComponentsWithType","componentStore","getComponentStore","Array","from","filter","x","values","registerEventListeners","listeners","ListenerComponent","listener","emitter","get","options","bound","method","bind","Reflect","defineMetadata","addListener","event","unregisterEventListeners","getMetadata","removeListener","loadAllModulesInDirectory","dir","pattern","__async","results","files","walkSync","endsWith","test","file","p","path","join","loadModulesAtPath","info","require","resolve","mod","setup","Error","modules","registerModules","module","registerModule","FilePathSymbol","reloadModules","paths","Set","add","unregisterModule","cache","e","error","CommandClientSymbol","runModuleHook","_","remove","hookName","args","functions","getModuleHookStore","call","registerEventEmitter","set","_Registry","init_structures","__esmMin","init_Registry","init_CommandClient","import_chalk","import_discord","Extension","init_Extension","__esmMin","init_converter","init_structures","_logger","commandClient","CommandClient","getFromModule","client","discord","logger","getSubLogger","name","chalk","green","constructor","convertArguments","component","argList","args","getConverterArgs","__async","items","Collection","extension","registry","extensions","converter","getComponentsWithType","ConverterComponent","options","set","type","ext","index","arg","get","undefined","converterArgs","execute","_Extension","import_chalk","CTSExtension","init_CTSExtension","__esmMin","init_Extension","Extension","logger","_logger","commandClient","ctsLogger","getSubLogger","name","chalk","green","constructor","_CTSExtension","import_chalk","import_discord","import_v10","ApplicationCommandExtension","init_ApplicationCommand","init_ApplicationCommandOption","init_core","init_CTSExtension","CTSExtension","constructor","config","unmanagedCommands","registerUnmanagedCommand","command","push","interactionCreate","i","__async","isCommand","cmd","ext","extensions","commandClient","registry","subcommand","subcommandGroup","isChatInputCommand","options","getSubcommand","getSubcommandGroup","extLoop","extension","components","getComponentsWithType","ApplicationCommandComponent","subcommandGroupChild","parent","name","commandName","argList","convertArguments","argTypes","idx","arg","value","decorator","decorators","ApplicationCommandOption","ApplicationCommandOptionType","Subcommand","SubcommandGroup","includes","type","get","executeGlobalHook","execute","e","emit","sync","client","logger","info","commands","guildCommands","Collection","subcommandGroups","getComponentsWithTypeGlobal","group","__spreadProps","__spreadValues","ApplicationCommandType","ChatInput","guilds","guild","set","option","find","x","child","executeHook","_a","_b","rest","g","size","fetch","chalk","green","length","map","blue","join","id","error","message","application","chatInteraction","messageInteraction","userInteraction","commandInteraction","_ApplicationCommandExtension","listener","event","argConverter","component","parameterless","ChatInputCommandInteraction","MessageContextMenuCommandInteraction","UserContextMenuCommandInteraction","CommandInteraction","TextCommandComponent","command","init_TextCommand","__esmMin","init_decoratorCreator","init_BaseComponent","BaseComponent","constructor","options","_TextCommandComponent","__name","createComponentDecorator","TextCommandRestOption","rest","init_parameters","__esmMin","init_core","ComponentArgumentDecorator","_TextCommandRestOption","createArgumentDecorator","import_discord","TextCommandExtension","init_listener","init_CTSExtension","init_TextCommand","init_parameters","init_core","CTSExtension","constructor","config","processPrefix","msg","__async","content","prefix","startsWith","length","Array","p","find","x","messageCreate","startIndex","slice","commands","extensions","Map","ext","commandClient","registry","cmd","getComponentsWithType","TextCommandComponent","push","set","commandNameLength","command","names","options","name","aliases","get","args","argStrings","split","convertArguments","argTypes","arg","i","converter","parameterless","decorators","TextCommandRestOption","text","join","shift","execute","e","emit","mesage","str","value","num","Number","_TextCommandExtension","listener","event","emitter","argConverter","component","type","Message","String","CommandClient_exports","__export","CommandClient","import_chalk","import_discord","import_events","import_tslog","init_CommandClient","__esmMin","init_ApplicationCommandExtension","init_TextCommandExtension","init_symbols","init_Registry","EventEmitter","constructor","discord","logger","Logger","prettyLogTimeZone","loggerOptions","ctsLogger","registry","owners","Set","getSubLogger","__spreadProps","__spreadValues","name","Registry","registerEventEmitter","isOwner","user","__async","has","id","fetchOwners","application","Error","info","fetch","owner","User","add","push","tag","Team","member","members","chalk","green","length","map","x","blue","join","enableApplicationCommandsExtension","config","registerModule","ApplicationCommandExtension","enableTextCommandsExtension","TextCommandExtension","getApplicationCommandsExtension","extensions","find","getFromModule","ext","Reflect","getMetadata","CommandClientSymbol","_CommandClient","import_discord","BaseComponent","init_BaseComponent","__esmMin","init_ComponentArgument","method","hooks","Collection","argTypes","_init","i","length","element","set","ComponentArgument","executeGlobalHook","target","name","args","__async","CommandClient","client","getFromModule","globalHooks","registry","fn","call","executeHook","hook","get","unshift","execute","beforeCallArgs","result","e","_BaseComponent","import_reflect_metadata","init_components","__esmMin","init_decoratorCreator","init_ComponentArgument","init_ComponentArgumentDecorator","init_BaseComponent","OwnerOnlyError","init_errors","__esmMin","_OwnerOnlyError","import_discord","createCheckDecorator","ownerOnly","init_checks","__esmMin","init_hooks","init_errors","__name","fn","createComponentHook","client","i","isOwner","BaseInteraction","user","Message","author","OwnerOnlyError","mergeMethodDecorators","init_decorators","__esmMin","__name","decorators","target","key","descriptor","decorator","init_utils","__esmMin","init_checks","init_errors","init_decorators","init_extensions","__esmMin","init_Extension","init_core","__esmMin","init_components","init_hooks","init_converter","init_utils","init_listener","init_structures","init_extensions","src_exports","__export","ApplicationCommandComponent","ApplicationCommandExtension","BaseComponent","CommandClient","ComponentArgument","ComponentArgumentDecorator","ConverterComponent","Extension","ListenerComponent","OwnerOnlyError","Registry","SubCommandGroup","SubCommandGroupChild","TextCommandComponent","TextCommandRestOption","applicationCommand","argConverter","command","createArgumentDecorator","createCheckDecorator","createComponentDecorator","createComponentHook","getComponent","getComponentArgumentStore","getComponentStore","getModuleHookStore","listener","mergeMethodDecorators","moduleHook","option","ownerOnly","rest","__toCommonJS","init_core","init_ApplicationCommand","init_ApplicationCommandOption","import_discord","init_core","init_ApplicationCommand","SubCommandGroup","constructor","options","guilds","command","cmd","ApplicationCommandComponent","__spreadValues","type","ApplicationCommandType","ChatInput","subcommandGroup","createComponentDecorator","createChild","SubCommandGroupChild","_SubCommandGroup","parent","subcommandGroupChild","_SubCommandGroupChild","init_ApplicationCommandExtension","init_TextCommand","init_parameters"]}
package/package.json CHANGED
@@ -1,38 +1,38 @@
1
1
  {
2
2
  "name": "@pikokr/command.ts",
3
3
  "description": "Discord.js command framework for typescript.",
4
- "version": "5.6.2-dev.4",
4
+ "version": "5.7.0-dev.1",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "MIT",
8
8
  "devDependencies": {
9
9
  "@discordjs/ts-docgen": "^0.4.1",
10
- "@swc/core": "1.3.78",
11
- "@types/lodash": "4.14.197",
12
- "@typescript-eslint/eslint-plugin": "^6.4.1",
13
- "@typescript-eslint/parser": "^6.4.1",
10
+ "@swc/core": "1.3.101",
11
+ "@types/lodash": "4.14.202",
12
+ "@typescript-eslint/eslint-plugin": "^6.16.0",
13
+ "@typescript-eslint/parser": "^6.16.0",
14
14
  "all-contributors-cli": "6.26.1",
15
- "discord-api-types": "^0.37.54",
16
- "discord.js": "14.13.0",
15
+ "discord-api-types": "^0.37.66",
16
+ "discord.js": "14.14.1",
17
17
  "dotenv": "16.3.1",
18
- "eslint": "^8.47.0",
19
- "eslint-config-prettier": "^9.0.0",
20
- "eslint-plugin-prettier": "^5.0.0",
21
- "prettier": "3.0.2",
22
- "rimraf": "5.0.1",
23
- "semantic-release": "^21.0.9",
24
- "ts-node": "10.9.1",
25
- "tslog": "^4.9.1",
26
- "tsup": "7.2.0",
27
- "typedoc": "^0.25.0",
28
- "typescript": "^5.1.6",
18
+ "eslint": "^8.56.0",
19
+ "eslint-config-prettier": "^9.1.0",
20
+ "eslint-plugin-prettier": "^5.1.2",
21
+ "prettier": "3.1.1",
22
+ "rimraf": "5.0.5",
23
+ "semantic-release": "^22.0.12",
24
+ "ts-node": "10.9.2",
25
+ "tslog": "^4.9.2",
26
+ "tsup": "8.0.1",
27
+ "typedoc": "^0.25.4",
28
+ "typescript": "^5.3.3",
29
29
  "utility-types": "^3.10.0"
30
30
  },
31
31
  "dependencies": {
32
- "@types/node": "^20.5.3",
33
- "chalk": "4.1.2",
32
+ "@types/node": "^20.10.5",
33
+ "chalk": "5.3.0",
34
34
  "lodash": "^4.17.21",
35
- "reflect-metadata": "^0.1.13",
35
+ "reflect-metadata": "^0.2.1",
36
36
  "walk-sync": "^3.0.0"
37
37
  },
38
38
  "repository": {
@@ -50,7 +50,7 @@
50
50
  "semantic-release": "semantic-release"
51
51
  },
52
52
  "peerDependencies": {
53
- "discord.js": "14.13.0",
53
+ "discord.js": "14",
54
54
  "tslog": "*"
55
55
  },
56
56
  "release": {
package/shell.nix ADDED
@@ -0,0 +1,3 @@
1
+ { pkgs ? import <nixpkgs> { } }:
2
+
3
+ pkgs.mkShell { packages = with pkgs; [ nodejs_20 corepack ]; }