commandkit 1.0.0-dev.20250528125253 → 1.0.0-dev.20250529125116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (91) hide show
  1. package/dist/CommandKit.js +4 -4
  2. package/dist/CommandKit.js.map +1 -1
  3. package/dist/app/commands/AppCommandRunner.js +2 -2
  4. package/dist/app/commands/AppCommandRunner.js.map +1 -1
  5. package/dist/app/commands/Context.js +2 -2
  6. package/dist/app/commands/Context.js.map +1 -1
  7. package/dist/app/handlers/AppCommandHandler.js +3 -3
  8. package/dist/app/handlers/AppCommandHandler.js.map +1 -1
  9. package/dist/app/handlers/AppEventsHandler.js +2 -2
  10. package/dist/app/handlers/AppEventsHandler.js.map +1 -1
  11. package/dist/app/index.js +3 -3
  12. package/dist/app/index.js.map +1 -1
  13. package/dist/app/register/CommandRegistrar.js +2 -2
  14. package/dist/app/register/CommandRegistrar.js.map +1 -1
  15. package/dist/cli/app-process.js +2 -2
  16. package/dist/cli/app-process.js.map +1 -1
  17. package/dist/cli/build.js +2 -2
  18. package/dist/cli/build.js.map +1 -1
  19. package/dist/cli/common.js +4 -4
  20. package/dist/cli/common.js.map +1 -1
  21. package/dist/cli/development.js +8 -8
  22. package/dist/cli/development.js.map +1 -1
  23. package/dist/cli/generators.js +4 -4
  24. package/dist/cli/generators.js.map +1 -1
  25. package/dist/cli/information.js +1 -1
  26. package/dist/cli/information.js.map +1 -1
  27. package/dist/cli/init.js +15 -15
  28. package/dist/cli/init.js.map +1 -1
  29. package/dist/cli/production.js +9 -9
  30. package/dist/cli/production.js.map +1 -1
  31. package/dist/cli/type-checker.js +2 -2
  32. package/dist/cli/type-checker.js.map +1 -1
  33. package/dist/components/index.js +4 -4
  34. package/dist/components/index.js.map +1 -1
  35. package/dist/components/v1/button/Button.js +4 -4
  36. package/dist/components/v1/button/Button.js.map +1 -1
  37. package/dist/components/v1/button/ButtonKit.js +4 -4
  38. package/dist/components/v1/button/ButtonKit.js.map +1 -1
  39. package/dist/components/v1/modal/Modal.js +4 -4
  40. package/dist/components/v1/modal/Modal.js.map +1 -1
  41. package/dist/components/v1/modal/ModalKit.js +4 -4
  42. package/dist/components/v1/modal/ModalKit.js.map +1 -1
  43. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js +4 -4
  44. package/dist/components/v1/select-menu/ChannelSelectMenuKit.js.map +1 -1
  45. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js +4 -4
  46. package/dist/components/v1/select-menu/MentionableSelectMenuKit.js.map +1 -1
  47. package/dist/components/v1/select-menu/RoleSelectMenuKit.js +4 -4
  48. package/dist/components/v1/select-menu/RoleSelectMenuKit.js.map +1 -1
  49. package/dist/components/v1/select-menu/SelectMenu.js +4 -4
  50. package/dist/components/v1/select-menu/SelectMenu.js.map +1 -1
  51. package/dist/components/v1/select-menu/StringSelectMenuKit.js +4 -4
  52. package/dist/components/v1/select-menu/StringSelectMenuKit.js.map +1 -1
  53. package/dist/components/v1/select-menu/UserSelectMenuKit.js +4 -4
  54. package/dist/components/v1/select-menu/UserSelectMenuKit.js.map +1 -1
  55. package/dist/config/config.js +2 -2
  56. package/dist/config/config.js.map +1 -1
  57. package/dist/config/default.js +2 -2
  58. package/dist/config/default.js.map +1 -1
  59. package/dist/config/loader.js +4 -4
  60. package/dist/config/loader.js.map +1 -1
  61. package/dist/context/async-context.js +4 -4
  62. package/dist/context/async-context.js.map +1 -1
  63. package/dist/context/environment.js +2 -2
  64. package/dist/context/environment.js.map +1 -1
  65. package/dist/flags/feature-flags.js +6 -6
  66. package/dist/flags/feature-flags.js.map +1 -1
  67. package/dist/index.js +4 -4
  68. package/dist/index.js.map +1 -1
  69. package/dist/logger/DefaultLogger.js +2 -2
  70. package/dist/logger/DefaultLogger.js.map +1 -1
  71. package/dist/logger/Logger.js +2 -2
  72. package/dist/logger/Logger.js.map +1 -1
  73. package/dist/plugins/index.js +2 -2
  74. package/dist/plugins/index.js.map +1 -1
  75. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js +1 -1
  76. package/dist/plugins/plugin-runtime/CommandKitPluginRuntime.js.map +1 -1
  77. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js +1 -1
  78. package/dist/plugins/plugin-runtime/CompilerPluginRuntime.js.map +1 -1
  79. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js +2 -2
  80. package/dist/plugins/plugin-runtime/builtin/CommonDirectiveTransformer.js.map +1 -1
  81. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js +2 -2
  82. package/dist/plugins/plugin-runtime/builtin/MacroPlugin.js.map +1 -1
  83. package/dist/utils/dev-hooks.js +1 -1
  84. package/dist/utils/dev-hooks.js.map +1 -1
  85. package/dist/utils/utilities.js +1 -1
  86. package/dist/utils/utilities.js.map +1 -1
  87. package/dist/version.js +1 -1
  88. package/dist/version.js.map +1 -1
  89. package/flag.cjs +6 -0
  90. package/flag.d.ts +1 -0
  91. package/package.json +10 -3
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var ja=Object.create;var Xe=Object.defineProperty;var Ha=Object.getOwnPropertyDescriptor;var Ga=Object.getOwnPropertyNames;var _a=Object.getPrototypeOf,Va=Object.prototype.hasOwnProperty;var cr=n=>{throw TypeError(n)};var Wa=(n,e,t)=>e in n?Xe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e)=>Xe(n,"name",{value:e,configurable:!0});var g=(n,e)=>()=>(n&&(e=n(n=0)),e);var Qe=(n,e)=>{for(var t in e)Xe(n,t,{get:e[t],enumerable:!0})},mr=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ga(e))!Va.call(n,r)&&r!==t&&Xe(n,r,{get:()=>e[r],enumerable:!(o=Ha(e,r))||o.enumerable});return n};var q=(n,e,t)=>(t=n!=null?ja(_a(n)):{},mr(e||!n||!n.__esModule?Xe(t,"default",{value:n,enumerable:!0}):t,n)),qa=n=>mr(Xe({},"__esModule",{value:!0}),n);var I=(n,e,t)=>Wa(n,typeof e!="symbol"?e+"":e,t),Dn=(n,e,t)=>e.has(n)||cr("Cannot "+t);var c=(n,e,t)=>(Dn(n,e,"read from private field"),t?t.call(n):e.get(n)),x=(n,e,t)=>e.has(n)?cr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),h=(n,e,t,o)=>(Dn(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t),v=(n,e,t)=>(Dn(n,e,"access private method"),t);var l=g(()=>{"use strict"});var ur,C,ye=g(()=>{"use strict";l();ur=require("picocolors"),C=(0,ur.createColors)(!0)});function Ja(n){let e=new dr.ActionRowBuilder;return Array.isArray(n.children)?e.setComponents(...n.children):n.children&&e.setComponents(n.children),e}var dr,pr=g(()=>{"use strict";l();dr=require("discord.js");i(Ja,"ActionRow")});function Ke(n){let e=new Error;return Reflect.set(e,"code",n),e}function lt(n){if(!(n instanceof Error))return!1;let e=Reflect.get(n,"code");for(let t in k)if(k[t]===e)return!0;return!1}function Z(n,e){if(!lt(n))return!1;let t=Reflect.get(n,"code");return t?Array.isArray(e)?e.includes(t):t===e:!1}var k,ke=g(()=>{"use strict";l();k={ExitMiddleware:Symbol("kExitMiddleware"),ForwardedCommand:Symbol("kForwardedCommand"),InvalidCommandPrefix:Symbol("kInvalidCommandPrefix"),PluginCaptureHandle:Symbol("kPluginCaptureHandle")};i(Ke,"createCommandKitError");i(lt,"isCommandKitError");i(Z,"isErrorType")});function za(n){return n&&Reflect.get(n,hr)===!0}function H(n){return ct.exit(n)}function mt(n,e){return Reflect.set(n,hr,!0),ct.run(n,e)}function Kn(n,e,t){return i((...r)=>mt(n,async()=>{try{return await e(...r)}catch(a){lt(a)||n.setExecutionError(a)}finally{typeof t=="function"&&setImmediate(async()=>{try{await t(...r)}catch{}})}}),"_fn")}function U(n=!1){var t;let e=((t=ct.getStore())==null?void 0:t.commandkit)??Te.instance;if(!e&&n)throw new Error("CommandKit instance not found.");return e}function R(){return ct.getStore()}function kn(){let n=ct.getStore();if(!n)throw new Error("No commandkit environment found. Please make sure you are inside commandkit handler.");return n}var fr,hr,ct,_=g(()=>{"use strict";l();fr=require("async_hooks");jt();ke();hr=Symbol("commandkitCommandWorker"),ct=new fr.AsyncLocalStorage;i(za,"isCommandWorkerContext");i(H,"exitContext");i(mt,"provideContext");i(Kn,"makeContextAwareFunction");i(U,"getCommandKit");i(R,"getContext");i(kn,"useEnvironment")});var be,xe,T,Ae,re,gr,Cr,Tn,An,ut,Bn=g(()=>{"use strict";l();be=require("discord.js");_();An=class An extends be.ButtonBuilder{constructor(){super(...arguments);x(this,re);x(this,xe,null);x(this,T,{autoReset:!0,time:5*60*1e3,once:!1});x(this,Ae,null)}onClick(t,o){var r,a,s,m;if(this.data.style===be.ButtonStyle.Link)throw new TypeError('Cannot setup "onClick" handler on link buttons.');if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,xe)&&v(this,re,Tn).call(this),h(this,xe,t),o&&h(this,T,{autoReset:o.autoReset??((r=c(this,T))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,T))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,T))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,T))==null?void 0:m.onEnd)}),v(this,re,Cr).call(this),this}onEnd(t){if(this.data.style===be.ButtonStyle.Link)throw new TypeError('Cannot setup "onEnd" handler on link buttons.');if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,T)??h(this,T,{}),c(this,T).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,T)??h(this,T,{}),c(this,T).onError=t,this}filter(t){return c(this,T)??h(this,T,{autoReset:!0,time:5*60*1e3}),c(this,T).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,re,Tn).call(this),this}};xe=new WeakMap,T=new WeakMap,Ae=new WeakMap,re=new WeakSet,gr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Cr=i(function(){if(this.data.style===be.ButtonStyle.Link||!c(this,T)||!c(this,xe))return;if((this.customId??null)===null)throw new TypeError('Cannot setup "onClick" handler on a button without a custom id.');let o=v(this,re,gr).call(this);h(this,Ae,o.subscribe(be.Events.InteractionCreate,async r=>{var d,p;if(!r.isButton())return;let a=this.customId??null,s=r.customId;if(a&&s!==a)return;let m=(d=c(this,T))==null?void 0:d.filter;if(m&&!await m(r))return;let u=c(this,xe);return u?u(r,this):(p=c(this,Ae))==null?void 0:p.call(this)},c(this,T)))},"#setupInteractionCollector"),Tn=i(function(){var t;(t=c(this,Ae))==null||t.call(this),h(this,Ae,null),h(this,T,null),h(this,xe,null)},"#destroyCollector"),i(An,"ButtonKit");ut=An});function Ya(n){let e=new ut;n.style??=yr.ButtonStyle.Primary,n.onClick&&(n.customId??=`buttonkit::${crypto.randomUUID()}`),n.customId&&e.setCustomId(n.customId),n.onClick&&e.onClick(n.onClick,n.options),n.disabled&&e.setDisabled(n.disabled),n.emoji&&e.setEmoji(n.emoji),n.skuId&&e.setSKUId(n.skuId),n.url&&e.setURL(n.url),n.style&&e.setStyle(n.style);let t=n.label||n.children;return t&&e.setLabel(Array.isArray(t)?t.join(" "):typeof t=="string"?t:String(t)),n.onEnd&&e.onEnd(n.onEnd),n.onError&&e.onError(n.onError),e}var yr,xr=g(()=>{"use strict";l();yr=require("discord.js");Bn();i(Ya,"Button")});var Ht,Be,A,Oe,ie,br,vr,On,Ln,dt,$n=g(()=>{"use strict";l();Ht=require("discord.js");_();Ln=class Ln extends Ht.ModalBuilder{constructor(){super(...arguments);x(this,ie);x(this,Be,null);x(this,A,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Oe,null)}onSubmit(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Be)&&v(this,ie,On).call(this),h(this,Be,t),o&&h(this,A,{autoReset:o.autoReset??((r=c(this,A))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,A))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,A))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,A))==null?void 0:m.onEnd)}),v(this,ie,vr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,A)??h(this,A,{}),c(this,A).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,A)??h(this,A,{}),c(this,A).onError=t,this}filter(t){return c(this,A)??h(this,A,{autoReset:!0,time:5*60*1e3}),c(this,A).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,ie,On).call(this),this}};Be=new WeakMap,A=new WeakMap,Oe=new WeakMap,ie=new WeakSet,br=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),vr=i(function(){if(!c(this,A))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,ie,br).call(this);t&&h(this,Oe,t.subscribe(Ht.Events.InteractionCreate,async o=>{var u,d;if(!o.isModalSubmit())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,A))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Be);return m?m(o,this):(d=c(this,Oe))==null?void 0:d.call(this)},c(this,A)))},"#setupCollector"),On=i(function(){var t;(t=c(this,Oe))==null||t.call(this),h(this,Oe,null),h(this,Be,null),h(this,A,null)},"#destroyCollector"),i(Ln,"ModalKit");dt=Ln});function Xa(n){let e=new dt;if(n.title&&e.setTitle(n.title),n.onSubmit&&(n.customId??=`modalkit::${crypto.randomUUID()}`),n.customId&&e.setCustomId(n.customId),n.onSubmit&&e.onSubmit(n.onSubmit,n.options),n.children){let t=(Array.isArray(n.children)?n.children:[n.children]).map(o=>{if(o instanceof ae.ActionRowBuilder)return o;if(o instanceof ae.TextInputBuilder)return new ae.ActionRowBuilder().addComponents(o)}).filter(o=>o!=null);e.addComponents(t)}return n.onEnd&&e.onEnd(n.onEnd),n.onError&&e.onError(n.onError),e}function Fn(n){let e=new ae.TextInputBuilder().setStyle(n.style);return n.customId&&e.setCustomId(n.customId),n.label&&e.setLabel(n.label),n.placeholder&&e.setPlaceholder(n.placeholder),n.maxLength&&e.setMaxLength(n.maxLength),n.minLength&&e.setMinLength(n.minLength),n.value&&e.setValue(n.value),n.required&&e.setRequired(n.required),e}function Qa(n){return Fn({...n,style:ae.TextInputStyle.Short})}function Za(n){return Fn({...n,style:ae.TextInputStyle.Paragraph})}var ae,Er=g(()=>{"use strict";l();ae=require("discord.js");$n();i(Xa,"Modal");i(Fn,"TextInput");i(Qa,"ShortInput");i(Za,"ParagraphInput")});var Gt,Le,B,$e,se,wr,Mr,Nn,Un,pt,jn=g(()=>{"use strict";l();Gt=require("discord.js");_();Un=class Un extends Gt.StringSelectMenuBuilder{constructor(){super(...arguments);x(this,se);x(this,Le,null);x(this,B,{autoReset:!1,time:5*60*1e3,once:!0});x(this,$e,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Le)&&v(this,se,Nn).call(this),h(this,Le,t),o&&h(this,B,{autoReset:o.autoReset??((r=c(this,B))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,B))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,B))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,B))==null?void 0:m.onEnd)}),v(this,se,Mr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,B)??h(this,B,{}),c(this,B).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,B)??h(this,B,{}),c(this,B).onError=t,this}filter(t){return c(this,B)??h(this,B,{autoReset:!0,time:5*60*1e3}),c(this,B).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,se,Nn).call(this),this}};Le=new WeakMap,B=new WeakMap,$e=new WeakMap,se=new WeakSet,wr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Mr=i(function(){if(!c(this,B))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,se,wr).call(this);t&&h(this,$e,t.subscribe(Gt.Events.InteractionCreate,async o=>{var u,d;if(!o.isStringSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,B))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Le);return m?m(o,this):(d=c(this,$e))==null?void 0:d.call(this)},c(this,B)))},"#setupCollector"),Nn=i(function(){var t;(t=c(this,$e))==null||t.call(this),h(this,$e,null),h(this,Le,null),h(this,B,null)},"#destroyCollector"),i(Un,"StringSelectMenuKit");pt=Un});var _t,Fe,O,Ne,le,Sr,Ir,Hn,Gn,ft,_n=g(()=>{"use strict";l();_t=require("discord.js");_();Gn=class Gn extends _t.ChannelSelectMenuBuilder{constructor(){super(...arguments);x(this,le);x(this,Fe,null);x(this,O,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Ne,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Fe)&&v(this,le,Hn).call(this),h(this,Fe,t),o&&h(this,O,{autoReset:o.autoReset??((r=c(this,O))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,O))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,O))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,O))==null?void 0:m.onEnd)}),v(this,le,Ir).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,O)??h(this,O,{}),c(this,O).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,O)??h(this,O,{}),c(this,O).onError=t,this}filter(t){return c(this,O)??h(this,O,{autoReset:!0,time:5*60*1e3}),c(this,O).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,le,Hn).call(this),this}};Fe=new WeakMap,O=new WeakMap,Ne=new WeakMap,le=new WeakSet,Sr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Ir=i(function(){if(!c(this,O))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,le,Sr).call(this);t&&h(this,Ne,t.subscribe(_t.Events.InteractionCreate,async o=>{var u,d;if(!o.isChannelSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,O))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Fe);return m?m(o,this):(d=c(this,Ne))==null?void 0:d.call(this)},c(this,O)))},"#setupCollector"),Hn=i(function(){var t;(t=c(this,Ne))==null||t.call(this),h(this,Ne,null),h(this,Fe,null),h(this,O,null)},"#destroyCollector"),i(Gn,"ChannelSelectMenuKit");ft=Gn});var Vt,Ue,L,je,ce,Pr,Rr,Vn,Wn,ht,qn=g(()=>{"use strict";l();Vt=require("discord.js");_();Wn=class Wn extends Vt.MentionableSelectMenuBuilder{constructor(){super(...arguments);x(this,ce);x(this,Ue,null);x(this,L,{autoReset:!1,time:5*60*1e3,once:!0});x(this,je,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Ue)&&v(this,ce,Vn).call(this),h(this,Ue,t),o&&h(this,L,{autoReset:o.autoReset??((r=c(this,L))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,L))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,L))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,L))==null?void 0:m.onEnd)}),v(this,ce,Rr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,L)??h(this,L,{}),c(this,L).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,L)??h(this,L,{}),c(this,L).onError=t,this}filter(t){return c(this,L)??h(this,L,{autoReset:!0,time:5*60*1e3}),c(this,L).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,ce,Vn).call(this),this}};Ue=new WeakMap,L=new WeakMap,je=new WeakMap,ce=new WeakSet,Pr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Rr=i(function(){if(!c(this,L))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,ce,Pr).call(this);t&&h(this,je,t.subscribe(Vt.Events.InteractionCreate,async o=>{var u,d;if(!o.isMentionableSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,L))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Ue);return m?m(o,this):(d=c(this,je))==null?void 0:d.call(this)},c(this,L)))},"#setupCollector"),Vn=i(function(){var t;(t=c(this,je))==null||t.call(this),h(this,je,null),h(this,Ue,null),h(this,L,null)},"#destroyCollector"),i(Wn,"MentionableSelectMenuKit");ht=Wn});var Wt,He,$,Ge,me,Dr,Kr,Jn,zn,gt,Yn=g(()=>{"use strict";l();Wt=require("discord.js");_();zn=class zn extends Wt.UserSelectMenuBuilder{constructor(){super(...arguments);x(this,me);x(this,He,null);x(this,$,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Ge,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,He)&&v(this,me,Jn).call(this),h(this,He,t),o&&h(this,$,{autoReset:o.autoReset??((r=c(this,$))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,$))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,$))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,$))==null?void 0:m.onEnd)}),v(this,me,Kr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,$)??h(this,$,{}),c(this,$).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,$)??h(this,$,{}),c(this,$).onError=t,this}filter(t){return c(this,$)??h(this,$,{autoReset:!0,time:5*60*1e3}),c(this,$).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,me,Jn).call(this),this}};He=new WeakMap,$=new WeakMap,Ge=new WeakMap,me=new WeakSet,Dr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Kr=i(function(){if(!c(this,$))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,me,Dr).call(this);t&&h(this,Ge,t.subscribe(Wt.Events.InteractionCreate,async o=>{var u,d;if(!o.isUserSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,$))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,He);return m?m(o,this):(d=c(this,Ge))==null?void 0:d.call(this)},c(this,$)))},"#setupCollector"),Jn=i(function(){var t;(t=c(this,Ge))==null||t.call(this),h(this,Ge,null),h(this,He,null),h(this,$,null)},"#destroyCollector"),i(zn,"UserSelectMenuKit");gt=zn});var qt,_e,F,Ve,ue,kr,Tr,Xn,Qn,Ct,Zn=g(()=>{"use strict";l();qt=require("discord.js");_();Qn=class Qn extends qt.RoleSelectMenuBuilder{constructor(){super(...arguments);x(this,ue);x(this,_e,null);x(this,F,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Ve,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,_e)&&v(this,ue,Xn).call(this),h(this,_e,t),o&&h(this,F,{autoReset:o.autoReset??((r=c(this,F))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,F))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,F))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,F))==null?void 0:m.onEnd)}),v(this,ue,Tr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,F)??h(this,F,{}),c(this,F).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,F)??h(this,F,{}),c(this,F).onError=t,this}filter(t){return c(this,F)??h(this,F,{autoReset:!0,time:5*60*1e3}),c(this,F).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,ue,Xn).call(this),this}};_e=new WeakMap,F=new WeakMap,Ve=new WeakMap,ue=new WeakSet,kr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Tr=i(function(){if(!c(this,F))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,ue,kr).call(this);t&&h(this,Ve,t.subscribe(qt.Events.InteractionCreate,async o=>{var u,d;if(!o.isRoleSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,F))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,_e);return m?m(o,this):(d=c(this,Ve))==null?void 0:d.call(this)},c(this,F)))},"#setupCollector"),Xn=i(function(){var t;(t=c(this,Ve))==null||t.call(this),h(this,Ve,null),h(this,_e,null),h(this,F,null)},"#destroyCollector"),i(Qn,"RoleSelectMenuKit");Ct=Qn});function yt(n,e){n.setCustomId(e.customId??`select-menu::${crypto.randomUUID()}`),e.maxValues!=null&&n.setMaxValues(e.maxValues),e.minValues!=null&&n.setMinValues(e.minValues),e.placeholder&&n.setPlaceholder(e.placeholder),e.disabled&&n.setDisabled(e.disabled),e.onEnd&&n.onEnd(e.onEnd),e.onError&&n.onError(e.onError),e.onSelect&&n.onSelect(e.onSelect,e.options)}function es(n){let e=new pt;return yt(e,n),n.children&&e.setOptions(Array.isArray(n.children)?n.children:[n.children]),n.children&&e.setOptions(Array.isArray(n.children)?n.children:[n.children]),e}function ts(n){return new Ar.StringSelectMenuOptionBuilder(n)}function ns(n){let e=new gt;return yt(e,n),n.defaultValues&&e.setDefaultUsers(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),e}function os(n){let e=new Ct;return yt(e,n),n.defaultValues&&e.setDefaultRoles(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),e}function rs(n){let e=new ht;return yt(e,n),n.defaultValues&&e.setDefaultValues(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),e}function is(n){let e=new ft;return yt(e,n),n.defaultValues&&e.setDefaultChannels(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),n.channelTypes&&e.setChannelTypes(Array.isArray(n.channelTypes)?n.channelTypes:[n.channelTypes]),e}var Ar,Br=g(()=>{"use strict";l();Ar=require("discord.js");_n();qn();Zn();jn();Yn();i(yt,"applyPropsToBuilder");i(es,"StringSelectMenu");i(ts,"StringSelectMenuOption");i(ns,"UserSelectMenu");i(os,"RoleSelectMenu");i(rs,"MentionableSelectMenu");i(is,"ChannelSelectMenu")});var Or=g(()=>{"use strict";l()});function Ze(n,e){n.id!=null&&e.setId(n.id)}var Jt=g(()=>{"use strict";l();i(Ze,"applyId")});function as(n){let e=new V.ContainerBuilder;if(Ze(n,e),typeof n.accentColor!=null&&e.setAccentColor(n.accentColor),n.spoiler!=null&&e.setSpoiler(n.spoiler),n.children!=null){if(Array.isArray(n.children)||(n.children=[n.children]),n.children.length===0)return e;for(let t of n.children.flat())t instanceof V.TextDisplayBuilder&&e.addTextDisplayComponents(t),t instanceof V.FileBuilder&&e.addFileComponents(t),t instanceof V.ActionRowBuilder&&e.addActionRowComponents(t),t instanceof V.SeparatorBuilder&&e.addSeparatorComponents(t),t instanceof V.SectionBuilder&&e.addSectionComponents(t),t instanceof V.MediaGalleryBuilder&&e.addMediaGalleryComponents(t)}return e}var V,Lr=g(()=>{"use strict";l();V=require("discord.js");Jt();i(as,"Container")});function ss(n){let e=new $r.FileBuilder(n);return n.url!=null&&e.setURL(n.url),e}var $r,Fr=g(()=>{"use strict";l();$r=require("discord.js");i(ss,"File")});function ls(n){let e=new zt.MediaGalleryBuilder;return Ze(n,e),n.children!=null&&(Array.isArray(n.children)||(n.children=[n.children]),e.addItems(n.children.flat())),e}function cs(n){let e=new zt.MediaGalleryItemBuilder;return n.description!=null&&e.setDescription(n.description),n.spoiler!=null&&e.setSpoiler(n.spoiler),n.url!=null&&e.setURL(n.url),e}var zt,Nr=g(()=>{"use strict";l();zt=require("discord.js");Jt();i(ls,"MediaGallery");i(cs,"MediaGalleryItem")});function ms(n){let e=new de.SectionBuilder;if(Ze(n,e),n.children!=null){Array.isArray(n.children)||(n.children=[n.children]);for(let t of n.children.flat())t instanceof de.ThumbnailBuilder?e.setThumbnailAccessory(t):t instanceof de.ButtonBuilder?e.setButtonAccessory(t):t instanceof de.TextDisplayBuilder&&e.addTextDisplayComponents(t)}return e}function us(n){return new de.ThumbnailBuilder({description:n.description,spoiler:n.spoiler,id:n.id,media:{url:n.url}})}var de,Ur=g(()=>{"use strict";l();de=require("discord.js");Jt();i(ms,"Section");i(us,"Thumbnail")});function ds(n){return new jr.SeparatorBuilder(n)}var jr,Hr=g(()=>{"use strict";l();jr=require("discord.js");i(ds,"Separator")});function ps(n){let e=new Gr.TextDisplayBuilder(n);return!n.content&&n.children&&(Array.isArray(n.children)?e.setContent(n.children.join(" ")):e.setContent(typeof n.children=="string"?n.children:String(n.children))),e}var Gr,_r=g(()=>{"use strict";l();Gr=require("discord.js");i(ps,"TextDisplay")});var Vr=g(()=>{"use strict";l();Lr();Fr();Nr();Ur();Hr();_r()});function fs(n,e="CommandKitWarning"){process.emitWarning(n,{code:e})}function eo(n){Wr.has(n)||(Wr.add(n),fs(`${n} is unstable and may change in future versions.`,"CommandKitUnstableWarning"))}var Wr,qr=g(()=>{"use strict";l();Wr=new Set;i(fs,"emitWarning");i(eo,"warnUnstable")});function gs(n){return!(typeof n!="object"||n===null||!Reflect.has(n,"type")||!Reflect.has(n,"data"))}function Cs(n){return n.data}function to(n){return eo("CommandKit JSX"),Array.isArray(n.children)?n.children.flat():[n.children]}function no(n,e,...t){return eo("CommandKit JSX"),n({...e,children:e.children??t})}var hs,Jr=g(()=>{"use strict";l();qr();hs={ActionRow:"action-row",Button:"button-kit",Modal:"modal",TextInput:"text-input"};i(gs,"isCommandKitElement");i(Cs,"getElement");i(to,"Fragment");i(no,"createElement")});var zr=g(()=>{"use strict";l()});var Yt,Yr,oo,xt,ro=g(()=>{"use strict";l();oo=class oo{constructor(e){this.client=e;x(this,Yt);I(this,"subscribers",new Map);I(this,"globalHandlers",new Map);I(this,"cleanupTimer",null);v(this,Yt,Yr).call(this)}destroy(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null);for(let[e,t]of this.subscribers)for(let o of t)this.unsubscribe(e,o,"destroy");this.subscribers.clear(),this.globalHandlers.clear()}hasSubscribers(e){return this.subscribers.has(e)}getSubscriberCount(e){let t=this.subscribers.get(e);return(t==null?void 0:t.size)??0}hasGlobalHandlers(){return this.globalHandlers.size>0}getGlobalHandlersCount(){return this.subscribers.size}subscribe(e,t,o){return this.subscribers.has(e)||(this.subscribers.set(e,new Set),this.client.on(e,this.createGlobalHandler(e)),this.client.setMaxListeners(this.client.getMaxListeners()+1)),o??={},o.registeredAt=Date.now(),Reflect.set(t,"options",o),this.subscribers.get(e).add(t),()=>{this.unsubscribe(e,t)}}unsubscribe(e,t,o){var a,s;let r=this.subscribers.get(e);r&&(r.delete(t),r.size<1&&(this.subscribers.delete(e),this.client.removeListener(e,this.globalHandlers.get(e)),this.globalHandlers.delete(e),this.client.setMaxListeners(Math.max(this.client.getMaxListeners()-1,0))),(s=(a=Reflect.get(t,"options")).onEnd)==null||s.call(a,o??"unsubscribe"))}createGlobalHandler(e){if(this.globalHandlers.has(e))return this.globalHandlers.get(e);let t=i(async(...o)=>{let r=this.subscribers.get(e);if(r&&r.size>0)for(let a of r){let s=Reflect.get(a,"options");if(s.time&&Date.now()-s.registeredAt>s.time){this.unsubscribe(e,a,"time");continue}if(s.autoReset&&(s.registeredAt=Date.now()),!(s.filter&&!await s.filter(...o)))try{await a(...o)}catch(u){if(s.onError)await s.onError(u);else throw u}finally{s.once&&this.unsubscribe(e,a,"once")}}},"handler");return this.globalHandlers.set(e,t),t}};Yt=new WeakSet,Yr=i(function(){this.cleanupTimer&&clearInterval(this.cleanupTimer),this.cleanupTimer=setInterval(()=>{for(let[e,t]of this.subscribers)for(let o of t){let r=Reflect.get(o,"options");r.time&&Date.now()-r.registeredAt>r.time&&this.unsubscribe(e,o,"time")}},6e4).unref()},"#cleanupLoop"),i(oo,"EventInterceptor");xt=oo});var io=g(()=>{"use strict";l();pr();Bn();xr();$n();Er();jn();_n();qn();Yn();Zn();Br();Or();Vr();Jr();zr();ro()});var ys,W,xs,bs,Y,ve=g(()=>{"use strict";l();ys=Symbol("kCommandKitCacheTag"),W=process.env.COMMANDKIT_IS_DEV==="true",xs=process.env.COMMANDKIT_IS_TEST==="true",bs=process.env.COMMANDKIT_BOOTSTRAP_MODE||"development",Y={ReloadCommands:"reload-commands",ReloadEvents:"reload-events",Unknown:"unknown"}});function Xt(n){return n instanceof We}var Xr,ao,We,so=g(()=>{"use strict";l();Xr=require("crypto"),ao=class ao{constructor(e){this.options=e}id=(0,Xr.randomUUID)();loadedAt=Date.now();async activate(e){}async deactivate(e){}};i(ao,"PluginCommon");We=ao;i(Xt,"isPlugin")});function bt(n){return Xt(n)&&n.type==="compiler"}var lo,pe,Qr=g(()=>{"use strict";l();so();lo=class lo extends We{type="compiler";async transform(e){return null}async resolve(e){return null}async onBuildStart(){}async onBuildEnd(){}};i(lo,"CompilerPlugin");pe=lo;i(bt,"isCompilerPlugin")});function mo(n){return Xt(n)&&n.type==="runtime"}var uo,co,Zr=g(()=>{"use strict";l();so();uo=class uo extends We{type="runtime";async onBeforeCommandsLoad(e){}async onAfterCommandsLoad(e){}async onBeforeEventsLoad(e){}async onAfterEventsLoad(e){}async onBeforeClientLogin(e){}async onAfterClientLogin(e){}async onBeforeInteraction(e,t){}async onBeforeMessageCommand(e,t){}async executeCommand(e,t,o,r,a){return!1}async onEventsRouterInit(e){}async onCommandsRouterInit(e){}async performHMR(e,t){}async prepareCommand(e,t){return null}async onBeforeRegisterCommands(e,t){}async onBeforeRegisterGlobalCommands(e,t){}async onBeforePrepareGuildCommandsRegistration(e,t){}async onBeforeRegisterGuildCommands(e,t){}async onAfterCommand(e,t){}async willEmitEvent(e,t){}};i(uo,"RuntimePlugin");co=uo;i(mo,"isRuntimePlugin")});var ei=g(()=>{"use strict";l()});var Es,ws,Ms,Qt,po,vt,fo=g(()=>{"use strict";l();_();ye();Es={autocomplete:"Autocomplete",messageContextMenu:"MessageContextMenu",userContextMenu:"UserContextMenu",chatInput:"ChatInputCommand",message:"Message"},ws={0:C.blue,1:C.green,2:C.yellow,3:C.red,4:C.white},Ms={0:C.bgBlue,1:C.bgGreen,2:C.bgYellow,3:C.bgRed,4:C.bgWhite},Qt={vertical:"\u2502",horizontalDown:"\u252C",horizontalUp:"\u2534",verticalRight:"\u251C",corner:"\u2514"},po=class po{constructor(e=process.stdout,t=process.stderr){this.stdout=e;this.stderr=t;this.logger=new console.Console(this.stdout,this.stderr)}logger;_formatTime(e){let t=e.getHours().toString().padStart(2,"0"),o=e.getMinutes().toString().padStart(2,"0"),r=e.getSeconds().toString().padStart(2,"0"),a=e.getMilliseconds().toString().padStart(3,"0");return`${t}:${o}:${r}.${a}`}_getContext(){let e=R();if(!e)return"";let t=e.variables.get("execHandlerKind"),o=e.variables.get("commandHandlerType"),r=e.variables.get("currentCommandName");if(!t&&!o)return"";let a=Es[t];if(!a&&!o)return"";let s=e.variables.get("forwardedBy"),m=e.variables.get("forwardedTo"),u=r?C.magenta(`/${r}`)+" ":"",d=m?`${C.yellowBright(`(${s||r} \u2192 ${m})`)} `:"";return C.dim(`${Qt.vertical} `)+C.cyanBright(`${u}${d}${a?C.gray(`[${a}]`):""}`.trim())}_getLevelLabel(e){let t;switch(e){case 0:t="[DEBUG]";break;case 1:t="[INFO]";break;case 2:t="[WARN]";break;case 3:t="[ERROR]";break;default:t="[LOG]"}return`${Ms[e](C.whiteBright(` ${t} `))} `}_getPrefix(e){let t=this._formatTime(new Date);return`${this._getLevelLabel(e)}${C.dim(Qt.vertical)} ${C.dim(t)}`}_log(e,...t){let o=this._getPrefix(e),r=this._getContext(),a=ws[e];r?this.logger.log(`${o}
2
- ${r} ${C.dim(Qt.corner)}`,...t.map(s=>a(s))):this.logger.log(`${o} ${C.dim(Qt.corner)}`,...t.map(s=>a(s)))}debug(...e){this._log(0,...e)}error(...e){this._log(3,...e)}log(...e){this._log(4,...e)}info(...e){this._log(1,...e)}warn(...e){this._log(2,...e)}};i(po,"DefaultLogger");vt=po});function ti(n){let e=n;if(!(e!=null&&e.provider))throw new Error("A logger provider must be provided.");let t=["log","error","warn","info","debug"],o={configure(r){e=r}};for(let r of t)o[r]=(...a)=>{e.provider[r](...a)};return o}var M,fe=g(()=>{"use strict";l();fo();i(ti,"createLogger");M=ti({provider:new vt})});var ni,ho,Et,go=g(()=>{"use strict";l();ni=require("discord.js");ke();fe();ho=class ho{constructor(e){this.commandkit=e}plugins=new ni.Collection;getPlugins(){return this.plugins}getPlugin(e){return this.plugins.get(e)??null}async softRegisterPlugin(e){let t=e.name;if(!this.plugins.has(t))try{await e.activate(this),this.plugins.set(t,e)}catch(o){throw new Error(`Failed to activate plugin "${t}": ${(o==null?void 0:o.stack)||o}`)}}async registerPlugin(e){let t=e.name;if(this.plugins.has(t))throw new Error(`Plugin with name "${t}" already exists.`);try{await e.activate(this),this.plugins.set(t,e)}catch(o){throw new Error(`Failed to activate plugin "${t}": ${(o==null?void 0:o.stack)||o}`)}}async unregisterPlugin(e){let t=e.name;if(!this.plugins.has(t))throw new Error(`Plugin with name "${t}" does not exist.`);this.plugins.delete(t);try{await e.deactivate(this)}catch(o){throw new Error(`Failed to deactivate plugin "${t}": ${(o==null?void 0:o.stack)||o}`)}}async unregisterAllPlugins(){for(let e of this.plugins.values())await this.unregisterPlugin(e)}capture(){throw Ke(k.PluginCaptureHandle)}async execute(e){let t;for(let o of this.plugins.values())try{t=await e(this,o)}catch(r){if(Z(r,k.PluginCaptureHandle))return!0;M.error(`Plugin "${o.name}" failed`,(r==null?void 0:r.stack)||r)}return t}};i(ho,"CommandKitPluginRuntime");Et=ho});function Co(n){let t=class t extends pe{name=n.name;onBuildEnd(){var r;return(r=n.onBuildEnd)==null?void 0:r.call(n)}onBuildStart(){var r;return(r=n.onBuildStart)==null?void 0:r.call(n)}async transform(r){var a;return(a=n.transform)==null?void 0:a.call(n,r)}async resolve(r){var a;return(a=n.resolve)==null?void 0:a.call(n,r)}};i(t,"EsbuildPluginCompat");let e=t;return e}var ri,oi,yo,wt,ii=g(()=>{"use strict";l();ri=require("fs/promises");he();oi=/\.(c|m)?(t|j)sx?$/,yo=class yo{constructor(e){this.plugins=e}name="CompilerPluginRuntime";getPlugins(){return this.plugins}isEmpty(){return!this.plugins.length}async onLoad(e){var a,s;let o=await(0,ri.readFile)(e.path,"utf8"),r=(a=e.path)==null?void 0:a.split(".").pop();for(let m of this.plugins)try{let u=await((s=m.transform)==null?void 0:s.call(m,{contents:o,path:e.path,loader:r,args:e}));if(!u)continue;u.contents&&(o=u.contents),u.loader&&(r=u.loader)}catch(u){let d=u instanceof Error?u:new Error(u);return{pluginName:m.name,errors:[{text:d.message,detail:(d==null?void 0:d.stack)??d,location:null}]}}return{contents:o,loader:r}}async onResolve(e){var o;let t={};for(let r of this.plugins)try{let a=await((o=r.resolve)==null?void 0:o.call(r,e));if(!a)continue;t={...t,...a}}catch(a){let s=a instanceof Error?a:new Error(a);return{errors:[{text:s.message,detail:(s==null?void 0:s.stack)??s,location:null}]}}return t}async onStart(){var e;for(let t of this.plugins)try{await((e=t.onBuildStart)==null?void 0:e.call(t))}catch(o){console.error(`Plugin ${t.name} failed to run onBuildStart with ${(o==null?void 0:o.stack)||o}`)}}async onEnd(){var e;for(let t of this.plugins)try{await((e=t.onBuildEnd)==null?void 0:e.call(t))}catch(o){console.error(`Plugin ${t.name} failed to run onBuildEnd with ${(o==null?void 0:o.stack)||o}`)}}async onDispose(){var e;for(let t of this.plugins)try{await((e=t.deactivate)==null?void 0:e.call(t,this))}catch(o){console.error(`Plugin ${t.name} failed to deactivate with ${(o==null?void 0:o.stack)||o}`)}}async onInit(){var e;for(let t of this.plugins)try{await((e=t.activate)==null?void 0:e.call(t,this))}catch(o){console.error(`Plugin ${t.name} failed to activate with ${(o==null?void 0:o.stack)||o}`)}}async cleanup(){await this.onEnd(),await this.onDispose()}async setup(e){this.plugins.length&&(await this.onInit(),await e.onResolve({filter:oi},this.onResolve.bind(this)),await e.onLoad({filter:oi},this.onLoad.bind(this)),await e.onStart(this.onStart.bind(this)),e.onEnd(async()=>{await this.onEnd()}),e.onDispose(async()=>{await this.onDispose()}))}toEsbuildPlugin(){return{name:this.name,setup:this.setup.bind(this)}}};i(yo,"CompilerPluginRuntime");wt=yo;i(Co,"fromEsbuildPlugin")});var ai=g(()=>{"use strict";l()});var si=g(()=>{"use strict";l()});var bo,xo,li=g(()=>{"use strict";l();he();bo=class bo extends pe{transformer=null;async activate(e){let{createDirectiveTransformer:t}=await import("directive-to-hof");this.transformer=t(this.options)}async deactivate(e){this.transformer=null}async transform(e){if(!this.options.enabled||!this.transformer)return null;let t=await this.transformer(e.contents.toString(),e.path);return{contents:t.contents,loader:t.loader}}};i(bo,"CommonDirectiveTransformer");xo=bo});var he=g(()=>{"use strict";l();Qr();Zr();ei();go();ii();ai();si();li()});var vo,Zt,ci=g(()=>{"use strict";l();he();vo=class vo extends pe{name="MacroPlugin";macroTransformer;async activate(){let e=await import("use-macro");this.macroTransformer=new e.MacroTransformer}async deactivate(){this.macroTransformer=null}async transform(e){if(!this.options.enabled)return null;let{contents:t,loader:o}=await this.macroTransformer.transform(e.contents.toString(),e.path);return{contents:t,loader:o}}};i(vo,"MacroPlugin");Zt=vo});var X,mi=g(()=>{"use strict";l();ci();X={plugins:[new Zt({enabled:!0})],esbuildPlugins:[],compilerOptions:{macro:{development:!1}},static:!0,typescript:{ignoreBuildErrors:!1},distDir:"dist",env:{},sourceMap:{development:!0,production:!0},typedCommands:!0}});function qe(){return Eo}function Ss(n={}){var e;return Eo={compilerOptions:{macro:{...X.compilerOptions.macro,...(e=n.compilerOptions)==null?void 0:e.macro}},distDir:n.distDir??X.distDir,env:{...X.env,...n.env},esbuildPlugins:[...n.esbuildPlugins??[],...X.esbuildPlugins??[]],plugins:[...n.plugins??[],...X.plugins??[]].flat(1/0),sourceMap:{...X.sourceMap,...n.sourceMap},static:n.static??X.static,typedCommands:n.typedCommands??X.typedCommands,typescript:{...X.typescript,...n.typescript}},Eo}var Eo,en=g(()=>{"use strict";l();mi();Eo=X;i(qe,"getConfig");i(Ss,"defineConfig")});function tn(n,e){return Reflect.set(n,di,!0),Je.run(n,e)}function Is(){let n=Je.getStore();if(!n)throw new Error("Event worker context not found");return n}function Ps(n){return n&&Reflect.get(n,di)===!0}var ui,di,Je,Mt=g(()=>{"use strict";l();ui=require("async_hooks"),di=Symbol("commandkitEventWorker"),Je=new ui.AsyncLocalStorage;i(tn,"runInEventWorkerContext");i(Is,"getEventWorkerContext");i(Ps,"isEventWorkerContext")});function pi(){if(Mo)return Mo;let n=(0,St.join)(process.cwd(),W?".commandkit":qe().distDir);return(0,nn.existsSync)(n)||(n=process.cwd()),Mo=n,n}function fi(){return["src",".commandkit",qe().distDir].map(t=>(0,St.join)(process.cwd(),t))}function hi(){if(wo)return wo;let n=(0,St.join)(process.cwd(),W?".commandkit":qe().distDir);(0,nn.existsSync)(n)||(n=process.cwd());let e=["app"].map(t=>(0,St.join)(n,t));for(let t of e)if((0,nn.existsSync)(t))return wo=t,t;return null}function on(n,e){let t=null,o=null;return(...r)=>(t&&(clearTimeout(t),o&&o(null)),new Promise(a=>{o=a,t=setTimeout(()=>{let s=n(...r);a(s),t=null,o=null},e)}))}function gi(n){return i((...t)=>{if(W)return n(...t)},"f")}function Ci(){throw Je.getStore()?new Ee:new Error("stopEvents() may only be called inside an event handler")}var nn,St,wo,Mo,So,Ee,It=g(()=>{"use strict";l();nn=require("fs"),St=require("path");ve();en();Mt();wo=null,Mo=null;i(pi,"getCurrentDirectory");i(fi,"getSourceDirectories");i(hi,"findAppDirectory");i(on,"debounce");i(gi,"devOnly");So=class So extends Error{constructor(){super("Event propagation stopped"),this.name="StopEventPropagationError"}};i(So,"StopEventPropagationError");Ee=So;i(Ci,"stopEvents")});function Pt(n,e=!1){return`${"file://"+yi.default.resolve(n).replace(/\\\\|\\/g,"/")}${e?`?ts=${Date.now()}`:""}`}var yi,Io=g(()=>{"use strict";l();yi=q(require("path"));i(Pt,"toFileURL")});var G,ze,et,Dt,Po,Rt,Ro,rn,Do=g(()=>{"use strict";l();G=require("discord.js");ke();Po=class Po{constructor(e,t,o){this.message=e;this.prefix=t;this.schema=o;x(this,ze,null);x(this,et,null);x(this,Dt,[])}getArgs(){return this.parse(),c(this,Dt)}get options(){return c(this,et)||h(this,et,new rn(this)),c(this,et)}getOption(e){var t;return(t=this.parse().options.find(o=>o.name===e))==null?void 0:t.value}getCommand(){return this.parse().command}getSubcommand(){return this.parse().subcommand}getSubcommandGroup(){return this.parse().subcommandGroup}getPrefix(){for(let e of this.prefix)if(this.message.content.startsWith(e))return e}getFullCommand(){return[this.getCommand(),this.getSubcommandGroup(),this.getSubcommand()].filter(e=>e).join(" ")}parse(){if(c(this,ze))return c(this,ze);let e=this.message.content,t=this.getPrefix();if(!t)throw Ke(k.InvalidCommandPrefix);let o=e.slice(t.length).trim().split(" "),r=o.shift();h(this,Dt,o);let a,s;if(r!=null&&r.includes(":")){let[,d,p]=r.split(":");!p&&d?s=d:p&&d&&(a=d,s=p)}let m=this.schema([r,a,s].filter(Boolean).join(" ").trim()),u=o.map(d=>{try{let[p,b]=d.split(":");if(!(p in m))return null;switch(m[p]){case G.ApplicationCommandOptionType.Boolean:return{name:p,value:b==="true"};case G.ApplicationCommandOptionType.Integer:return{name:p,value:parseInt(b,10)};case G.ApplicationCommandOptionType.Number:return{name:p,value:parseFloat(b)};case G.ApplicationCommandOptionType.String:return{name:p,value:b};case G.ApplicationCommandOptionType.User:return{name:p,value:this.message.mentions.users.find(y=>y.id===b.replace(/[<@!>]/g,""))};case G.ApplicationCommandOptionType.Channel:return{name:p,value:this.message.mentions.channels.find(y=>y.id===b.replace(/[<#>]/g,""))};case G.ApplicationCommandOptionType.Role:return{name:p,value:this.message.mentions.roles.find(y=>y.id===b.replace(/[<@&>]/g,""))};case G.ApplicationCommandOptionType.Attachment:return{name:p,value:this.message.attachments.find(y=>y.name===b)};default:return null}}catch{return null}}).filter(d=>d!==null);return h(this,ze,{command:r,options:u,subcommand:s,subcommandGroup:a}),c(this,ze)}};ze=new WeakMap,et=new WeakMap,Dt=new WeakMap,i(Po,"MessageCommandParser");Rt=Po,Ro=class Ro{constructor(e){this.parser=e}assertOption(e,t=!1){let o=this.parser.getOption(e);if(t&&o===void 0)throw new Error(`Option "${e}" is required.`);return o??null}getMember(e,t=!1){var a;let o=this.assertOption(e,t),r=(a=this.parser.message.guild)==null?void 0:a.members.cache.get(o==null?void 0:o.id);if(t&&!r)throw new Error(`Member "${e}" is required.`);return r??null}getAttachment(e,t=!1){return this.assertOption(e,t)}getBoolean(e,t=!1){return this.assertOption(e,t)}getNumber(e,t=!1){return this.assertOption(e,t)}getString(e,t=!1){return this.assertOption(e,t)}getInteger(e,t=!1){return this.assertOption(e,t)}getUser(e,t=!1){return this.assertOption(e,t)}getChannel(e,t=!1){return this.assertOption(e,t)}getRole(e,t=!1){return this.assertOption(e,t)}getMentionable(e,t=!1){let o=this.assertOption(e,t);if(o instanceof G.GuildMember||o instanceof G.User||o instanceof G.Role)return o;if(t)throw new Error(`Mentionable "${e}" is required.`);return null}getSubcommand(e=!1){let t=this.parser.getSubcommand();if(e&&t===void 0)throw new Error("Subcommand is required.");return t??null}getSubcommandGroup(e=!1){let t=this.parser.getSubcommandGroup();if(e&&t===void 0)throw new Error("Subcommand group is required.");return t??null}};i(Ro,"MessageCommandOptions");rn=Ro});var ee,Ko,Kt,ko=g(()=>{"use strict";l();ee=require("discord.js");fe();Ko=class Ko{constructor(e){this.commandkit=e;this.api.setToken(this.commandkit.client.token??process.env.DISCORD_TOKEN??process.env.TOKEN??"")}api=new ee.REST;getCommandsData(){return this.commandkit.commandHandler.getCommandsArray().flatMap(o=>{let r="toJSON"in o.data.command?o.data.command.toJSON():o.data.command,a=[r];return o.data.userContextMenu&&r.type!==ee.ApplicationCommandType.User&&a.push({...r,type:ee.ApplicationCommandType.User,options:void 0,description_localizations:void 0,description:void 0}),o.data.messageContextMenu&&r.type!==ee.ApplicationCommandType.Message&&a.push({...r,type:ee.ApplicationCommandType.Message,description_localizations:void 0,description:void 0,options:void 0}),a})}async register(){let e=this.getCommandsData(),t=!1,o={preventDefault(){t=!0},commands:e};if(await this.commandkit.plugins.execute(async(s,m)=>{if(!t)return m.onBeforeRegisterCommands(s,o)}),t)return;if(!this.commandkit.client.isReady())throw new Error("Cannot register commands before the client is ready");let r=e.filter(s=>{var m;return(m=s.guilds)==null?void 0:m.filter(Boolean).length}).map(s=>{var m;return{...s,guilds:Array.from(new Set((m=s.guilds)==null?void 0:m.filter(Boolean)))}}),a=e.filter(s=>{var m;return!((m=s.guilds)!=null&&m.filter(Boolean).length)});await this.updateGlobalCommands(a),await this.updateGuildCommands(r)}async updateGlobalCommands(e){if(!e.length)return;let t=!1,o={preventDefault(){t=!0},commands:e};await this.commandkit.plugins.execute(async(r,a)=>{if(!t)return a.onBeforeRegisterGlobalCommands(r,o)});try{let r=await this.api.put(ee.Routes.applicationCommands(this.commandkit.client.user.id),{body:e.map(a=>({...a,guilds:void 0}))});M.info(`\u2728 Refreshed ${r.length} global application (/) commands`)}catch(r){M.error("Failed to update global application (/) commands",r)}}async updateGuildCommands(e){if(!e.length)return;let t=!1,o={preventDefault(){t=!0},commands:e};if(await this.commandkit.plugins.execute(async(r,a)=>{if(!t)return a.onBeforePrepareGuildCommandsRegistration(r,o)}),!t)try{let r=new Map;if(e.forEach(s=>{var m;(m=s.guilds)!=null&&m.length&&s.guilds.forEach(u=>{r.has(u)||r.set(u,[]),r.get(u).push(s)})}),!r.size)return;let a=0;for(let[s,m]of r){let u=!1,d={preventDefault(){u=!0},commands:m};if(await this.commandkit.plugins.execute(async(b,y)=>{if(!u)return y.onBeforeRegisterGuildCommands(b,d)}),u)continue;let p=await this.api.put(ee.Routes.applicationGuildCommands(this.commandkit.client.user.id,s),{body:m.map(b=>({...b,guilds:void 0}))});a+=p.length}M.info(`\u2728 Refreshed ${a} guild application (/) commands`)}catch(r){M.error("Failed to update guild application (/) commands",r)}}};i(Ko,"CommandRegistrar");Kt=Ko});function Rs(n){let e=R();if(!e)throw new Error("after must be called inside commandkit handler.");return e.registerDeferredFunction(n)}function Ds(n){let e=R();if(!e)throw new Error("cancelAfter must be called inside commandkit handler.");e.clearDeferredFunction(n)}var xi,D,Ao,kt,To,Bo=g(()=>{"use strict";l();xi=require("crypto");_();Ao=class Ao{constructor(e){this.commandkit=e;x(this,D,{executionError:null,type:null,variables:new Map,deferredFunctions:new Map,marker:"",markStart:0,markEnd:0,context:null})}setContext(e){c(this,D).context=e}get context(){return c(this,D).context}getExecutionError(){return c(this,D).executionError}setExecutionError(e){if(c(this,D).executionError)throw new Error("Execution error already set.");c(this,D).executionError=e}getType(){let e=c(this,D).type;if(!e)throw new Error("Environment type not set.");return e}setType(e){c(this,D).type=e}get variables(){return c(this,D).variables}registerDeferredFunction(e){let t=(0,xi.randomUUID)();return c(this,D).deferredFunctions.set(t,e),t}clearDeferredFunction(e){c(this,D).deferredFunctions.delete(e)}async runDeferredFunctions(){for(let[e,t]of c(this,D).deferredFunctions)try{await t(this)}catch(o){this.commandkit.emit("unhandledDeferredFunctionRejection",o)}finally{this.clearDeferredFunction(e)}}clearAllDeferredFunctions(){c(this,D).deferredFunctions.clear()}markStart(e){c(this,D).marker=e,c(this,D).markStart=performance.now()}markEnd(){c(this,D).markEnd||(c(this,D).markEnd=performance.now())}getMarker(){return c(this,D).marker}getExecutionTime(){return Math.abs(c(this,D).markEnd-c(this,D).markStart)}};D=new WeakMap,i(Ao,"CommandKitEnvironment");kt=Ao,To=(e=>(e.CommandHandler="COMMAND_HANDLER",e))(To||{});i(Rs,"after");i(Ds,"cancelAfter")});function Oo(){throw Ke(k.ExitMiddleware)}function Ks(n){if(lt(n))throw n}function Lo(){throw Ke(k.ForwardedCommand)}var $o=g(()=>{"use strict";l();ke();i(Oo,"exitMiddleware");i(Ks,"rethrow");i(Lo,"redirect")});var j,tt,Tt,an,At,Fo,nt,No=g(()=>{"use strict";l();_();$o();j={ChatInputCommand:"chatInput",MessageContextMenu:"messageContextMenu",UserContextMenu:"userContextMenu",Autocomplete:"autocomplete",Message:"message"},Tt=class Tt{constructor(e,t){this.commandkit=e;this.config=t;I(this,"interaction");I(this,"message");I(this,"guild");I(this,"guildId");I(this,"channel");I(this,"channelId");I(this,"client");I(this,"command");x(this,tt);I(this,"_locale",null);this.interaction=t.interaction,this.message=t.message,this.client=e.client,h(this,tt,t.store??new Map),this.command=t.command,t.interaction&&(this.guild=t.interaction.guild,this.guildId=t.interaction.guildId,this.channel=t.interaction.channel,this.channelId=t.interaction.channelId),t.message&&(this.guild=t.message.guild,this.guildId=t.message.guildId,this.channel=t.message.channel,this.channelId=t.message.channelId),this.config.environment&&this.config.environment.setContext(this)}get store(){return c(this,tt)}get commandName(){return this.isInteraction()?this.interaction.commandName:this.config.messageCommandParser.getCommand()}get options(){return this.isMessage()?this.config.messageCommandParser.options:this.interaction.options}get forwarded(){return this.config.forwarded??!1}async forwardCommand(e){let t=await this.commandkit.commandHandler.prepareCommandRun(this.isInteraction()?this.interaction:this.message,e);if(!t)throw new Error(`Command ${e} not found`);let o=this.config.environment??R();if(!o)throw new Error("No commandkit environment found.");let r={chatInput:t.command.data.chatInput,autocomplete:t.command.data.autocomplete,message:t.command.data.message,messageContextMenu:t.command.data.messageContextMenu,userContextMenu:t.command.data.userContextMenu},a=o.variables.get("execHandlerKind");if(!a)throw new Error("No execution handler kind found.");let s=r[a];if(!s)throw new Error(`No handler found for ${a}`);o.variables.set("forwardedBy",this.commandName),o.variables.set("forwardedTo",e),await s(this.clone({forwarded:!0})),Lo()}get executionMode(){return this.config.executionMode}isInteraction(){return this.executionMode===j.ChatInputCommand||this.executionMode===j.Autocomplete||this.executionMode===j.MessageContextMenu||this.executionMode===j.UserContextMenu}isChatInputCommand(){return this.executionMode===j.ChatInputCommand}isAutocomplete(){return this.executionMode===j.Autocomplete}isMessageContextMenu(){return this.executionMode===j.MessageContextMenu}isUserContextMenu(){return this.executionMode===j.UserContextMenu}isMessage(){return this.executionMode===j.Message}getCommandIdentifier(){return this.isInteraction()?this.interaction.commandName:this.message.content.split(" ")[0].slice(1)}getGuildLocale(){var e;return this.isInteraction()?this.interaction.guildLocale:((e=this.message.guild)==null?void 0:e.preferredLocale)??null}getUserLocale(){return this.isInteraction()?this.interaction.locale:null}getLocale(e=!1){if(this._locale)return this._locale;let t=e?this.getUserLocale():this.getGuildLocale();return t||this.commandkit.config.defaultLocale}setLocale(e){this._locale=e}clone(e){return e?new Tt(this.commandkit,{...this.config,...e,store:c(this,tt)}):new Tt(this.commandkit,this.config)}isMiddleware(){return this instanceof nt}args(){return this.isMessage()?this.config.messageCommandParser.getArgs():[]}exit(){Oo()}};tt=new WeakMap,i(Tt,"Context");an=Tt,Fo=class Fo extends an{constructor(){super(...arguments);x(this,At,!1)}get cancelled(){return c(this,At)}cancel(){h(this,At,!0)}setCommandRunner(t){var o,r;(r=(o=this.config.customArgs)==null?void 0:o.setCommandRunner)==null||r.call(o,t)}};At=new WeakMap,i(Fo,"MiddlewareContext");nt=Fo});var sn,cn,bi,Uo,ln,vi=g(()=>{"use strict";l();sn=require("discord.js");Bo();fe();No();_();ke();Uo=class Uo{constructor(e){this.handler=e;x(this,cn)}async runCommand(e,t){let{commandkit:o}=this.handler,r=this.getExecutionMode(t),a=null,s=new kt(o);s.setType("COMMAND_HANDLER"),s.variables.set("commandHandlerType","app"),s.variables.set("currentCommandName",e.command.command.name),s.variables.set("execHandlerKind",r);let m=new nt(o,{command:e.command,environment:s,executionMode:r,interaction:t instanceof sn.Message?null:t,message:t instanceof sn.Message?t:null,forwarded:!1,customArgs:{setCommandRunner:i(d=>{a=d},"setCommandRunner")},messageCommandParser:e.messageCommandParser}),u=!1;if(e.middlewares.length&&await mt(s,async()=>{for(let d of e.middlewares)if(d.data.beforeExecute)try{await d.data.beforeExecute(m)}catch(p){if(Z(p,k.ExitMiddleware)){u=!0;return}if(Z(p,[k.ForwardedCommand,k.InvalidCommandPrefix]))continue;throw p}}),!m.cancelled){let p=e.command.data[r];if(p||M.warn(`Command ${e.command.command.name} has no handler for ${r}`),p)try{let b=Kn(s,async()=>(s.registerDeferredFunction(S=>{S.markEnd();let P=S.getExecutionError(),w=S.getMarker(),K=`${S.getExecutionTime().toFixed(2)}ms`;if(P){M.error(`[${w} - ${K}] Error executing command: ${P.stack||P}`);return}M.info(`[${w} - ${K}] Command executed successfully`)}),p(m.clone())),v(this,cn,bi).bind(this)),y=a!=null?a(b):b;s.markStart(e.command.data.command.name),await o.plugins.execute(async(S,P)=>P.executeCommand(S,s,t,e,y))||await y()}catch(b){Z(b,k.ExitMiddleware)&&(u=!0),Z(b,[k.ForwardedCommand,k.ExitMiddleware])||M.error(b)}}!u&&e.middlewares.length&&await mt(s,async()=>{for(let d of e.middlewares)if(d.data.afterExecute)try{await d.data.afterExecute(m)}catch(p){if(Z(p,k.ExitMiddleware))return;throw p}})}getExecutionMode(e){return e instanceof sn.Message?j.Message:e.isChatInputCommand()?j.ChatInputCommand:e.isAutocomplete()?j.Autocomplete:e.isMessageContextMenuCommand()?j.MessageContextMenu:e.isUserContextMenuCommand()?j.UserContextMenu:null}};cn=new WeakSet,bi=i(async function(){let e=kn();await e.runDeferredFunctions(),e.clearAllDeferredFunctions(),await this.handler.commandkit.plugins.execute(async(t,o)=>{await o.onAfterCommand(t,e)})},"#finalizer"),i(Uo,"AppCommandRunner");ln=Uo});async function ot(n=!1){let e=(0,we.join)(process.cwd(),"node_modules","commandkit-types");if(!W&&!n)return e;let t=(0,we.join)(e,"package.json"),o=(0,we.join)(e,"index.js"),r=(0,we.join)(e,"index.d.ts"),a=(0,we.join)(e,"command.d.ts"),s={name:"commandkit-types",version:"1.0.0",description:"CommandKit types package",type:"commonjs",main:"index.js",types:"index.d.ts"},m="module.exports = {};",u=`// Main types index file - imports all type declarations
1
+ "use strict";var ja=Object.create;var Xe=Object.defineProperty;var Ha=Object.getOwnPropertyDescriptor;var Ga=Object.getOwnPropertyNames;var _a=Object.getPrototypeOf,Va=Object.prototype.hasOwnProperty;var cr=n=>{throw TypeError(n)};var Wa=(n,e,t)=>e in n?Xe(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var i=(n,e)=>Xe(n,"name",{value:e,configurable:!0});var g=(n,e)=>()=>(n&&(e=n(n=0)),e);var Qe=(n,e)=>{for(var t in e)Xe(n,t,{get:e[t],enumerable:!0})},mr=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Ga(e))!Va.call(n,r)&&r!==t&&Xe(n,r,{get:()=>e[r],enumerable:!(o=Ha(e,r))||o.enumerable});return n};var q=(n,e,t)=>(t=n!=null?ja(_a(n)):{},mr(e||!n||!n.__esModule?Xe(t,"default",{value:n,enumerable:!0}):t,n)),qa=n=>mr(Xe({},"__esModule",{value:!0}),n);var I=(n,e,t)=>Wa(n,typeof e!="symbol"?e+"":e,t),Dn=(n,e,t)=>e.has(n)||cr("Cannot "+t);var c=(n,e,t)=>(Dn(n,e,"read from private field"),t?t.call(n):e.get(n)),x=(n,e,t)=>e.has(n)?cr("Cannot add the same private member more than once"):e instanceof WeakSet?e.add(n):e.set(n,t),h=(n,e,t,o)=>(Dn(n,e,"write to private field"),o?o.call(n,t):e.set(n,t),t),v=(n,e,t)=>(Dn(n,e,"access private method"),t);var l=g(()=>{"use strict"});var ur,C,ye=g(()=>{"use strict";l();ur=require("picocolors"),C=(0,ur.createColors)(!0)});function Ja(n){let e=new dr.ActionRowBuilder;return Array.isArray(n.children)?e.setComponents(...n.children):n.children&&e.setComponents(n.children),e}var dr,pr=g(()=>{"use strict";l();dr=require("discord.js");i(Ja,"ActionRow")});function Ke(n){let e=new Error;return Reflect.set(e,"code",n),e}function lt(n){if(!(n instanceof Error))return!1;let e=Reflect.get(n,"code");for(let t in k)if(k[t]===e)return!0;return!1}function ee(n,e){if(!lt(n))return!1;let t=Reflect.get(n,"code");return t?Array.isArray(e)?e.includes(t):t===e:!1}var k,ke=g(()=>{"use strict";l();k={ExitMiddleware:Symbol("kExitMiddleware"),ForwardedCommand:Symbol("kForwardedCommand"),InvalidCommandPrefix:Symbol("kInvalidCommandPrefix"),PluginCaptureHandle:Symbol("kPluginCaptureHandle")};i(Ke,"createCommandKitError");i(lt,"isCommandKitError");i(ee,"isErrorType")});function za(n){return n&&Reflect.get(n,hr)===!0}function H(n){return ct.exit(n)}function mt(n,e){return Reflect.set(n,hr,!0),ct.run(n,e)}function Kn(n,e,t){return i((...r)=>mt(n,async()=>{try{return await e(...r)}catch(a){lt(a)||n.setExecutionError(a)}finally{typeof t=="function"&&setImmediate(async()=>{try{await t(...r)}catch{}})}}),"_fn")}function U(n=!1){var t;let e=((t=ct.getStore())==null?void 0:t.commandkit)??Te.instance;if(!e&&n)throw new Error("CommandKit instance not found.");return e}function R(){return ct.getStore()}function kn(){let n=ct.getStore();if(!n)throw new Error("No commandkit environment found. Please make sure you are inside commandkit handler.");return n}var fr,hr,ct,_=g(()=>{"use strict";l();fr=require("async_hooks");jt();ke();hr=Symbol("commandkitCommandWorker"),ct=new fr.AsyncLocalStorage;i(za,"isCommandWorkerContext");i(H,"exitContext");i(mt,"provideContext");i(Kn,"makeContextAwareFunction");i(U,"getCommandKit");i(R,"getContext");i(kn,"useEnvironment")});var be,xe,T,Ae,re,gr,Cr,Tn,An,ut,Bn=g(()=>{"use strict";l();be=require("discord.js");_();An=class An extends be.ButtonBuilder{constructor(){super(...arguments);x(this,re);x(this,xe,null);x(this,T,{autoReset:!0,time:5*60*1e3,once:!1});x(this,Ae,null)}onClick(t,o){var r,a,s,m;if(this.data.style===be.ButtonStyle.Link)throw new TypeError('Cannot setup "onClick" handler on link buttons.');if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,xe)&&v(this,re,Tn).call(this),h(this,xe,t),o&&h(this,T,{autoReset:o.autoReset??((r=c(this,T))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,T))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,T))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,T))==null?void 0:m.onEnd)}),v(this,re,Cr).call(this),this}onEnd(t){if(this.data.style===be.ButtonStyle.Link)throw new TypeError('Cannot setup "onEnd" handler on link buttons.');if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,T)??h(this,T,{}),c(this,T).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,T)??h(this,T,{}),c(this,T).onError=t,this}filter(t){return c(this,T)??h(this,T,{autoReset:!0,time:5*60*1e3}),c(this,T).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,re,Tn).call(this),this}};xe=new WeakMap,T=new WeakMap,Ae=new WeakMap,re=new WeakSet,gr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Cr=i(function(){if(this.data.style===be.ButtonStyle.Link||!c(this,T)||!c(this,xe))return;if((this.customId??null)===null)throw new TypeError('Cannot setup "onClick" handler on a button without a custom id.');let o=v(this,re,gr).call(this);h(this,Ae,o.subscribe(be.Events.InteractionCreate,async r=>{var d,p;if(!r.isButton())return;let a=this.customId??null,s=r.customId;if(a&&s!==a)return;let m=(d=c(this,T))==null?void 0:d.filter;if(m&&!await m(r))return;let u=c(this,xe);return u?u(r,this):(p=c(this,Ae))==null?void 0:p.call(this)},c(this,T)))},"#setupInteractionCollector"),Tn=i(function(){var t;(t=c(this,Ae))==null||t.call(this),h(this,Ae,null),h(this,T,null),h(this,xe,null)},"#destroyCollector"),i(An,"ButtonKit");ut=An});function Ya(n){let e=new ut;n.style??=yr.ButtonStyle.Primary,n.onClick&&(n.customId??=`buttonkit::${crypto.randomUUID()}`),n.customId&&e.setCustomId(n.customId),n.onClick&&e.onClick(n.onClick,n.options),n.disabled&&e.setDisabled(n.disabled),n.emoji&&e.setEmoji(n.emoji),n.skuId&&e.setSKUId(n.skuId),n.url&&e.setURL(n.url),n.style&&e.setStyle(n.style);let t=n.label||n.children;return t&&e.setLabel(Array.isArray(t)?t.join(" "):typeof t=="string"?t:String(t)),n.onEnd&&e.onEnd(n.onEnd),n.onError&&e.onError(n.onError),e}var yr,xr=g(()=>{"use strict";l();yr=require("discord.js");Bn();i(Ya,"Button")});var Ht,Be,A,Oe,ie,br,vr,On,Ln,dt,$n=g(()=>{"use strict";l();Ht=require("discord.js");_();Ln=class Ln extends Ht.ModalBuilder{constructor(){super(...arguments);x(this,ie);x(this,Be,null);x(this,A,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Oe,null)}onSubmit(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Be)&&v(this,ie,On).call(this),h(this,Be,t),o&&h(this,A,{autoReset:o.autoReset??((r=c(this,A))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,A))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,A))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,A))==null?void 0:m.onEnd)}),v(this,ie,vr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,A)??h(this,A,{}),c(this,A).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,A)??h(this,A,{}),c(this,A).onError=t,this}filter(t){return c(this,A)??h(this,A,{autoReset:!0,time:5*60*1e3}),c(this,A).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,ie,On).call(this),this}};Be=new WeakMap,A=new WeakMap,Oe=new WeakMap,ie=new WeakSet,br=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),vr=i(function(){if(!c(this,A))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,ie,br).call(this);t&&h(this,Oe,t.subscribe(Ht.Events.InteractionCreate,async o=>{var u,d;if(!o.isModalSubmit())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,A))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Be);return m?m(o,this):(d=c(this,Oe))==null?void 0:d.call(this)},c(this,A)))},"#setupCollector"),On=i(function(){var t;(t=c(this,Oe))==null||t.call(this),h(this,Oe,null),h(this,Be,null),h(this,A,null)},"#destroyCollector"),i(Ln,"ModalKit");dt=Ln});function Xa(n){let e=new dt;if(n.title&&e.setTitle(n.title),n.onSubmit&&(n.customId??=`modalkit::${crypto.randomUUID()}`),n.customId&&e.setCustomId(n.customId),n.onSubmit&&e.onSubmit(n.onSubmit,n.options),n.children){let t=(Array.isArray(n.children)?n.children:[n.children]).map(o=>{if(o instanceof ae.ActionRowBuilder)return o;if(o instanceof ae.TextInputBuilder)return new ae.ActionRowBuilder().addComponents(o)}).filter(o=>o!=null);e.addComponents(t)}return n.onEnd&&e.onEnd(n.onEnd),n.onError&&e.onError(n.onError),e}function Fn(n){let e=new ae.TextInputBuilder().setStyle(n.style);return n.customId&&e.setCustomId(n.customId),n.label&&e.setLabel(n.label),n.placeholder&&e.setPlaceholder(n.placeholder),n.maxLength&&e.setMaxLength(n.maxLength),n.minLength&&e.setMinLength(n.minLength),n.value&&e.setValue(n.value),n.required&&e.setRequired(n.required),e}function Qa(n){return Fn({...n,style:ae.TextInputStyle.Short})}function Za(n){return Fn({...n,style:ae.TextInputStyle.Paragraph})}var ae,Er=g(()=>{"use strict";l();ae=require("discord.js");$n();i(Xa,"Modal");i(Fn,"TextInput");i(Qa,"ShortInput");i(Za,"ParagraphInput")});var Gt,Le,B,$e,se,wr,Mr,Nn,Un,pt,jn=g(()=>{"use strict";l();Gt=require("discord.js");_();Un=class Un extends Gt.StringSelectMenuBuilder{constructor(){super(...arguments);x(this,se);x(this,Le,null);x(this,B,{autoReset:!1,time:5*60*1e3,once:!0});x(this,$e,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Le)&&v(this,se,Nn).call(this),h(this,Le,t),o&&h(this,B,{autoReset:o.autoReset??((r=c(this,B))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,B))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,B))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,B))==null?void 0:m.onEnd)}),v(this,se,Mr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,B)??h(this,B,{}),c(this,B).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,B)??h(this,B,{}),c(this,B).onError=t,this}filter(t){return c(this,B)??h(this,B,{autoReset:!0,time:5*60*1e3}),c(this,B).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,se,Nn).call(this),this}};Le=new WeakMap,B=new WeakMap,$e=new WeakMap,se=new WeakSet,wr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Mr=i(function(){if(!c(this,B))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,se,wr).call(this);t&&h(this,$e,t.subscribe(Gt.Events.InteractionCreate,async o=>{var u,d;if(!o.isStringSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,B))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Le);return m?m(o,this):(d=c(this,$e))==null?void 0:d.call(this)},c(this,B)))},"#setupCollector"),Nn=i(function(){var t;(t=c(this,$e))==null||t.call(this),h(this,$e,null),h(this,Le,null),h(this,B,null)},"#destroyCollector"),i(Un,"StringSelectMenuKit");pt=Un});var _t,Fe,O,Ne,le,Sr,Ir,Hn,Gn,ft,_n=g(()=>{"use strict";l();_t=require("discord.js");_();Gn=class Gn extends _t.ChannelSelectMenuBuilder{constructor(){super(...arguments);x(this,le);x(this,Fe,null);x(this,O,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Ne,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Fe)&&v(this,le,Hn).call(this),h(this,Fe,t),o&&h(this,O,{autoReset:o.autoReset??((r=c(this,O))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,O))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,O))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,O))==null?void 0:m.onEnd)}),v(this,le,Ir).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,O)??h(this,O,{}),c(this,O).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,O)??h(this,O,{}),c(this,O).onError=t,this}filter(t){return c(this,O)??h(this,O,{autoReset:!0,time:5*60*1e3}),c(this,O).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,le,Hn).call(this),this}};Fe=new WeakMap,O=new WeakMap,Ne=new WeakMap,le=new WeakSet,Sr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Ir=i(function(){if(!c(this,O))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,le,Sr).call(this);t&&h(this,Ne,t.subscribe(_t.Events.InteractionCreate,async o=>{var u,d;if(!o.isChannelSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,O))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Fe);return m?m(o,this):(d=c(this,Ne))==null?void 0:d.call(this)},c(this,O)))},"#setupCollector"),Hn=i(function(){var t;(t=c(this,Ne))==null||t.call(this),h(this,Ne,null),h(this,Fe,null),h(this,O,null)},"#destroyCollector"),i(Gn,"ChannelSelectMenuKit");ft=Gn});var Vt,Ue,L,je,ce,Pr,Rr,Vn,Wn,ht,qn=g(()=>{"use strict";l();Vt=require("discord.js");_();Wn=class Wn extends Vt.MentionableSelectMenuBuilder{constructor(){super(...arguments);x(this,ce);x(this,Ue,null);x(this,L,{autoReset:!1,time:5*60*1e3,once:!0});x(this,je,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,Ue)&&v(this,ce,Vn).call(this),h(this,Ue,t),o&&h(this,L,{autoReset:o.autoReset??((r=c(this,L))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,L))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,L))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,L))==null?void 0:m.onEnd)}),v(this,ce,Rr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,L)??h(this,L,{}),c(this,L).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,L)??h(this,L,{}),c(this,L).onError=t,this}filter(t){return c(this,L)??h(this,L,{autoReset:!0,time:5*60*1e3}),c(this,L).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,ce,Vn).call(this),this}};Ue=new WeakMap,L=new WeakMap,je=new WeakMap,ce=new WeakSet,Pr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Rr=i(function(){if(!c(this,L))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,ce,Pr).call(this);t&&h(this,je,t.subscribe(Vt.Events.InteractionCreate,async o=>{var u,d;if(!o.isMentionableSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,L))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,Ue);return m?m(o,this):(d=c(this,je))==null?void 0:d.call(this)},c(this,L)))},"#setupCollector"),Vn=i(function(){var t;(t=c(this,je))==null||t.call(this),h(this,je,null),h(this,Ue,null),h(this,L,null)},"#destroyCollector"),i(Wn,"MentionableSelectMenuKit");ht=Wn});var Wt,He,$,Ge,me,Dr,Kr,Jn,zn,gt,Yn=g(()=>{"use strict";l();Wt=require("discord.js");_();zn=class zn extends Wt.UserSelectMenuBuilder{constructor(){super(...arguments);x(this,me);x(this,He,null);x(this,$,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Ge,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,He)&&v(this,me,Jn).call(this),h(this,He,t),o&&h(this,$,{autoReset:o.autoReset??((r=c(this,$))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,$))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,$))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,$))==null?void 0:m.onEnd)}),v(this,me,Kr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,$)??h(this,$,{}),c(this,$).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,$)??h(this,$,{}),c(this,$).onError=t,this}filter(t){return c(this,$)??h(this,$,{autoReset:!0,time:5*60*1e3}),c(this,$).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,me,Jn).call(this),this}};He=new WeakMap,$=new WeakMap,Ge=new WeakMap,me=new WeakSet,Dr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Kr=i(function(){if(!c(this,$))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,me,Dr).call(this);t&&h(this,Ge,t.subscribe(Wt.Events.InteractionCreate,async o=>{var u,d;if(!o.isUserSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,$))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,He);return m?m(o,this):(d=c(this,Ge))==null?void 0:d.call(this)},c(this,$)))},"#setupCollector"),Jn=i(function(){var t;(t=c(this,Ge))==null||t.call(this),h(this,Ge,null),h(this,He,null),h(this,$,null)},"#destroyCollector"),i(zn,"UserSelectMenuKit");gt=zn});var qt,_e,F,Ve,ue,kr,Tr,Xn,Qn,Ct,Zn=g(()=>{"use strict";l();qt=require("discord.js");_();Qn=class Qn extends qt.RoleSelectMenuBuilder{constructor(){super(...arguments);x(this,ue);x(this,_e,null);x(this,F,{autoReset:!1,time:5*60*1e3,once:!0});x(this,Ve,null)}onSelect(t,o){var r,a,s,m;if(!t)throw new TypeError('Cannot setup "onClick" without a handler function parameter.');return c(this,_e)&&v(this,ue,Xn).call(this),h(this,_e,t),o&&h(this,F,{autoReset:o.autoReset??((r=c(this,F))==null?void 0:r.autoReset)??!0,time:o.time??((a=c(this,F))==null?void 0:a.time)??5*60*1e3,filter:o.filter??((s=c(this,F))==null?void 0:s.filter),onEnd:o.onEnd??((m=c(this,F))==null?void 0:m.onEnd)}),v(this,ue,Tr).call(this),this}onEnd(t){if(!t)throw new TypeError('Cannot setup "onEnd" without a handler function parameter.');return c(this,F)??h(this,F,{}),c(this,F).onEnd=t,this}onError(t){if(!t)throw new TypeError('Cannot setup "onError" without a handler function parameter.');return c(this,F)??h(this,F,{}),c(this,F).onError=t,this}filter(t){return c(this,F)??h(this,F,{autoReset:!0,time:5*60*1e3}),c(this,F).filter=t,this}get customId(){return this.data.custom_id??this.data.customId}dispose(){return v(this,ue,Xn).call(this),this}};_e=new WeakMap,F=new WeakMap,Ve=new WeakMap,ue=new WeakSet,kr=i(function(){let t=R();return t?H(()=>t.commandkit.eventInterceptor):U(!0).eventInterceptor},"#getEventInterceptor"),Tr=i(function(){if(!c(this,F))return;if(!this.customId)throw new TypeError("Cannot setup an modal collector without a custom ID.");let t=v(this,ue,kr).call(this);t&&h(this,Ve,t.subscribe(qt.Events.InteractionCreate,async o=>{var u,d;if(!o.isRoleSelectMenu())return;let r=this.customId??null,a=o.customId;if(r&&a!==r)return;let s=(u=c(this,F))==null?void 0:u.filter;if(s&&!await s(o))return;let m=c(this,_e);return m?m(o,this):(d=c(this,Ve))==null?void 0:d.call(this)},c(this,F)))},"#setupCollector"),Xn=i(function(){var t;(t=c(this,Ve))==null||t.call(this),h(this,Ve,null),h(this,_e,null),h(this,F,null)},"#destroyCollector"),i(Qn,"RoleSelectMenuKit");Ct=Qn});function yt(n,e){n.setCustomId(e.customId??`select-menu::${crypto.randomUUID()}`),e.maxValues!=null&&n.setMaxValues(e.maxValues),e.minValues!=null&&n.setMinValues(e.minValues),e.placeholder&&n.setPlaceholder(e.placeholder),e.disabled&&n.setDisabled(e.disabled),e.onEnd&&n.onEnd(e.onEnd),e.onError&&n.onError(e.onError),e.onSelect&&n.onSelect(e.onSelect,e.options)}function es(n){let e=new pt;return yt(e,n),n.children&&e.setOptions(Array.isArray(n.children)?n.children:[n.children]),n.children&&e.setOptions(Array.isArray(n.children)?n.children:[n.children]),e}function ts(n){return new Ar.StringSelectMenuOptionBuilder(n)}function ns(n){let e=new gt;return yt(e,n),n.defaultValues&&e.setDefaultUsers(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),e}function os(n){let e=new Ct;return yt(e,n),n.defaultValues&&e.setDefaultRoles(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),e}function rs(n){let e=new ht;return yt(e,n),n.defaultValues&&e.setDefaultValues(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),e}function is(n){let e=new ft;return yt(e,n),n.defaultValues&&e.setDefaultChannels(Array.isArray(n.defaultValues)?n.defaultValues:[n.defaultValues]),n.channelTypes&&e.setChannelTypes(Array.isArray(n.channelTypes)?n.channelTypes:[n.channelTypes]),e}var Ar,Br=g(()=>{"use strict";l();Ar=require("discord.js");_n();qn();Zn();jn();Yn();i(yt,"applyPropsToBuilder");i(es,"StringSelectMenu");i(ts,"StringSelectMenuOption");i(ns,"UserSelectMenu");i(os,"RoleSelectMenu");i(rs,"MentionableSelectMenu");i(is,"ChannelSelectMenu")});var Or=g(()=>{"use strict";l()});function Ze(n,e){n.id!=null&&e.setId(n.id)}var Jt=g(()=>{"use strict";l();i(Ze,"applyId")});function as(n){let e=new V.ContainerBuilder;if(Ze(n,e),typeof n.accentColor!=null&&e.setAccentColor(n.accentColor),n.spoiler!=null&&e.setSpoiler(n.spoiler),n.children!=null){if(Array.isArray(n.children)||(n.children=[n.children]),n.children.length===0)return e;for(let t of n.children.flat())t instanceof V.TextDisplayBuilder&&e.addTextDisplayComponents(t),t instanceof V.FileBuilder&&e.addFileComponents(t),t instanceof V.ActionRowBuilder&&e.addActionRowComponents(t),t instanceof V.SeparatorBuilder&&e.addSeparatorComponents(t),t instanceof V.SectionBuilder&&e.addSectionComponents(t),t instanceof V.MediaGalleryBuilder&&e.addMediaGalleryComponents(t)}return e}var V,Lr=g(()=>{"use strict";l();V=require("discord.js");Jt();i(as,"Container")});function ss(n){let e=new $r.FileBuilder(n);return n.url!=null&&e.setURL(n.url),e}var $r,Fr=g(()=>{"use strict";l();$r=require("discord.js");i(ss,"File")});function ls(n){let e=new zt.MediaGalleryBuilder;return Ze(n,e),n.children!=null&&(Array.isArray(n.children)||(n.children=[n.children]),e.addItems(n.children.flat())),e}function cs(n){let e=new zt.MediaGalleryItemBuilder;return n.description!=null&&e.setDescription(n.description),n.spoiler!=null&&e.setSpoiler(n.spoiler),n.url!=null&&e.setURL(n.url),e}var zt,Nr=g(()=>{"use strict";l();zt=require("discord.js");Jt();i(ls,"MediaGallery");i(cs,"MediaGalleryItem")});function ms(n){let e=new de.SectionBuilder;if(Ze(n,e),n.children!=null){Array.isArray(n.children)||(n.children=[n.children]);for(let t of n.children.flat())t instanceof de.ThumbnailBuilder?e.setThumbnailAccessory(t):t instanceof de.ButtonBuilder?e.setButtonAccessory(t):t instanceof de.TextDisplayBuilder&&e.addTextDisplayComponents(t)}return e}function us(n){return new de.ThumbnailBuilder({description:n.description,spoiler:n.spoiler,id:n.id,media:{url:n.url}})}var de,Ur=g(()=>{"use strict";l();de=require("discord.js");Jt();i(ms,"Section");i(us,"Thumbnail")});function ds(n){return new jr.SeparatorBuilder(n)}var jr,Hr=g(()=>{"use strict";l();jr=require("discord.js");i(ds,"Separator")});function ps(n){let e=new Gr.TextDisplayBuilder(n);return!n.content&&n.children&&(Array.isArray(n.children)?e.setContent(n.children.join(" ")):e.setContent(typeof n.children=="string"?n.children:String(n.children))),e}var Gr,_r=g(()=>{"use strict";l();Gr=require("discord.js");i(ps,"TextDisplay")});var Vr=g(()=>{"use strict";l();Lr();Fr();Nr();Ur();Hr();_r()});function fs(n,e="CommandKitWarning"){process.emitWarning(n,{code:e})}function eo(n){Wr.has(n)||(Wr.add(n),fs(`${n} is unstable and may change in future versions.`,"CommandKitUnstableWarning"))}var Wr,qr=g(()=>{"use strict";l();Wr=new Set;i(fs,"emitWarning");i(eo,"warnUnstable")});function gs(n){return!(typeof n!="object"||n===null||!Reflect.has(n,"type")||!Reflect.has(n,"data"))}function Cs(n){return n.data}function to(n){return eo("CommandKit JSX"),Array.isArray(n.children)?n.children.flat():[n.children]}function no(n,e,...t){return eo("CommandKit JSX"),n({...e,children:e.children??t})}var hs,Jr=g(()=>{"use strict";l();qr();hs={ActionRow:"action-row",Button:"button-kit",Modal:"modal",TextInput:"text-input"};i(gs,"isCommandKitElement");i(Cs,"getElement");i(to,"Fragment");i(no,"createElement")});var zr=g(()=>{"use strict";l()});var Yt,Yr,oo,xt,ro=g(()=>{"use strict";l();oo=class oo{constructor(e){this.client=e;x(this,Yt);I(this,"subscribers",new Map);I(this,"globalHandlers",new Map);I(this,"cleanupTimer",null);v(this,Yt,Yr).call(this)}destroy(){this.cleanupTimer&&(clearInterval(this.cleanupTimer),this.cleanupTimer=null);for(let[e,t]of this.subscribers)for(let o of t)this.unsubscribe(e,o,"destroy");this.subscribers.clear(),this.globalHandlers.clear()}hasSubscribers(e){return this.subscribers.has(e)}getSubscriberCount(e){let t=this.subscribers.get(e);return(t==null?void 0:t.size)??0}hasGlobalHandlers(){return this.globalHandlers.size>0}getGlobalHandlersCount(){return this.subscribers.size}subscribe(e,t,o){return this.subscribers.has(e)||(this.subscribers.set(e,new Set),this.client.on(e,this.createGlobalHandler(e)),this.client.setMaxListeners(this.client.getMaxListeners()+1)),o??={},o.registeredAt=Date.now(),Reflect.set(t,"options",o),this.subscribers.get(e).add(t),()=>{this.unsubscribe(e,t)}}unsubscribe(e,t,o){var a,s;let r=this.subscribers.get(e);r&&(r.delete(t),r.size<1&&(this.subscribers.delete(e),this.client.removeListener(e,this.globalHandlers.get(e)),this.globalHandlers.delete(e),this.client.setMaxListeners(Math.max(this.client.getMaxListeners()-1,0))),(s=(a=Reflect.get(t,"options")).onEnd)==null||s.call(a,o??"unsubscribe"))}createGlobalHandler(e){if(this.globalHandlers.has(e))return this.globalHandlers.get(e);let t=i(async(...o)=>{let r=this.subscribers.get(e);if(r&&r.size>0)for(let a of r){let s=Reflect.get(a,"options");if(s.time&&Date.now()-s.registeredAt>s.time){this.unsubscribe(e,a,"time");continue}if(s.autoReset&&(s.registeredAt=Date.now()),!(s.filter&&!await s.filter(...o)))try{await a(...o)}catch(u){if(s.onError)await s.onError(u);else throw u}finally{s.once&&this.unsubscribe(e,a,"once")}}},"handler");return this.globalHandlers.set(e,t),t}};Yt=new WeakSet,Yr=i(function(){this.cleanupTimer&&clearInterval(this.cleanupTimer),this.cleanupTimer=setInterval(()=>{for(let[e,t]of this.subscribers)for(let o of t){let r=Reflect.get(o,"options");r.time&&Date.now()-r.registeredAt>r.time&&this.unsubscribe(e,o,"time")}},6e4).unref()},"#cleanupLoop"),i(oo,"EventInterceptor");xt=oo});var io=g(()=>{"use strict";l();pr();Bn();xr();$n();Er();jn();_n();qn();Yn();Zn();Br();Or();Vr();Jr();zr();ro()});var ys,W,xs,bs,Y,ve=g(()=>{"use strict";l();ys=Symbol("kCommandKitCacheTag"),W=process.env.COMMANDKIT_IS_DEV==="true",xs=process.env.COMMANDKIT_IS_TEST==="true",bs=process.env.COMMANDKIT_BOOTSTRAP_MODE||"development",Y={ReloadCommands:"reload-commands",ReloadEvents:"reload-events",Unknown:"unknown"}});function Xt(n){return n instanceof We}var Xr,ao,We,so=g(()=>{"use strict";l();Xr=require("crypto"),ao=class ao{constructor(e){this.options=e}id=(0,Xr.randomUUID)();loadedAt=Date.now();async activate(e){}async deactivate(e){}};i(ao,"PluginCommon");We=ao;i(Xt,"isPlugin")});function bt(n){return Xt(n)&&n.type==="compiler"}var lo,pe,Qr=g(()=>{"use strict";l();so();lo=class lo extends We{type="compiler";async transform(e){return null}async resolve(e){return null}async onBuildStart(){}async onBuildEnd(){}};i(lo,"CompilerPlugin");pe=lo;i(bt,"isCompilerPlugin")});function mo(n){return Xt(n)&&n.type==="runtime"}var uo,co,Zr=g(()=>{"use strict";l();so();uo=class uo extends We{type="runtime";async onBeforeCommandsLoad(e){}async onAfterCommandsLoad(e){}async onBeforeEventsLoad(e){}async onAfterEventsLoad(e){}async onBeforeClientLogin(e){}async onAfterClientLogin(e){}async onBeforeInteraction(e,t){}async onBeforeMessageCommand(e,t){}async executeCommand(e,t,o,r,a){return!1}async onEventsRouterInit(e){}async onCommandsRouterInit(e){}async performHMR(e,t){}async prepareCommand(e,t){return null}async onBeforeRegisterCommands(e,t){}async onBeforeRegisterGlobalCommands(e,t){}async onBeforePrepareGuildCommandsRegistration(e,t){}async onBeforeRegisterGuildCommands(e,t){}async onAfterCommand(e,t){}async willEmitEvent(e,t){}};i(uo,"RuntimePlugin");co=uo;i(mo,"isRuntimePlugin")});var ei=g(()=>{"use strict";l()});var Es,ws,Ms,Qt,po,vt,fo=g(()=>{"use strict";l();_();ye();Es={autocomplete:"Autocomplete",messageContextMenu:"MessageContextMenu",userContextMenu:"UserContextMenu",chatInput:"ChatInputCommand",message:"Message"},ws={0:C.blue,1:C.green,2:C.yellow,3:C.red,4:C.white},Ms={0:C.bgBlue,1:C.bgGreen,2:C.bgYellow,3:C.bgRed,4:C.bgWhite},Qt={vertical:"\u2502",horizontalDown:"\u252C",horizontalUp:"\u2534",verticalRight:"\u251C",corner:"\u2514"},po=class po{constructor(e=process.stdout,t=process.stderr){this.stdout=e;this.stderr=t;this.logger=new console.Console(this.stdout,this.stderr)}logger;_formatTime(e){let t=e.getHours().toString().padStart(2,"0"),o=e.getMinutes().toString().padStart(2,"0"),r=e.getSeconds().toString().padStart(2,"0"),a=e.getMilliseconds().toString().padStart(3,"0");return`${t}:${o}:${r}.${a}`}_getContext(){let e=R();if(!e)return"";let t=e.variables.get("execHandlerKind"),o=e.variables.get("commandHandlerType"),r=e.variables.get("currentCommandName");if(!t&&!o)return"";let a=Es[t];if(!a&&!o)return"";let s=e.variables.get("forwardedBy"),m=e.variables.get("forwardedTo"),u=r?C.magenta(`/${r}`)+" ":"",d=m?`${C.yellowBright(`(${s||r} \u2192 ${m})`)} `:"";return C.dim(`${Qt.vertical} `)+C.cyanBright(`${u}${d}${a?C.gray(`[${a}]`):""}`.trim())}_getLevelLabel(e){let t;switch(e){case 0:t="[DEBUG]";break;case 1:t="[INFO]";break;case 2:t="[WARN]";break;case 3:t="[ERROR]";break;default:t="[LOG]"}return`${Ms[e](C.whiteBright(` ${t} `))} `}_getPrefix(e){let t=this._formatTime(new Date);return`${this._getLevelLabel(e)}${C.dim(Qt.vertical)} ${C.dim(t)}`}_log(e,...t){let o=this._getPrefix(e),r=this._getContext(),a=ws[e];r?this.logger.log(`${o}
2
+ ${r} ${C.dim(Qt.corner)}`,...t.map(s=>a(s))):this.logger.log(`${o} ${C.dim(Qt.corner)}`,...t.map(s=>a(s)))}debug(...e){this._log(0,...e)}error(...e){this._log(3,...e)}log(...e){this._log(4,...e)}info(...e){this._log(1,...e)}warn(...e){this._log(2,...e)}};i(po,"DefaultLogger");vt=po});function ti(n){let e=n;if(!(e!=null&&e.provider))throw new Error("A logger provider must be provided.");let t=["log","error","warn","info","debug"],o={configure(r){e=r}};for(let r of t)o[r]=(...a)=>{e.provider[r](...a)};return o}var M,fe=g(()=>{"use strict";l();fo();i(ti,"createLogger");M=ti({provider:new vt})});var ni,ho,Et,go=g(()=>{"use strict";l();ni=require("discord.js");ke();fe();ho=class ho{constructor(e){this.commandkit=e}plugins=new ni.Collection;getPlugins(){return this.plugins}getPlugin(e){return this.plugins.get(e)??null}async softRegisterPlugin(e){let t=e.name;if(!this.plugins.has(t))try{await e.activate(this),this.plugins.set(t,e)}catch(o){throw new Error(`Failed to activate plugin "${t}": ${(o==null?void 0:o.stack)||o}`)}}async registerPlugin(e){let t=e.name;if(this.plugins.has(t))throw new Error(`Plugin with name "${t}" already exists.`);try{await e.activate(this),this.plugins.set(t,e)}catch(o){throw new Error(`Failed to activate plugin "${t}": ${(o==null?void 0:o.stack)||o}`)}}async unregisterPlugin(e){let t=e.name;if(!this.plugins.has(t))throw new Error(`Plugin with name "${t}" does not exist.`);this.plugins.delete(t);try{await e.deactivate(this)}catch(o){throw new Error(`Failed to deactivate plugin "${t}": ${(o==null?void 0:o.stack)||o}`)}}async unregisterAllPlugins(){for(let e of this.plugins.values())await this.unregisterPlugin(e)}capture(){throw Ke(k.PluginCaptureHandle)}async execute(e){let t;for(let o of this.plugins.values())try{t=await e(this,o)}catch(r){if(ee(r,k.PluginCaptureHandle))return!0;M.error(`Plugin "${o.name}" failed`,(r==null?void 0:r.stack)||r)}return t}};i(ho,"CommandKitPluginRuntime");Et=ho});function Co(n){let t=class t extends pe{name=n.name;onBuildEnd(){var r;return(r=n.onBuildEnd)==null?void 0:r.call(n)}onBuildStart(){var r;return(r=n.onBuildStart)==null?void 0:r.call(n)}async transform(r){var a;return(a=n.transform)==null?void 0:a.call(n,r)}async resolve(r){var a;return(a=n.resolve)==null?void 0:a.call(n,r)}};i(t,"EsbuildPluginCompat");let e=t;return e}var ri,oi,yo,wt,ii=g(()=>{"use strict";l();ri=require("fs/promises");he();oi=/\.(c|m)?(t|j)sx?$/,yo=class yo{constructor(e){this.plugins=e}name="CompilerPluginRuntime";getPlugins(){return this.plugins}isEmpty(){return!this.plugins.length}async onLoad(e){var a,s;let o=await(0,ri.readFile)(e.path,"utf8"),r=(a=e.path)==null?void 0:a.split(".").pop();for(let m of this.plugins)try{let u=await((s=m.transform)==null?void 0:s.call(m,{contents:o,path:e.path,loader:r,args:e}));if(!u)continue;u.contents&&(o=u.contents),u.loader&&(r=u.loader)}catch(u){let d=u instanceof Error?u:new Error(u);return{pluginName:m.name,errors:[{text:d.message,detail:(d==null?void 0:d.stack)??d,location:null}]}}return{contents:o,loader:r}}async onResolve(e){var o;let t={};for(let r of this.plugins)try{let a=await((o=r.resolve)==null?void 0:o.call(r,e));if(!a)continue;t={...t,...a}}catch(a){let s=a instanceof Error?a:new Error(a);return{errors:[{text:s.message,detail:(s==null?void 0:s.stack)??s,location:null}]}}return t}async onStart(){var e;for(let t of this.plugins)try{await((e=t.onBuildStart)==null?void 0:e.call(t))}catch(o){console.error(`Plugin ${t.name} failed to run onBuildStart with ${(o==null?void 0:o.stack)||o}`)}}async onEnd(){var e;for(let t of this.plugins)try{await((e=t.onBuildEnd)==null?void 0:e.call(t))}catch(o){console.error(`Plugin ${t.name} failed to run onBuildEnd with ${(o==null?void 0:o.stack)||o}`)}}async onDispose(){var e;for(let t of this.plugins)try{await((e=t.deactivate)==null?void 0:e.call(t,this))}catch(o){console.error(`Plugin ${t.name} failed to deactivate with ${(o==null?void 0:o.stack)||o}`)}}async onInit(){var e;for(let t of this.plugins)try{await((e=t.activate)==null?void 0:e.call(t,this))}catch(o){console.error(`Plugin ${t.name} failed to activate with ${(o==null?void 0:o.stack)||o}`)}}async cleanup(){await this.onEnd(),await this.onDispose()}async setup(e){this.plugins.length&&(await this.onInit(),await e.onResolve({filter:oi},this.onResolve.bind(this)),await e.onLoad({filter:oi},this.onLoad.bind(this)),await e.onStart(this.onStart.bind(this)),e.onEnd(async()=>{await this.onEnd()}),e.onDispose(async()=>{await this.onDispose()}))}toEsbuildPlugin(){return{name:this.name,setup:this.setup.bind(this)}}};i(yo,"CompilerPluginRuntime");wt=yo;i(Co,"fromEsbuildPlugin")});var ai=g(()=>{"use strict";l()});var si=g(()=>{"use strict";l()});var bo,xo,li=g(()=>{"use strict";l();he();bo=class bo extends pe{transformer=null;async activate(e){let{createDirectiveTransformer:t}=await import("directive-to-hof");this.transformer=t(this.options)}async deactivate(e){this.transformer=null}async transform(e){if(!this.options.enabled||!this.transformer)return null;let t=await this.transformer(e.contents.toString(),e.path);return{contents:t.contents,loader:t.loader}}};i(bo,"CommonDirectiveTransformer");xo=bo});var he=g(()=>{"use strict";l();Qr();Zr();ei();go();ii();ai();si();li()});var vo,Zt,ci=g(()=>{"use strict";l();he();vo=class vo extends pe{name="MacroPlugin";macroTransformer;async activate(){let e=await import("use-macro");this.macroTransformer=new e.MacroTransformer}async deactivate(){this.macroTransformer=null}async transform(e){if(!this.options.enabled)return null;let{contents:t,loader:o}=await this.macroTransformer.transform(e.contents.toString(),e.path);return{contents:t,loader:o}}};i(vo,"MacroPlugin");Zt=vo});var X,mi=g(()=>{"use strict";l();ci();X={plugins:[new Zt({enabled:!0})],esbuildPlugins:[],compilerOptions:{macro:{development:!1}},static:!0,typescript:{ignoreBuildErrors:!1},distDir:"dist",env:{},sourceMap:{development:!0,production:!0},typedCommands:!0}});function qe(){return Eo}function Ss(n={}){var e;return Eo={compilerOptions:{macro:{...X.compilerOptions.macro,...(e=n.compilerOptions)==null?void 0:e.macro}},distDir:n.distDir??X.distDir,env:{...X.env,...n.env},esbuildPlugins:[...n.esbuildPlugins??[],...X.esbuildPlugins??[]],plugins:[...n.plugins??[],...X.plugins??[]].flat(1/0),sourceMap:{...X.sourceMap,...n.sourceMap},static:n.static??X.static,typedCommands:n.typedCommands??X.typedCommands,typescript:{...X.typescript,...n.typescript}},Eo}var Eo,en=g(()=>{"use strict";l();mi();Eo=X;i(qe,"getConfig");i(Ss,"defineConfig")});function tn(n,e){return Reflect.set(n,di,!0),Je.run(n,e)}function Is(){let n=Je.getStore();if(!n)throw new Error("Event worker context not found");return n}function Ps(n){return n&&Reflect.get(n,di)===!0}var ui,di,Je,Mt=g(()=>{"use strict";l();ui=require("async_hooks"),di=Symbol("commandkitEventWorker"),Je=new ui.AsyncLocalStorage;i(tn,"runInEventWorkerContext");i(Is,"getEventWorkerContext");i(Ps,"isEventWorkerContext")});function pi(){if(Mo)return Mo;let n=(0,St.join)(process.cwd(),W?".commandkit":qe().distDir);return(0,nn.existsSync)(n)||(n=process.cwd()),Mo=n,n}function fi(){return["src",".commandkit",qe().distDir].map(t=>(0,St.join)(process.cwd(),t))}function hi(){if(wo)return wo;let n=(0,St.join)(process.cwd(),W?".commandkit":qe().distDir);(0,nn.existsSync)(n)||(n=process.cwd());let e=["app"].map(t=>(0,St.join)(n,t));for(let t of e)if((0,nn.existsSync)(t))return wo=t,t;return null}function on(n,e){let t=null,o=null;return(...r)=>(t&&(clearTimeout(t),o&&o(null)),new Promise(a=>{o=a,t=setTimeout(()=>{let s=n(...r);a(s),t=null,o=null},e)}))}function gi(n){return i((...t)=>{if(W)return n(...t)},"f")}function Ci(){throw Je.getStore()?new Ee:new Error("stopEvents() may only be called inside an event handler")}var nn,St,wo,Mo,So,Ee,It=g(()=>{"use strict";l();nn=require("fs"),St=require("path");ve();en();Mt();wo=null,Mo=null;i(pi,"getCurrentDirectory");i(fi,"getSourceDirectories");i(hi,"findAppDirectory");i(on,"debounce");i(gi,"devOnly");So=class So extends Error{constructor(){super("Event propagation stopped"),this.name="StopEventPropagationError"}};i(So,"StopEventPropagationError");Ee=So;i(Ci,"stopEvents")});function Pt(n,e=!1){return`${"file://"+yi.default.resolve(n).replace(/\\\\|\\/g,"/")}${e?`?ts=${Date.now()}`:""}`}var yi,Io=g(()=>{"use strict";l();yi=q(require("path"));i(Pt,"toFileURL")});var G,ze,et,Dt,Po,Rt,Ro,rn,Do=g(()=>{"use strict";l();G=require("discord.js");ke();Po=class Po{constructor(e,t,o){this.message=e;this.prefix=t;this.schema=o;x(this,ze,null);x(this,et,null);x(this,Dt,[])}getArgs(){return this.parse(),c(this,Dt)}get options(){return c(this,et)||h(this,et,new rn(this)),c(this,et)}getOption(e){var t;return(t=this.parse().options.find(o=>o.name===e))==null?void 0:t.value}getCommand(){return this.parse().command}getSubcommand(){return this.parse().subcommand}getSubcommandGroup(){return this.parse().subcommandGroup}getPrefix(){for(let e of this.prefix)if(this.message.content.startsWith(e))return e}getFullCommand(){return[this.getCommand(),this.getSubcommandGroup(),this.getSubcommand()].filter(e=>e).join(" ")}parse(){if(c(this,ze))return c(this,ze);let e=this.message.content,t=this.getPrefix();if(!t)throw Ke(k.InvalidCommandPrefix);let o=e.slice(t.length).trim().split(" "),r=o.shift();h(this,Dt,o);let a,s;if(r!=null&&r.includes(":")){let[,d,p]=r.split(":");!p&&d?s=d:p&&d&&(a=d,s=p)}let m=this.schema([r,a,s].filter(Boolean).join(" ").trim()),u=o.map(d=>{try{let[p,b]=d.split(":");if(!(p in m))return null;switch(m[p]){case G.ApplicationCommandOptionType.Boolean:return{name:p,value:b==="true"};case G.ApplicationCommandOptionType.Integer:return{name:p,value:parseInt(b,10)};case G.ApplicationCommandOptionType.Number:return{name:p,value:parseFloat(b)};case G.ApplicationCommandOptionType.String:return{name:p,value:b};case G.ApplicationCommandOptionType.User:return{name:p,value:this.message.mentions.users.find(y=>y.id===b.replace(/[<@!>]/g,""))};case G.ApplicationCommandOptionType.Channel:return{name:p,value:this.message.mentions.channels.find(y=>y.id===b.replace(/[<#>]/g,""))};case G.ApplicationCommandOptionType.Role:return{name:p,value:this.message.mentions.roles.find(y=>y.id===b.replace(/[<@&>]/g,""))};case G.ApplicationCommandOptionType.Attachment:return{name:p,value:this.message.attachments.find(y=>y.name===b)};default:return null}}catch{return null}}).filter(d=>d!==null);return h(this,ze,{command:r,options:u,subcommand:s,subcommandGroup:a}),c(this,ze)}};ze=new WeakMap,et=new WeakMap,Dt=new WeakMap,i(Po,"MessageCommandParser");Rt=Po,Ro=class Ro{constructor(e){this.parser=e}assertOption(e,t=!1){let o=this.parser.getOption(e);if(t&&o===void 0)throw new Error(`Option "${e}" is required.`);return o??null}getMember(e,t=!1){var a;let o=this.assertOption(e,t),r=(a=this.parser.message.guild)==null?void 0:a.members.cache.get(o==null?void 0:o.id);if(t&&!r)throw new Error(`Member "${e}" is required.`);return r??null}getAttachment(e,t=!1){return this.assertOption(e,t)}getBoolean(e,t=!1){return this.assertOption(e,t)}getNumber(e,t=!1){return this.assertOption(e,t)}getString(e,t=!1){return this.assertOption(e,t)}getInteger(e,t=!1){return this.assertOption(e,t)}getUser(e,t=!1){return this.assertOption(e,t)}getChannel(e,t=!1){return this.assertOption(e,t)}getRole(e,t=!1){return this.assertOption(e,t)}getMentionable(e,t=!1){let o=this.assertOption(e,t);if(o instanceof G.GuildMember||o instanceof G.User||o instanceof G.Role)return o;if(t)throw new Error(`Mentionable "${e}" is required.`);return null}getSubcommand(e=!1){let t=this.parser.getSubcommand();if(e&&t===void 0)throw new Error("Subcommand is required.");return t??null}getSubcommandGroup(e=!1){let t=this.parser.getSubcommandGroup();if(e&&t===void 0)throw new Error("Subcommand group is required.");return t??null}};i(Ro,"MessageCommandOptions");rn=Ro});var te,Ko,Kt,ko=g(()=>{"use strict";l();te=require("discord.js");fe();Ko=class Ko{constructor(e){this.commandkit=e;this.api.setToken(this.commandkit.client.token??process.env.DISCORD_TOKEN??process.env.TOKEN??"")}api=new te.REST;getCommandsData(){return this.commandkit.commandHandler.getCommandsArray().flatMap(o=>{let r="toJSON"in o.data.command?o.data.command.toJSON():o.data.command,a=[r];return o.data.userContextMenu&&r.type!==te.ApplicationCommandType.User&&a.push({...r,type:te.ApplicationCommandType.User,options:void 0,description_localizations:void 0,description:void 0}),o.data.messageContextMenu&&r.type!==te.ApplicationCommandType.Message&&a.push({...r,type:te.ApplicationCommandType.Message,description_localizations:void 0,description:void 0,options:void 0}),a})}async register(){let e=this.getCommandsData(),t=!1,o={preventDefault(){t=!0},commands:e};if(await this.commandkit.plugins.execute(async(s,m)=>{if(!t)return m.onBeforeRegisterCommands(s,o)}),t)return;if(!this.commandkit.client.isReady())throw new Error("Cannot register commands before the client is ready");let r=e.filter(s=>{var m;return(m=s.guilds)==null?void 0:m.filter(Boolean).length}).map(s=>{var m;return{...s,guilds:Array.from(new Set((m=s.guilds)==null?void 0:m.filter(Boolean)))}}),a=e.filter(s=>{var m;return!((m=s.guilds)!=null&&m.filter(Boolean).length)});await this.updateGlobalCommands(a),await this.updateGuildCommands(r)}async updateGlobalCommands(e){if(!e.length)return;let t=!1,o={preventDefault(){t=!0},commands:e};await this.commandkit.plugins.execute(async(r,a)=>{if(!t)return a.onBeforeRegisterGlobalCommands(r,o)});try{let r=await this.api.put(te.Routes.applicationCommands(this.commandkit.client.user.id),{body:e.map(a=>({...a,guilds:void 0}))});M.info(`\u2728 Refreshed ${r.length} global application (/) commands`)}catch(r){M.error("Failed to update global application (/) commands",r)}}async updateGuildCommands(e){if(!e.length)return;let t=!1,o={preventDefault(){t=!0},commands:e};if(await this.commandkit.plugins.execute(async(r,a)=>{if(!t)return a.onBeforePrepareGuildCommandsRegistration(r,o)}),!t)try{let r=new Map;if(e.forEach(s=>{var m;(m=s.guilds)!=null&&m.length&&s.guilds.forEach(u=>{r.has(u)||r.set(u,[]),r.get(u).push(s)})}),!r.size)return;let a=0;for(let[s,m]of r){let u=!1,d={preventDefault(){u=!0},commands:m};if(await this.commandkit.plugins.execute(async(b,y)=>{if(!u)return y.onBeforeRegisterGuildCommands(b,d)}),u)continue;let p=await this.api.put(te.Routes.applicationGuildCommands(this.commandkit.client.user.id,s),{body:m.map(b=>({...b,guilds:void 0}))});a+=p.length}M.info(`\u2728 Refreshed ${a} guild application (/) commands`)}catch(r){M.error("Failed to update guild application (/) commands",r)}}};i(Ko,"CommandRegistrar");Kt=Ko});function Rs(n){let e=R();if(!e)throw new Error("after must be called inside commandkit handler.");return e.registerDeferredFunction(n)}function Ds(n){let e=R();if(!e)throw new Error("cancelAfter must be called inside commandkit handler.");e.clearDeferredFunction(n)}var xi,D,Ao,kt,To,Bo=g(()=>{"use strict";l();xi=require("crypto");_();Ao=class Ao{constructor(e){this.commandkit=e;x(this,D,{executionError:null,type:null,variables:new Map,deferredFunctions:new Map,marker:"",markStart:0,markEnd:0,context:null})}setContext(e){c(this,D).context=e}get context(){return c(this,D).context}getExecutionError(){return c(this,D).executionError}setExecutionError(e){if(c(this,D).executionError)throw new Error("Execution error already set.");c(this,D).executionError=e}getType(){let e=c(this,D).type;if(!e)throw new Error("Environment type not set.");return e}setType(e){c(this,D).type=e}get variables(){return c(this,D).variables}registerDeferredFunction(e){let t=(0,xi.randomUUID)();return c(this,D).deferredFunctions.set(t,e),t}clearDeferredFunction(e){c(this,D).deferredFunctions.delete(e)}async runDeferredFunctions(){for(let[e,t]of c(this,D).deferredFunctions)try{await t(this)}catch(o){this.commandkit.emit("unhandledDeferredFunctionRejection",o)}finally{this.clearDeferredFunction(e)}}clearAllDeferredFunctions(){c(this,D).deferredFunctions.clear()}markStart(e){c(this,D).marker=e,c(this,D).markStart=performance.now()}markEnd(){c(this,D).markEnd||(c(this,D).markEnd=performance.now())}getMarker(){return c(this,D).marker}getExecutionTime(){return Math.abs(c(this,D).markEnd-c(this,D).markStart)}};D=new WeakMap,i(Ao,"CommandKitEnvironment");kt=Ao,To=(e=>(e.CommandHandler="COMMAND_HANDLER",e))(To||{});i(Rs,"after");i(Ds,"cancelAfter")});function Oo(){throw Ke(k.ExitMiddleware)}function Ks(n){if(lt(n))throw n}function Lo(){throw Ke(k.ForwardedCommand)}var $o=g(()=>{"use strict";l();ke();i(Oo,"exitMiddleware");i(Ks,"rethrow");i(Lo,"redirect")});var j,tt,Tt,an,At,Fo,nt,No=g(()=>{"use strict";l();_();$o();j={ChatInputCommand:"chatInput",MessageContextMenu:"messageContextMenu",UserContextMenu:"userContextMenu",Autocomplete:"autocomplete",Message:"message"},Tt=class Tt{constructor(e,t){this.commandkit=e;this.config=t;I(this,"interaction");I(this,"message");I(this,"guild");I(this,"guildId");I(this,"channel");I(this,"channelId");I(this,"client");I(this,"command");x(this,tt);I(this,"_locale",null);this.interaction=t.interaction,this.message=t.message,this.client=e.client,h(this,tt,t.store??new Map),this.command=t.command,t.interaction&&(this.guild=t.interaction.guild,this.guildId=t.interaction.guildId,this.channel=t.interaction.channel,this.channelId=t.interaction.channelId),t.message&&(this.guild=t.message.guild,this.guildId=t.message.guildId,this.channel=t.message.channel,this.channelId=t.message.channelId),this.config.environment&&this.config.environment.setContext(this)}get store(){return c(this,tt)}get commandName(){return this.isInteraction()?this.interaction.commandName:this.config.messageCommandParser.getCommand()}get options(){return this.isMessage()?this.config.messageCommandParser.options:this.interaction.options}get forwarded(){return this.config.forwarded??!1}async forwardCommand(e){let t=await this.commandkit.commandHandler.prepareCommandRun(this.isInteraction()?this.interaction:this.message,e);if(!t)throw new Error(`Command ${e} not found`);let o=this.config.environment??R();if(!o)throw new Error("No commandkit environment found.");let r={chatInput:t.command.data.chatInput,autocomplete:t.command.data.autocomplete,message:t.command.data.message,messageContextMenu:t.command.data.messageContextMenu,userContextMenu:t.command.data.userContextMenu},a=o.variables.get("execHandlerKind");if(!a)throw new Error("No execution handler kind found.");let s=r[a];if(!s)throw new Error(`No handler found for ${a}`);o.variables.set("forwardedBy",this.commandName),o.variables.set("forwardedTo",e),await s(this.clone({forwarded:!0})),Lo()}get executionMode(){return this.config.executionMode}isInteraction(){return this.executionMode===j.ChatInputCommand||this.executionMode===j.Autocomplete||this.executionMode===j.MessageContextMenu||this.executionMode===j.UserContextMenu}isChatInputCommand(){return this.executionMode===j.ChatInputCommand}isAutocomplete(){return this.executionMode===j.Autocomplete}isMessageContextMenu(){return this.executionMode===j.MessageContextMenu}isUserContextMenu(){return this.executionMode===j.UserContextMenu}isMessage(){return this.executionMode===j.Message}getCommandIdentifier(){return this.isInteraction()?this.interaction.commandName:this.message.content.split(" ")[0].slice(1)}getGuildLocale(){var e;return this.isInteraction()?this.interaction.guildLocale:((e=this.message.guild)==null?void 0:e.preferredLocale)??null}getUserLocale(){return this.isInteraction()?this.interaction.locale:null}getLocale(e=!1){if(this._locale)return this._locale;let t=e?this.getUserLocale():this.getGuildLocale();return t||this.commandkit.config.defaultLocale}setLocale(e){this._locale=e}clone(e){return e?new Tt(this.commandkit,{...this.config,...e,store:c(this,tt)}):new Tt(this.commandkit,this.config)}isMiddleware(){return this instanceof nt}args(){return this.isMessage()?this.config.messageCommandParser.getArgs():[]}exit(){Oo()}};tt=new WeakMap,i(Tt,"Context");an=Tt,Fo=class Fo extends an{constructor(){super(...arguments);x(this,At,!1)}get cancelled(){return c(this,At)}cancel(){h(this,At,!0)}setCommandRunner(t){var o,r;(r=(o=this.config.customArgs)==null?void 0:o.setCommandRunner)==null||r.call(o,t)}};At=new WeakMap,i(Fo,"MiddlewareContext");nt=Fo});var sn,cn,bi,Uo,ln,vi=g(()=>{"use strict";l();sn=require("discord.js");Bo();fe();No();_();ke();Uo=class Uo{constructor(e){this.handler=e;x(this,cn)}async runCommand(e,t){let{commandkit:o}=this.handler,r=this.getExecutionMode(t),a=null,s=new kt(o);s.setType("COMMAND_HANDLER"),s.variables.set("commandHandlerType","app"),s.variables.set("currentCommandName",e.command.command.name),s.variables.set("execHandlerKind",r);let m=new nt(o,{command:e.command,environment:s,executionMode:r,interaction:t instanceof sn.Message?null:t,message:t instanceof sn.Message?t:null,forwarded:!1,customArgs:{setCommandRunner:i(d=>{a=d},"setCommandRunner")},messageCommandParser:e.messageCommandParser}),u=!1;if(e.middlewares.length&&await mt(s,async()=>{for(let d of e.middlewares)if(d.data.beforeExecute)try{await d.data.beforeExecute(m)}catch(p){if(ee(p,k.ExitMiddleware)){u=!0;return}if(ee(p,[k.ForwardedCommand,k.InvalidCommandPrefix]))continue;throw p}}),!m.cancelled){let p=e.command.data[r];if(p||M.warn(`Command ${e.command.command.name} has no handler for ${r}`),p)try{let b=Kn(s,async()=>(s.registerDeferredFunction(S=>{S.markEnd();let P=S.getExecutionError(),w=S.getMarker(),K=`${S.getExecutionTime().toFixed(2)}ms`;if(P){M.error(`[${w} - ${K}] Error executing command: ${P.stack||P}`);return}M.info(`[${w} - ${K}] Command executed successfully`)}),p(m.clone())),v(this,cn,bi).bind(this)),y=a!=null?a(b):b;s.markStart(e.command.data.command.name),await o.plugins.execute(async(S,P)=>P.executeCommand(S,s,t,e,y))||await y()}catch(b){ee(b,k.ExitMiddleware)&&(u=!0),ee(b,[k.ForwardedCommand,k.ExitMiddleware])||M.error(b)}}!u&&e.middlewares.length&&await mt(s,async()=>{for(let d of e.middlewares)if(d.data.afterExecute)try{await d.data.afterExecute(m)}catch(p){if(ee(p,k.ExitMiddleware))return;throw p}})}getExecutionMode(e){return e instanceof sn.Message?j.Message:e.isChatInputCommand()?j.ChatInputCommand:e.isAutocomplete()?j.Autocomplete:e.isMessageContextMenuCommand()?j.MessageContextMenu:e.isUserContextMenuCommand()?j.UserContextMenu:null}};cn=new WeakSet,bi=i(async function(){let e=kn();await e.runDeferredFunctions(),e.clearAllDeferredFunctions(),await this.handler.commandkit.plugins.execute(async(t,o)=>{await o.onAfterCommand(t,e)})},"#finalizer"),i(Uo,"AppCommandRunner");ln=Uo});async function ot(n=!1){let e=(0,we.join)(process.cwd(),"node_modules","commandkit-types");if(!W&&!n)return e;let t=(0,we.join)(e,"package.json"),o=(0,we.join)(e,"index.js"),r=(0,we.join)(e,"index.d.ts"),a=(0,we.join)(e,"command.d.ts"),s={name:"commandkit-types",version:"1.0.0",description:"CommandKit types package",type:"commonjs",main:"index.js",types:"index.d.ts"},m="module.exports = {};",u=`// Main types index file - imports all type declarations
3
3
  import './command';
4
4
  export {};
5
5
  `,d=`// Auto-generated command types
@@ -11,8 +11,8 @@ declare module 'commandkit' {
11
11
  ${n}
12
12
  }
13
13
  export {};
14
- `,t=(0,we.join)(process.cwd(),"node_modules","commandkit-types");if(!(0,Ei.existsSync)(t))return;let o=(0,we.join)(t,"command.d.ts");await(0,Me.writeFile)(o,e,{encoding:"utf-8"})}var Me,we,Ei,Bt=g(()=>{"use strict";l();Me=require("fs/promises"),we=require("path");ve();Ei=require("fs");i(ot,"generateTypesPackage");i(wi,"rewriteCommandDeclaration")});var N,ks,Ts,jo,Ot,Ho=g(()=>{"use strict";l();N=require("discord.js");Io();Do();ke();ko();fe();vi();ve();Bt();ye();ks={command:i(n=>n instanceof N.SlashCommandBuilder||n instanceof N.ContextMenuCommandBuilder||n&&typeof n=="object","command"),chatInput:i(n=>typeof n=="function","chatInput"),autocomplete:i(n=>typeof n=="function","autocomplete"),message:i(n=>typeof n=="function","message"),messageContextMenu:i(n=>typeof n=="function","messageContextMenu"),userContextMenu:i(n=>typeof n=="function","userContextMenu")},Ts={beforeExecute:i(n=>typeof n=="function","beforeExecute"),afterExecute:i(n=>typeof n=="function","afterExecute")},jo=class jo{constructor(e){this.commandkit=e;this.registrar=new Kt(this.commandkit)}loadedCommands=new N.Collection;loadedMiddlewares=new N.Collection;commandNameToId=new Map;subcommandPathToId=new Map;registrar;onInteraction=null;onMessageCreate=null;commandRunner=new ln(this);externalCommandData=new N.Collection;externalMiddlewareData=new N.Collection;printBanner(){let e=crypto.randomUUID(),t=this.getCommandsArray().reduce((u,d)=>{let p=d.command.category||e;return u[p]=u[p]||[],u[p].push(d),u},{});console.log(C.green(`Loaded ${C.magenta(this.loadedCommands.size.toString())} commands:`));let o=Object.keys(t).sort(),r={};o.forEach(u=>{if(u!==e&&u.includes(":")){let d=u.split(":"),p=null;for(let b=d.length-1;b>0;b--){let y=d.slice(0,b).join(":");if(o.includes(y)){p=y;break}}p&&(r[p]=r[p]||[],r[p].push(u))}});let a=new Set,s=i((u,d="",p=!1,b="")=>{if(a.has(u))return;a.add(u);let y=t[u],E=r[u]&&r[u].length>0,S=p?"\u2514\u2500":"\u251C\u2500",P=b+(p?" ":"\u2502 ");if(u!==e){let w=u.includes(":")?u.split(":").pop():u;console.log(C.cyan(`${d}${S} ${C.bold(w)}`))}if(y.forEach((w,K)=>{let st=K===y.length-1&&!E?"\u2514\u2500":"\u251C\u2500",Fa=u!==e?P:d,Na=w.data.command.name,Ua=w.command.middlewares.length>0?C.magenta(" (\u03BB)"):"";console.log(`${C.green(`${Fa}${st}`)} ${C.yellow(Na)}${Ua}`)}),E){let w=r[u].sort();w.forEach((K,De)=>{let st=De===w.length-1;s(K,P,st,P)})}},"printCategory"),m=o.filter(u=>{if(u===e)return!0;if(u.includes(":")){let d=u.split(":");for(let p=1;p<d.length;p++){let b=d.slice(0,p).join(":");if(o.includes(b))return!1}return!0}return!0}).sort();m.forEach((u,d)=>{let p=d===m.length-1;s(u,"",p)})}getCommandsArray(){return Array.from(this.loadedCommands.values())}registerCommandHandler(){this.onInteraction??=async e=>{if(await this.commandkit.plugins.execute(async(a,s)=>s.onBeforeInteraction(a,e))||!(e.isCommand()||e.isAutocomplete()||e.isUserContextMenuCommand()||e.isMessageContextMenuCommand()))return;let r=await this.prepareCommandRun(e);if(r)return this.commandRunner.runCommand(r,e)},this.onMessageCreate??=async e=>{if(await this.commandkit.plugins.execute(async(r,a)=>a.onBeforeMessageCommand(r,e))||e.author.bot)return;let o=await this.prepareCommandRun(e);if(o)return this.commandRunner.runCommand(o,e)},this.commandkit.client.on(N.Events.InteractionCreate,this.onInteraction),this.commandkit.client.on(N.Events.MessageCreate,this.onMessageCreate)}async prepareCommandRun(e,t){var m;let o;if(!t)if(e instanceof N.Message){if(e.author.bot)return null;let u=await this.commandkit.config.getMessageCommandPrefix(e);o=new Rt(e,Array.isArray(u)?u:[u],d=>{var E,S;let p=this.commandNameToId.get(d);if(!p)return null;let b=this.loadedCommands.get(p);return!b||e.guildId&&((E=b.guilds)!=null&&E.length)&&!b.guilds.includes(e.guildId)?null:((S=("toJSON"in b.data.command?b.data.command.toJSON():b.data.command).options)==null?void 0:S.reduce((P,w)=>(P[w.name]=w.type,P),{}))??{}});try{t=o.getFullCommand().split(" ")[0]}catch(d){return Z(d,k.InvalidCommandPrefix)||M.error(d),null}}else{if(!(e.isChatInputCommand()||e.isAutocomplete()||e.isContextMenuCommand()))return null;t=e.commandName}let r=this.commandNameToId.get(t);if(!r)return null;let a=this.loadedCommands.get(r);if(!a||(e instanceof N.CommandInteraction||e instanceof N.AutocompleteInteraction)&&e.guildId&&((m=a.guilds)!=null&&m.length)&&!a.guilds.includes(e.guildId))return null;let s=[];for(let u of a.command.middlewares){let d=this.loadedMiddlewares.get(u);d&&s.push(d)}return{command:a,middlewares:s,messageCommandParser:o}}async reloadCommands(){this.loadedCommands.clear(),this.loadedMiddlewares.clear(),this.commandNameToId.clear(),this.subcommandPathToId.clear(),this.externalCommandData.clear(),this.externalMiddlewareData.clear(),await this.loadCommands()}async addExternalMiddleware(e){for(let t of e)t.id&&this.externalMiddlewareData.set(t.id,t)}async addExternalCommands(e){for(let t of e)t.id&&this.externalCommandData.set(t.id,t)}async registerExternalLoadedMiddleware(e){for(let t of e)this.loadedMiddlewares.set(t.middleware.id,t)}async registerExternalLoadedCommands(e){for(let t of e)this.loadedCommands.set(t.command.id,t),this.commandNameToId.set(t.command.name,t.command.id)}async loadCommands(){await this.commandkit.plugins.execute((s,m)=>m.onBeforeCommandsLoad(s));let e=this.commandkit.commandsRouter;if(!e)throw new Error("Commands router has not yet initialized");let{commands:t,middlewares:o}=e.getData(),r=this.externalCommandData.size?t.concat(this.externalCommandData):t,a=this.externalMiddlewareData.size?o.concat(this.externalMiddlewareData):o;for(let[s,m]of a)await this.loadMiddleware(s,m);for(let[s,m]of r)await this.loadCommand(s,m);W&&await wi(`type CommandTypeData = ${Array.from(this.loadedCommands.mapValues(s=>JSON.stringify(s.command.name)).values()).join(" | ")}`),await this.commandkit.plugins.execute((s,m)=>m.onAfterCommandsLoad(s))}async loadMiddleware(e,t){try{let o=await import(`${Pt(t.path)}?t=${Date.now()}`),r=0;for(let[a,s]of Object.entries(Ts)){if(o[a]&&!await s(o[a]))throw new Error(`Invalid export for middleware ${e}: ${a} does not match expected value`);o[a]&&r++}if(r===0)throw new Error(`Invalid export for middleware ${e}: at least one handler function must be provided`);this.loadedMiddlewares.set(e,{middleware:t,data:o})}catch(o){M.error(`Failed to load middleware ${e}`,o)}}async loadCommand(e,t){try{if(t.path===null){this.loadedCommands.set(e,{command:t,data:{command:{name:t.name,description:`${t.name} commands`,type:1}}});return}let o=await import(`${Pt(t.path)}?t=${Date.now()}`);if(!o.command)throw new Error(`Invalid export for command ${t.name}: no command definition found`);let r=0;for(let[s,m]of Object.entries(ks))if(s!=="command"&&o[s]&&r++,o[s]&&!await m(o[s]))throw new Error(`Invalid export for command ${t.name}: ${s} does not match expected value`);if(r===0)throw new Error(`Invalid export for command ${t.name}: at least one handler function must be provided`);let a=o.command;await this.commandkit.plugins.execute(async(s,m)=>{let u=await m.prepareCommand(s,a);u&&(a=u)}),this.loadedCommands.set(e,{command:t,guilds:o.guilds,data:{...o,command:"toJSON"in a?a.toJSON():a}}),this.commandNameToId.set(t.name,e)}catch(o){M.error(`Failed to load command ${t.name} (${e})`,o)}}};i(jo,"AppCommandHandler");Ot=jo});var Go,Ii,_o,J,As,Mi,Si,Bs,Os,Vo,Lt,Pi=g(()=>{"use strict";l();Go=require("discord.js"),Ii=require("fs"),_o=require("fs/promises"),J=require("path"),As=/^\+middleware\.(m|c)?(j|t)sx?$/,Mi=/^\+([^+().][^().]*)\.middleware\.(m|c)?(j|t)sx?$/,Si=/^\+global-middleware\.(m|c)?(j|t)sx?$/,Bs=/^([^+().][^().]*)\.(m|c)?(j|t)sx?$/,Os=/^\(.+\)$/,Vo=class Vo{constructor(e){this.options=e}commands=new Go.Collection;middlewares=new Go.Collection;populate(e){for(let[t,o]of Object.entries(e.commands))this.commands.set(t,o);for(let[t,o]of Object.entries(e.middlewares))this.middlewares.set(t,o)}isValidPath(){return(0,Ii.existsSync)(this.options.entrypoint)}isCommand(e){return Bs.test(e)}isMiddleware(e){return As.test(e)||Si.test(e)||Mi.test(e)}isCategory(e){return Os.test(e)}clear(){this.commands.clear(),this.middlewares.clear()}async scan(){let e=await(0,_o.readdir)(this.options.entrypoint,{withFileTypes:!0});for(let t of e){if(t.name.startsWith("_"))continue;let o=(0,J.join)(this.options.entrypoint,t.name);if(t.isDirectory()){let r=this.isCategory(t.name)?t.name.slice(1,-1):null;await this.traverse(o,r)}else await this.handle(t)}return await this.applyMiddlewares(),this.toJSON()}getData(){return{commands:this.commands,middlewares:this.middlewares}}toJSON(){return{commands:Object.fromEntries(this.commands.entries()),middlewares:Object.fromEntries(this.middlewares.entries())}}async traverse(e,t){let o=await(0,_o.readdir)(e,{withFileTypes:!0});for(let r of o)if(!r.name.startsWith("_")){if(r.isFile())(this.isCommand(r.name)||this.isMiddleware(r.name))&&await this.handle(r,t);else if(r.isDirectory()&&this.isCategory(r.name)&&t){let a=this.isCategory(r.name)?`${t}:${r.name.slice(1,-1)}`:null;await this.traverse((0,J.join)(e,r.name),a)}}}async handle(e,t=null){let o=e.name,r=(0,J.join)(e.parentPath,e.name);if(this.isCommand(o)){let a={id:crypto.randomUUID(),name:(0,J.basename)(r,(0,J.extname)(r)),path:r,category:t,parentPath:e.parentPath,relativePath:this.replaceEntrypoint(r),middlewares:[]};this.commands.set(a.id,a)}else if(this.isMiddleware(o)){let a={id:crypto.randomUUID(),name:(0,J.basename)(r,(0,J.extname)(r)),path:r,relativePath:this.replaceEntrypoint(r),parentPath:e.parentPath,global:Si.test(o),command:Mi.test(o)&&o.split(".")[0]||null};this.middlewares.set(a.id,a)}}applyMiddlewares(){this.commands.forEach(e=>{let t=e.parentPath,o=Array.from(this.middlewares.values()).filter(r=>r.global?!0:r.command?r.command===e.name:r.parentPath===t).map(r=>r.id);e.middlewares=Array.from(new Set([...e.middlewares,...o]))})}replaceEntrypoint(e){return(0,J.normalize)(e).replace(this.options.entrypoint,"")}};i(Vo,"CommandsRouter");Lt=Vo});var Ri,Di,Wo,mn,qo,$t,Ki=g(()=>{"use strict";l();Ri=require("discord.js"),Di=require("fs"),Wo=require("fs/promises"),mn=require("path"),qo=class qo{constructor(e){this.options=e;var t;if(e.entrypoints&&(e.entrypoints=Array.from(new Set(e.entrypoints))),!((t=e.entrypoints)!=null&&t.length))throw new Error("Entrypoint directory must be provided")}events=new Ri.Collection;addEntrypoints(e){this.options.entrypoints=Array.from(new Set([...this.options.entrypoints,...e]))}match(e){return this.events.get(e)??null}get entrypoints(){return this.options.entrypoints}isValidPath(){return this.entrypoints.every(e=>(0,Di.existsSync)(e))}clear(){this.events.clear()}async reload(){return this.clear(),this.scan()}async scan(){for(let e of this.entrypoints){let t=await(0,Wo.readdir)(e,{withFileTypes:!0});for(let o of t)if(o.isDirectory()){let r=(0,mn.join)(e,o.name);await this.scanEvent(o.name,r,null,[],!0)}}return Object.fromEntries(this.events)}toJSON(){return Object.fromEntries(this.events)}async scanEvent(e,t,o=null,r=[],a=!1){let s=await(0,Wo.readdir)(t,{withFileTypes:!0}),m=a&&/^\(.+\)$/.test(e),u=m?e.slice(1,-1):o??null;s.sort((d,p)=>d.name.localeCompare(p.name));for(let d of s)if(!d.name.startsWith("_")){if(d.isDirectory()){let p=(0,mn.join)(t,d.name);await this.scanEvent(d.name,p,u,r);continue}d.isFile()&&/\.(m|c)?(j|t)sx?$/.test(d.name)&&r.push((0,mn.join)(d.parentPath,d.name))}if(!m){let d=this.events.get(e);if(d){d.listeners=Array.from(new Set([...d.listeners,...r]));return}this.events.set(e,{event:e,path:t,listeners:r,namespace:u})}}};i(qo,"EventsRouter");$t=qo});var Jo=g(()=>{"use strict";l();Pi();Ki()});var ki,zo,un,Ti=g(()=>{"use strict";l();ki=require("discord.js");fe();Io();It();Mt();zo=class zo{constructor(e){this.commandkit=e}loadedEvents=new ki.Collection;getEvents(){return this.loadedEvents.size===0?[]:this.loadedEvents.toJSON().map(t=>({name:t.name,namespace:t.namespace,onceListeners:t.listeners.filter(o=>o.once).length,regularListeners:t.listeners.filter(o=>!o.once).length,metadata:t.event}))}async reloadEvents(){this.unregisterAll(),await this.loadEvents()}async loadEvents(){await this.commandkit.plugins.execute((o,r)=>r.onBeforeEventsLoad(o));let t=await this.commandkit.eventsRouter.scan();for(let o of Object.values(t)){let r=[];for(let m of o.listeners){let u=await import(Pt(m,!0));(!u.default||typeof u.default!="function")&&M.error(`Event handler for ${o.event}${o.namespace?` of namespace ${o.namespace}`:""} does not have a default export or is not a function`),r.push({handler:u.default,once:!!u.once})}let a=r.length;a||M.warn(`Event ${o.event}${o.namespace?` of namespace ${o.namespace}`:""} does not have any listeners`);let s=`${o.namespace?`${o.namespace}:`:""}${o.event}`;this.loadedEvents.set(s,{name:o.event,namespace:o.namespace,event:o,listeners:r}),M.info(`\u2728 Loaded event ${o.event}${o.namespace?` of namespace ${o.namespace}`:""} with ${a} listener${a===1?"":"s"}`)}this.registerAllClientEvents(),await this.commandkit.plugins.execute((o,r)=>r.onAfterEventsLoad(o))}unregisterAll(){this.unregisterAllClientListeners(),this.loadedEvents.clear()}registerAllClientEvents(){let e=this.commandkit.client;for(let[t,o]of this.loadedEvents.entries()){let{name:r,listeners:a,namespace:s}=o,m=a.filter(y=>y.once),u=a.filter(y=>!y.once),d=new Set,p=i(async(...y)=>{let E=!1,S={name:r,args:y,namespace:s??null,once:!1,metadata:o.event,accept(){E||(E=!0)}};await this.commandkit.plugins.execute(async(P,w)=>{var K;if(!E)return(K=w.willEmitEvent)==null?void 0:K.call(w,P,S)}).catch(Object),await tn({event:r,namespace:s??null,data:o.event,commandkit:this.commandkit,arguments:y},async()=>{for(let P of u)try{await P.handler(...y)}catch(w){if(w instanceof Ee){M.debug(`Event propagation stopped for ${r}${s?` of namespace ${s}`:""}`);break}M.error(`Error handling event ${r}${s?` of namespace ${s}`:""}`,w)}})},"mainHandler"),b=i(async(...y)=>{let E=!1,S=!1,P={name:r,args:y,namespace:s??null,once:!0,metadata:o.event,accept(){S||(S=!0)}};await this.commandkit.plugins.execute(async(w,K)=>{var De;if(!S)return(De=K.willEmitEvent)==null?void 0:De.call(K,w,P)}).catch(Object);for(let w of m){if(E)break;await tn({event:r,namespace:s??null,data:o.event,commandkit:this.commandkit,arguments:y},async()=>{try{if(d.has(w.handler))return;await w.handler(...y),d.add(w.handler)}catch(K){K instanceof Ee&&(M.debug(`Event propagation stopped for ${r}${s?` of namespace ${s}`:""}`),E=!0),M.error(`Error handling event ${r}${s?` of namespace ${s}`:""}`,K)}})}d.size===m.length&&u.length===0&&(this.loadedEvents.delete(t),M.info(`\u{1F9F9} Cleaned up completed once-only event ${r}${s?` of namespace ${s}`:""}`))},"onceHandler");this.loadedEvents.set(t,{...o,mainListener:u.length>0?{handler:p,once:!1}:void 0,executedOnceListeners:d}),s?(u.length>0&&this.commandkit.events.on(s,r,p),m.length>0&&this.commandkit.events.once(s,r,b)):(u.length>0&&e.on(r,p),m.length>0&&e.once(r,b)),M.info(`\u{1F50C} Registered event ${r}${s?` of namespace ${s}`:""} (${u.length} regular, ${m.length} once-only)`)}}unregisterAllClientListeners(){let e=this.commandkit.client;for(let[t,{name:o,mainListener:r,namespace:a}]of this.loadedEvents.entries())r?a?this.commandkit.events.off(a,o,r.handler):e.off(o,r.handler):a?this.commandkit.events.removeAllListeners(a,o):e.removeAllListeners(o),this.loadedEvents.delete(t),M.info(`\u{1F5D1}\uFE0F Unregistered event ${o}${a?` of namespace ${a}`:""}`)}};i(zo,"AppEventsHandler");un=zo});function $s(n){process.stdout.write(n),process.stdout.write(`
15
- `)}function dn(n){let e=(0,ge.join)(n,"sharding-manager.js");return te.default.existsSync(e)?e:(0,ge.join)(n,"index.js")}function Se(n){$s(C.red(`Error: ${n}`)),process.exit(1)}async function Fs(n){return/\.(c|m)?tsx?$/.test(n)?(process.features.typescript||await Yo(),!0):!1}function Ns(){if(rt)return rt;let n={"yarn.lock":"yarn","pnpm-lock.yaml":"pnpm","package-lock.json":"npm","bun.lock":"bun","bun.lockb":"bun"};for(let[e,t]of Object.entries(n))if(te.default.existsSync((0,ge.join)(process.cwd(),e))){rt=t;break}return rt||(rt="npm"),rt}async function Yo(n){if(Q)return Q;try{Q=await import("typescript")}catch(e){if(e instanceof Error&&"code"in e&&e.code==="MODULE_NOT_FOUND")try{let t=Ns();return(0,Ai.execSync)(`${t} add typescript`,{stdio:"inherit",cwd:process.cwd()}),console.log(C.cyan("TypeScript has been installed automatically, restarting...")),Q=await import("typescript"),Q}catch{Se("TypeScript is not installed and could not be installed automatically. Please install it manually.")}Se(e||"TypeScript must be installed to use TypeScript config files.")}return Q}async function Bi(n){if(await Us(n),await Fs(n)&&Q){let{transpileModule:o}=Q,r=te.default.readFileSync(n,"utf8"),{outputText:a}=o(r,{compilerOptions:{module:Q.ModuleKind.ESNext,target:Q.ScriptTarget.ESNext,moduleResolution:Q.ModuleResolutionKind.NodeNext},fileName:n}),s=await ot(),m=(0,ge.join)(s,"compiled-commandkit.config.mjs");te.default.writeFileSync(m,a),n=m}return await import(`file://${n}`).then(o=>o.default||o)}async function Us(n){if(!te.default.existsSync(n))throw new Error(`File not found: ${n}`)}async function Oi(n,e){let t=(0,ge.join)(process.cwd(),n),o=(0,ge.join)(process.cwd(),e),r=["app/locales"],a=r.map(m=>(0,ge.join)(t,m)),s=r.map(m=>(0,ge.join)(o,m));for(let m of a){if(!te.default.existsSync(m))continue;let u=s[a.indexOf(m)];te.default.existsSync(u)||te.default.promises.mkdir(u,{recursive:!0}),await te.default.promises.cp(m,u,{recursive:!0,force:!0})}}var Ls,ge,te,Ai,Q,rt,Ie=g(()=>{"use strict";l();Ls=require("rimraf"),ge=require("path"),te=q(require("fs"));ye();Bt();Ai=require("child_process");i($s,"write");i(dn,"findEntrypoint");i(Se,"panic");i(Fs,"ensureTypeScript");i(Ns,"detectPackageManager");i(Yo,"loadTypeScript");i(Bi,"loadConfigFileFromPath");i(Us,"ensureExists");i(Oi,"copyLocaleFiles")});function Qo(n){return js.map(e=>(0,$i.join)(n,e))}function Hs(n){let e=Qo(n);for(let t of e)if((0,Li.existsSync)(t))return{path:t,isTypeScript:/\.ts$/.test(t)};return null}async function Ce(n=process.cwd()){if(Xo)return Xo;let e=Hs(n);if(!e)return qe();let t=await Bi(e.path);return Xo=t,t}var Li,$i,js,Xo,Ft=g(()=>{"use strict";l();Li=require("fs"),$i=require("path");Ie();en();js=["commandkit.config.js","commandkit.config.mjs","commandkit.config.cjs","commandkit.config.ts"];i(Qo,"getPossibleConfigPaths");i(Hs,"findConfigFile");Xo=null;i(Ce,"loadConfigFile")});function Fi(n){W&&process.on("message",async e=>{if(typeof e!="object"||e===null)return;let{event:t,path:o,id:r}=e;if(!t)return;process.env.COMMANDKIT_DEBUG_HMR==="true"&&M.info(`Received HMR event: ${t}${o?` for ${o}`:""}`);let a=!1,s=!1,m=!1,u={accept(){a=!0},preventDefault(){s=!0},path:o,event:t};try{if(await n.plugins.execute(async(d,p)=>{var b;a||await((b=p.performHMR)==null?void 0:b.call(p,d,u))}),s)return;switch(t){case Y.ReloadCommands:n.commandHandler.reloadCommands(),m=!0;break;case Y.ReloadEvents:n.eventHandler.reloadEvents(),m=!0;break;case Y.Unknown:m=!1;break;default:break}}finally{r&&process.send&&process.send({type:"commandkit-hmr-ack",id:r,handled:m||a})}})}var Ni=g(()=>{"use strict";l();fe();ve();i(Fi,"registerDevHooks")});var Ui,Zo,pn,ji=g(()=>{"use strict";l();Ui=q(require("events")),Zo=class Zo{constructor(e){this.commandkit=e}emitter=new Ui.default;to(e){return{on:this.on.bind(this,e),off:this.off.bind(this,e),once:this.once.bind(this,e),emit:this.emit.bind(this,e),removeAllListeners:this.removeAllListeners.bind(this,e)}}on(e,t,o){this.emitter.on(`${e}:${t}`,o)}off(e,t,o){this.emitter.off(`${e}:${t}`,o)}once(e,t,o){this.emitter.once(`${e}:${t}`,o)}emit(e,t,...o){return this.emitter.emit(`${e}:${t}`,...o)}removeAllListeners(e,t){t?this.emitter.removeAllListeners(`${e}:${t}`):this.emitter.removeAllListeners(e)}};i(Zo,"CommandKitEventsChannel");pn=Zo});var Hi,er,fn,Gi=g(()=>{"use strict";l();Hi=require("discord.js"),er=class er extends Hi.Collection{};i(er,"FlagStore");fn=er});function Gs(n){hn.add(n)}function _s(n){gn.add(n)}var _i,Cn,tr,Vi,Wi,hn,gn,it,z,qi,Ji,zi,Yi,Xi,ne,Te,jt=g(()=>{"use strict";l();_i=q(require("events"));ye();io();ro();Cn=require("discord.js");It();tr=require("path");Ho();Jo();Ti();go();Ft();ve();Ni();Vi=require("fs");ji();he();Bt();fe();Gi();hn=new Set,gn=new Set;i(Gs,"onBootstrap");i(_s,"onApplicationBootstrap");ne=class ne extends _i.default{constructor(t){if(ne.instance&&process.emitWarning("CommandKit instance already exists. Having multiple instance in same project is discouraged and it may lead to unexpected behavior.",{code:"MultiInstanceWarning"}),!t.client)throw new Error(C.red('"client" is required when instantiating CommandKit.'));super();this.options=t;x(this,z);x(this,it,!1);I(this,"eventInterceptor");I(this,"config",{defaultLocale:Cn.Locale.EnglishUS,getMessageCommandPrefix:i(()=>"!","getMessageCommandPrefix")});I(this,"store",new Map);I(this,"flags",new fn);I(this,"commandsRouter");I(this,"eventsRouter");I(this,"commandHandler",new Ot(this));I(this,"eventHandler",new un(this));I(this,"plugins");I(this,"events",new pn(this));this.plugins=new Et(this),ne.instance||(ne.instance=this),Wi=ne.instance,v(this,z,qi).call(this)}async start(t){if(!c(this,it)){if(!this.options.client)throw new Error(C.red('"client" is required when starting CommandKit.'));if(this.eventInterceptor=new xt(this.client),W)try{Fi(this),await ot()}catch(o){process.env.COMMANDKIT_DEBUG_TYPEGEN&&M.error(o)}if(await this.loadPlugins(),await v(this,z,zi).call(this),this.commandHandler.registerCommandHandler(),this.incrementClientListenersCount(),t!==!1&&!this.options.client.isReady()){this.client.once(Cn.Events.ClientReady,async()=>{await this.commandHandler.registrar.register()}),await this.plugins.execute((r,a)=>{var s;return(s=a.onBeforeClientLogin)==null?void 0:s.call(a,r)});let o=t??this.options.client.token??process.env.TOKEN??process.env.DISCORD_TOKEN;await this.options.client.login(o),await this.plugins.execute((r,a)=>{var s;return(s=a.onAfterClientLogin)==null?void 0:s.call(a,r)})}else this.options.client.isReady()&&await this.commandHandler.registrar.register();h(this,it,!0),await v(this,z,Ji).call(this)}}async loadPlugins(){let o=(await Ce()).plugins.flat(2).filter(r=>mo(r));if(o.length)for(let r of o)await this.plugins.softRegisterPlugin(r)}get started(){return c(this,it)}setPrefixResolver(t){return this.config.getMessageCommandPrefix=t,this}setDefaultLocale(t){return this.config.defaultLocale=t,this}get client(){return this.options.client}async reloadCommands(){await this.commandHandler.reloadCommands()}async reloadEvents(){await this.eventHandler.reloadEvents()}incrementClientListenersCount(){this.options.client.setMaxListeners(this.options.client.getMaxListeners()+1)}decrementClientListenersCount(){this.options.client.setMaxListeners(this.options.client.getMaxListeners()-1)}getAppDirectory(){return hi()}getPath(t){let o=this.getAppDirectory();if(!o)return null;switch(t){case"commands":return(0,tr.join)(o,"commands");case"events":return(0,tr.join)(o,"events");default:return t}}};it=new WeakMap,z=new WeakSet,qi=i(async function(){for(let t of hn)try{await t(this)}catch(o){M.error("Error while executing bootstrap hook: ",o)}finally{hn.delete(t)}hn.clear()},"#bootstrapHooks"),Ji=i(async function(){for(let t of gn)try{await t(this)}catch(o){M.error("Error while executing application bootstrap hook: ",o)}finally{gn.delete(t)}gn.clear()},"#applicationBootstrapHooks"),zi=i(async function(){if(!this.getAppDirectory())return;let o=this.getPath("commands"),r=this.getPath("events");this.commandsRouter=new Lt({entrypoint:o}),await this.plugins.execute((a,s)=>s.onCommandsRouterInit(a)),this.eventsRouter=new $t({entrypoints:[r]}),await this.plugins.execute((a,s)=>s.onEventsRouterInit(a)),await v(this,z,Xi).call(this),await v(this,z,Yi).call(this)},"#init"),Yi=i(async function(){if(this.commandsRouter.isValidPath()){let t=await this.commandsRouter.scan();W&&(0,Vi.writeFileSync)("./.commandkit/commands.json",JSON.stringify(t,null,2))}await this.commandHandler.loadCommands(),this.commandHandler.printBanner()},"#initCommands"),Xi=i(async function(){this.eventsRouter.isValidPath()&&await this.eventsRouter.scan(),await this.eventHandler.loadEvents()},"#initEvents"),i(ne,"CommandKit"),I(ne,"createElement",no),I(ne,"Fragment",to),I(ne,"instance");Te=ne});var ea={};Qe(ea,{version:()=>yn});var yn,xn=g(()=>{"use strict";l();yn="1.0.0-dev.20250528125253"});function vn(n=!1){let e={NODE_ENV:"development",COMMANDKIT_IS_DEV:"true"};return n?Object.assign({},e):Object.assign({},process.env,e)}function En(n=!1){let e={NODE_ENV:"production",COMMANDKIT_IS_DEV:"false"};return n?Object.assign({},e):Object.assign({},process.env,e)}var ta,Ws,qs,na,oa,rr=g(()=>{"use strict";l();i(vn,"DevEnv");i(En,"ProdEnv");ta=[".env",".env.local"],Ws=[".env.development",".env.development.local"],qs=[".env.production",".env.production.local"],na=[...ta,...Ws],oa=[...ta,...qs]});function Js(n){return n?["pipe","pipe","pipe","ipc"]:["pipe","pipe","pipe"]}function wn(n,e,t){var a,s;(0,aa.existsSync)((0,ia.join)(e,n))||Se(`Could not locate the entrypoint file: ${n}`);let o=Js(t),r=(0,ra.spawn)("node",[`--title="CommandKit ${t?"Development":"Production"}"`,"--enable-source-maps",n],{cwd:e,windowsHide:!0,env:t?vn():En(),stdio:o});return(a=r.stdout)==null||a.pipe(process.stdout),(s=r.stderr)==null||s.pipe(process.stderr),r}var ra,ia,aa,ir=g(()=>{"use strict";l();ra=require("child_process");rr();ia=require("path"),aa=require("fs");Ie();i(Js,"getStdio");i(wn,"createAppProcess")});function Ys(n,e,t){let o=n.flattenDiagnosticMessageText(e.messageText,`
14
+ `,t=(0,we.join)(process.cwd(),"node_modules","commandkit-types");if(!(0,Ei.existsSync)(t))return;let o=(0,we.join)(t,"command.d.ts");await(0,Me.writeFile)(o,e,{encoding:"utf-8"})}var Me,we,Ei,Bt=g(()=>{"use strict";l();Me=require("fs/promises"),we=require("path");ve();Ei=require("fs");i(ot,"generateTypesPackage");i(wi,"rewriteCommandDeclaration")});var N,ks,Ts,jo,Ot,Ho=g(()=>{"use strict";l();N=require("discord.js");Io();Do();ke();ko();fe();vi();ve();Bt();ye();ks={command:i(n=>n instanceof N.SlashCommandBuilder||n instanceof N.ContextMenuCommandBuilder||n&&typeof n=="object","command"),chatInput:i(n=>typeof n=="function","chatInput"),autocomplete:i(n=>typeof n=="function","autocomplete"),message:i(n=>typeof n=="function","message"),messageContextMenu:i(n=>typeof n=="function","messageContextMenu"),userContextMenu:i(n=>typeof n=="function","userContextMenu")},Ts={beforeExecute:i(n=>typeof n=="function","beforeExecute"),afterExecute:i(n=>typeof n=="function","afterExecute")},jo=class jo{constructor(e){this.commandkit=e;this.registrar=new Kt(this.commandkit)}loadedCommands=new N.Collection;loadedMiddlewares=new N.Collection;commandNameToId=new Map;subcommandPathToId=new Map;registrar;onInteraction=null;onMessageCreate=null;commandRunner=new ln(this);externalCommandData=new N.Collection;externalMiddlewareData=new N.Collection;printBanner(){let e=crypto.randomUUID(),t=this.getCommandsArray().reduce((u,d)=>{let p=d.command.category||e;return u[p]=u[p]||[],u[p].push(d),u},{});console.log(C.green(`Loaded ${C.magenta(this.loadedCommands.size.toString())} commands:`));let o=Object.keys(t).sort(),r={};o.forEach(u=>{if(u!==e&&u.includes(":")){let d=u.split(":"),p=null;for(let b=d.length-1;b>0;b--){let y=d.slice(0,b).join(":");if(o.includes(y)){p=y;break}}p&&(r[p]=r[p]||[],r[p].push(u))}});let a=new Set,s=i((u,d="",p=!1,b="")=>{if(a.has(u))return;a.add(u);let y=t[u],E=r[u]&&r[u].length>0,S=p?"\u2514\u2500":"\u251C\u2500",P=b+(p?" ":"\u2502 ");if(u!==e){let w=u.includes(":")?u.split(":").pop():u;console.log(C.cyan(`${d}${S} ${C.bold(w)}`))}if(y.forEach((w,K)=>{let st=K===y.length-1&&!E?"\u2514\u2500":"\u251C\u2500",Fa=u!==e?P:d,Na=w.data.command.name,Ua=w.command.middlewares.length>0?C.magenta(" (\u03BB)"):"";console.log(`${C.green(`${Fa}${st}`)} ${C.yellow(Na)}${Ua}`)}),E){let w=r[u].sort();w.forEach((K,De)=>{let st=De===w.length-1;s(K,P,st,P)})}},"printCategory"),m=o.filter(u=>{if(u===e)return!0;if(u.includes(":")){let d=u.split(":");for(let p=1;p<d.length;p++){let b=d.slice(0,p).join(":");if(o.includes(b))return!1}return!0}return!0}).sort();m.forEach((u,d)=>{let p=d===m.length-1;s(u,"",p)})}getCommandsArray(){return Array.from(this.loadedCommands.values())}registerCommandHandler(){this.onInteraction??=async e=>{if(await this.commandkit.plugins.execute(async(a,s)=>s.onBeforeInteraction(a,e))||!(e.isCommand()||e.isAutocomplete()||e.isUserContextMenuCommand()||e.isMessageContextMenuCommand()))return;let r=await this.prepareCommandRun(e);if(r)return this.commandRunner.runCommand(r,e)},this.onMessageCreate??=async e=>{if(await this.commandkit.plugins.execute(async(r,a)=>a.onBeforeMessageCommand(r,e))||e.author.bot)return;let o=await this.prepareCommandRun(e);if(o)return this.commandRunner.runCommand(o,e)},this.commandkit.client.on(N.Events.InteractionCreate,this.onInteraction),this.commandkit.client.on(N.Events.MessageCreate,this.onMessageCreate)}async prepareCommandRun(e,t){var m;let o;if(!t)if(e instanceof N.Message){if(e.author.bot)return null;let u=await this.commandkit.config.getMessageCommandPrefix(e);o=new Rt(e,Array.isArray(u)?u:[u],d=>{var E,S;let p=this.commandNameToId.get(d);if(!p)return null;let b=this.loadedCommands.get(p);return!b||e.guildId&&((E=b.guilds)!=null&&E.length)&&!b.guilds.includes(e.guildId)?null:((S=("toJSON"in b.data.command?b.data.command.toJSON():b.data.command).options)==null?void 0:S.reduce((P,w)=>(P[w.name]=w.type,P),{}))??{}});try{t=o.getFullCommand().split(" ")[0]}catch(d){return ee(d,k.InvalidCommandPrefix)||M.error(d),null}}else{if(!(e.isChatInputCommand()||e.isAutocomplete()||e.isContextMenuCommand()))return null;t=e.commandName}let r=this.commandNameToId.get(t);if(!r)return null;let a=this.loadedCommands.get(r);if(!a||(e instanceof N.CommandInteraction||e instanceof N.AutocompleteInteraction)&&e.guildId&&((m=a.guilds)!=null&&m.length)&&!a.guilds.includes(e.guildId))return null;let s=[];for(let u of a.command.middlewares){let d=this.loadedMiddlewares.get(u);d&&s.push(d)}return{command:a,middlewares:s,messageCommandParser:o}}async reloadCommands(){this.loadedCommands.clear(),this.loadedMiddlewares.clear(),this.commandNameToId.clear(),this.subcommandPathToId.clear(),this.externalCommandData.clear(),this.externalMiddlewareData.clear(),await this.loadCommands()}async addExternalMiddleware(e){for(let t of e)t.id&&this.externalMiddlewareData.set(t.id,t)}async addExternalCommands(e){for(let t of e)t.id&&this.externalCommandData.set(t.id,t)}async registerExternalLoadedMiddleware(e){for(let t of e)this.loadedMiddlewares.set(t.middleware.id,t)}async registerExternalLoadedCommands(e){for(let t of e)this.loadedCommands.set(t.command.id,t),this.commandNameToId.set(t.command.name,t.command.id)}async loadCommands(){await this.commandkit.plugins.execute((s,m)=>m.onBeforeCommandsLoad(s));let e=this.commandkit.commandsRouter;if(!e)throw new Error("Commands router has not yet initialized");let{commands:t,middlewares:o}=e.getData(),r=this.externalCommandData.size?t.concat(this.externalCommandData):t,a=this.externalMiddlewareData.size?o.concat(this.externalMiddlewareData):o;for(let[s,m]of a)await this.loadMiddleware(s,m);for(let[s,m]of r)await this.loadCommand(s,m);W&&await wi(`type CommandTypeData = ${Array.from(this.loadedCommands.mapValues(s=>JSON.stringify(s.command.name)).values()).join(" | ")}`),await this.commandkit.plugins.execute((s,m)=>m.onAfterCommandsLoad(s))}async loadMiddleware(e,t){try{let o=await import(`${Pt(t.path)}?t=${Date.now()}`),r=0;for(let[a,s]of Object.entries(Ts)){if(o[a]&&!await s(o[a]))throw new Error(`Invalid export for middleware ${e}: ${a} does not match expected value`);o[a]&&r++}if(r===0)throw new Error(`Invalid export for middleware ${e}: at least one handler function must be provided`);this.loadedMiddlewares.set(e,{middleware:t,data:o})}catch(o){M.error(`Failed to load middleware ${e}`,o)}}async loadCommand(e,t){try{if(t.path===null){this.loadedCommands.set(e,{command:t,data:{command:{name:t.name,description:`${t.name} commands`,type:1}}});return}let o=await import(`${Pt(t.path)}?t=${Date.now()}`);if(!o.command)throw new Error(`Invalid export for command ${t.name}: no command definition found`);let r=0;for(let[s,m]of Object.entries(ks))if(s!=="command"&&o[s]&&r++,o[s]&&!await m(o[s]))throw new Error(`Invalid export for command ${t.name}: ${s} does not match expected value`);if(r===0)throw new Error(`Invalid export for command ${t.name}: at least one handler function must be provided`);let a=o.command;await this.commandkit.plugins.execute(async(s,m)=>{let u=await m.prepareCommand(s,a);u&&(a=u)}),this.loadedCommands.set(e,{command:t,guilds:o.guilds,data:{...o,command:"toJSON"in a?a.toJSON():a}}),this.commandNameToId.set(t.name,e)}catch(o){M.error(`Failed to load command ${t.name} (${e})`,o)}}};i(jo,"AppCommandHandler");Ot=jo});var Go,Ii,_o,J,As,Mi,Si,Bs,Os,Vo,Lt,Pi=g(()=>{"use strict";l();Go=require("discord.js"),Ii=require("fs"),_o=require("fs/promises"),J=require("path"),As=/^\+middleware\.(m|c)?(j|t)sx?$/,Mi=/^\+([^+().][^().]*)\.middleware\.(m|c)?(j|t)sx?$/,Si=/^\+global-middleware\.(m|c)?(j|t)sx?$/,Bs=/^([^+().][^().]*)\.(m|c)?(j|t)sx?$/,Os=/^\(.+\)$/,Vo=class Vo{constructor(e){this.options=e}commands=new Go.Collection;middlewares=new Go.Collection;populate(e){for(let[t,o]of Object.entries(e.commands))this.commands.set(t,o);for(let[t,o]of Object.entries(e.middlewares))this.middlewares.set(t,o)}isValidPath(){return(0,Ii.existsSync)(this.options.entrypoint)}isCommand(e){return Bs.test(e)}isMiddleware(e){return As.test(e)||Si.test(e)||Mi.test(e)}isCategory(e){return Os.test(e)}clear(){this.commands.clear(),this.middlewares.clear()}async scan(){let e=await(0,_o.readdir)(this.options.entrypoint,{withFileTypes:!0});for(let t of e){if(t.name.startsWith("_"))continue;let o=(0,J.join)(this.options.entrypoint,t.name);if(t.isDirectory()){let r=this.isCategory(t.name)?t.name.slice(1,-1):null;await this.traverse(o,r)}else await this.handle(t)}return await this.applyMiddlewares(),this.toJSON()}getData(){return{commands:this.commands,middlewares:this.middlewares}}toJSON(){return{commands:Object.fromEntries(this.commands.entries()),middlewares:Object.fromEntries(this.middlewares.entries())}}async traverse(e,t){let o=await(0,_o.readdir)(e,{withFileTypes:!0});for(let r of o)if(!r.name.startsWith("_")){if(r.isFile())(this.isCommand(r.name)||this.isMiddleware(r.name))&&await this.handle(r,t);else if(r.isDirectory()&&this.isCategory(r.name)&&t){let a=this.isCategory(r.name)?`${t}:${r.name.slice(1,-1)}`:null;await this.traverse((0,J.join)(e,r.name),a)}}}async handle(e,t=null){let o=e.name,r=(0,J.join)(e.parentPath,e.name);if(this.isCommand(o)){let a={id:crypto.randomUUID(),name:(0,J.basename)(r,(0,J.extname)(r)),path:r,category:t,parentPath:e.parentPath,relativePath:this.replaceEntrypoint(r),middlewares:[]};this.commands.set(a.id,a)}else if(this.isMiddleware(o)){let a={id:crypto.randomUUID(),name:(0,J.basename)(r,(0,J.extname)(r)),path:r,relativePath:this.replaceEntrypoint(r),parentPath:e.parentPath,global:Si.test(o),command:Mi.test(o)&&o.split(".")[0]||null};this.middlewares.set(a.id,a)}}applyMiddlewares(){this.commands.forEach(e=>{let t=e.parentPath,o=Array.from(this.middlewares.values()).filter(r=>r.global?!0:r.command?r.command===e.name:r.parentPath===t).map(r=>r.id);e.middlewares=Array.from(new Set([...e.middlewares,...o]))})}replaceEntrypoint(e){return(0,J.normalize)(e).replace(this.options.entrypoint,"")}};i(Vo,"CommandsRouter");Lt=Vo});var Ri,Di,Wo,mn,qo,$t,Ki=g(()=>{"use strict";l();Ri=require("discord.js"),Di=require("fs"),Wo=require("fs/promises"),mn=require("path"),qo=class qo{constructor(e){this.options=e;var t;if(e.entrypoints&&(e.entrypoints=Array.from(new Set(e.entrypoints))),!((t=e.entrypoints)!=null&&t.length))throw new Error("Entrypoint directory must be provided")}events=new Ri.Collection;addEntrypoints(e){this.options.entrypoints=Array.from(new Set([...this.options.entrypoints,...e]))}match(e){return this.events.get(e)??null}get entrypoints(){return this.options.entrypoints}isValidPath(){return this.entrypoints.every(e=>(0,Di.existsSync)(e))}clear(){this.events.clear()}async reload(){return this.clear(),this.scan()}async scan(){for(let e of this.entrypoints){let t=await(0,Wo.readdir)(e,{withFileTypes:!0});for(let o of t)if(o.isDirectory()){let r=(0,mn.join)(e,o.name);await this.scanEvent(o.name,r,null,[],!0)}}return Object.fromEntries(this.events)}toJSON(){return Object.fromEntries(this.events)}async scanEvent(e,t,o=null,r=[],a=!1){let s=await(0,Wo.readdir)(t,{withFileTypes:!0}),m=a&&/^\(.+\)$/.test(e),u=m?e.slice(1,-1):o??null;s.sort((d,p)=>d.name.localeCompare(p.name));for(let d of s)if(!d.name.startsWith("_")){if(d.isDirectory()){let p=(0,mn.join)(t,d.name);await this.scanEvent(d.name,p,u,r);continue}d.isFile()&&/\.(m|c)?(j|t)sx?$/.test(d.name)&&r.push((0,mn.join)(d.parentPath,d.name))}if(!m){let d=this.events.get(e);if(d){d.listeners=Array.from(new Set([...d.listeners,...r]));return}this.events.set(e,{event:e,path:t,listeners:r,namespace:u})}}};i(qo,"EventsRouter");$t=qo});var Jo=g(()=>{"use strict";l();Pi();Ki()});var ki,zo,un,Ti=g(()=>{"use strict";l();ki=require("discord.js");fe();Io();It();Mt();zo=class zo{constructor(e){this.commandkit=e}loadedEvents=new ki.Collection;getEvents(){return this.loadedEvents.size===0?[]:this.loadedEvents.toJSON().map(t=>({name:t.name,namespace:t.namespace,onceListeners:t.listeners.filter(o=>o.once).length,regularListeners:t.listeners.filter(o=>!o.once).length,metadata:t.event}))}async reloadEvents(){this.unregisterAll(),await this.loadEvents()}async loadEvents(){await this.commandkit.plugins.execute((o,r)=>r.onBeforeEventsLoad(o));let t=await this.commandkit.eventsRouter.scan();for(let o of Object.values(t)){let r=[];for(let m of o.listeners){let u=await import(Pt(m,!0));(!u.default||typeof u.default!="function")&&M.error(`Event handler for ${o.event}${o.namespace?` of namespace ${o.namespace}`:""} does not have a default export or is not a function`),r.push({handler:u.default,once:!!u.once})}let a=r.length;a||M.warn(`Event ${o.event}${o.namespace?` of namespace ${o.namespace}`:""} does not have any listeners`);let s=`${o.namespace?`${o.namespace}:`:""}${o.event}`;this.loadedEvents.set(s,{name:o.event,namespace:o.namespace,event:o,listeners:r}),M.info(`\u2728 Loaded event ${o.event}${o.namespace?` of namespace ${o.namespace}`:""} with ${a} listener${a===1?"":"s"}`)}this.registerAllClientEvents(),await this.commandkit.plugins.execute((o,r)=>r.onAfterEventsLoad(o))}unregisterAll(){this.unregisterAllClientListeners(),this.loadedEvents.clear()}registerAllClientEvents(){let e=this.commandkit.client;for(let[t,o]of this.loadedEvents.entries()){let{name:r,listeners:a,namespace:s}=o,m=a.filter(y=>y.once),u=a.filter(y=>!y.once),d=new Set,p=i(async(...y)=>{let E=!1,S={name:r,args:y,namespace:s??null,once:!1,metadata:o.event,accept(){E||(E=!0)}};await this.commandkit.plugins.execute(async(P,w)=>{var K;if(!E)return(K=w.willEmitEvent)==null?void 0:K.call(w,P,S)}).catch(Object),await tn({event:r,namespace:s??null,data:o.event,commandkit:this.commandkit,arguments:y},async()=>{for(let P of u)try{await P.handler(...y)}catch(w){if(w instanceof Ee){M.debug(`Event propagation stopped for ${r}${s?` of namespace ${s}`:""}`);break}M.error(`Error handling event ${r}${s?` of namespace ${s}`:""}`,w)}})},"mainHandler"),b=i(async(...y)=>{let E=!1,S=!1,P={name:r,args:y,namespace:s??null,once:!0,metadata:o.event,accept(){S||(S=!0)}};await this.commandkit.plugins.execute(async(w,K)=>{var De;if(!S)return(De=K.willEmitEvent)==null?void 0:De.call(K,w,P)}).catch(Object);for(let w of m){if(E)break;await tn({event:r,namespace:s??null,data:o.event,commandkit:this.commandkit,arguments:y},async()=>{try{if(d.has(w.handler))return;await w.handler(...y),d.add(w.handler)}catch(K){K instanceof Ee&&(M.debug(`Event propagation stopped for ${r}${s?` of namespace ${s}`:""}`),E=!0),M.error(`Error handling event ${r}${s?` of namespace ${s}`:""}`,K)}})}d.size===m.length&&u.length===0&&(this.loadedEvents.delete(t),M.info(`\u{1F9F9} Cleaned up completed once-only event ${r}${s?` of namespace ${s}`:""}`))},"onceHandler");this.loadedEvents.set(t,{...o,mainListener:u.length>0?{handler:p,once:!1}:void 0,executedOnceListeners:d}),s?(u.length>0&&this.commandkit.events.on(s,r,p),m.length>0&&this.commandkit.events.once(s,r,b)):(u.length>0&&e.on(r,p),m.length>0&&e.once(r,b)),M.info(`\u{1F50C} Registered event ${r}${s?` of namespace ${s}`:""} (${u.length} regular, ${m.length} once-only)`)}}unregisterAllClientListeners(){let e=this.commandkit.client;for(let[t,{name:o,mainListener:r,namespace:a}]of this.loadedEvents.entries())r?a?this.commandkit.events.off(a,o,r.handler):e.off(o,r.handler):a?this.commandkit.events.removeAllListeners(a,o):e.removeAllListeners(o),this.loadedEvents.delete(t),M.info(`\u{1F5D1}\uFE0F Unregistered event ${o}${a?` of namespace ${a}`:""}`)}};i(zo,"AppEventsHandler");un=zo});function $s(n){process.stdout.write(n),process.stdout.write(`
15
+ `)}function dn(n){let e=(0,ge.join)(n,"sharding-manager.js");return Z.default.existsSync(e)?e:(0,ge.join)(n,"index.js")}function Se(n){$s(C.red(`Error: ${n}`)),process.exit(1)}async function Fs(n){return/\.(c|m)?tsx?$/.test(n)?(process.features.typescript||await Yo(),!0):!1}function Ns(){if(rt)return rt;let n={"yarn.lock":"yarn","pnpm-lock.yaml":"pnpm","package-lock.json":"npm","bun.lock":"bun","bun.lockb":"bun"};for(let[e,t]of Object.entries(n))if(Z.default.existsSync((0,ge.join)(process.cwd(),e))){rt=t;break}return rt||(rt="npm"),rt}async function Yo(n){if(Q)return Q;try{Q=await import("typescript")}catch(e){if(e instanceof Error&&"code"in e&&e.code==="MODULE_NOT_FOUND")try{let t=Ns();return(0,Ai.execSync)(`${t} add typescript`,{stdio:"inherit",cwd:process.cwd()}),console.log(C.cyan("TypeScript has been installed automatically, restarting...")),Q=await import("typescript"),Q}catch{Se("TypeScript is not installed and could not be installed automatically. Please install it manually.")}Se(e||"TypeScript must be installed to use TypeScript config files.")}return Q}async function Bi(n){await Us(n);let e=await Fs(n),t;if(e&&Q){let{transpileModule:r}=Q,a=Z.default.readFileSync(n,"utf8"),{outputText:s}=r(a,{compilerOptions:{module:Q.ModuleKind.ESNext,target:Q.ScriptTarget.ESNext,moduleResolution:Q.ModuleResolutionKind.NodeNext},fileName:n});await ot();let m=process.cwd(),u=(0,ge.join)(m,"compiled-commandkit.config.mjs");Z.default.writeFileSync(u,s),t=u,n=u}let o=await import(`file://${n}`).then(r=>r.default||r);if(t)try{Z.default.unlinkSync(t)}catch{}return o}async function Us(n){if(!Z.default.existsSync(n))throw new Error(`File not found: ${n}`)}async function Oi(n,e){let t=(0,ge.join)(process.cwd(),n),o=(0,ge.join)(process.cwd(),e),r=["app/locales"],a=r.map(m=>(0,ge.join)(t,m)),s=r.map(m=>(0,ge.join)(o,m));for(let m of a){if(!Z.default.existsSync(m))continue;let u=s[a.indexOf(m)];Z.default.existsSync(u)||Z.default.promises.mkdir(u,{recursive:!0}),await Z.default.promises.cp(m,u,{recursive:!0,force:!0})}}var Ls,ge,Z,Ai,Q,rt,Ie=g(()=>{"use strict";l();Ls=require("rimraf"),ge=require("path"),Z=q(require("fs"));ye();Bt();Ai=require("child_process");i($s,"write");i(dn,"findEntrypoint");i(Se,"panic");i(Fs,"ensureTypeScript");i(Ns,"detectPackageManager");i(Yo,"loadTypeScript");i(Bi,"loadConfigFileFromPath");i(Us,"ensureExists");i(Oi,"copyLocaleFiles")});function Qo(n){return js.map(e=>(0,$i.join)(n,e))}function Hs(n){let e=Qo(n);for(let t of e)if((0,Li.existsSync)(t))return{path:t,isTypeScript:/\.ts$/.test(t)};return null}async function Ce(n=process.cwd()){if(Xo)return Xo;let e=Hs(n);if(!e)return qe();let t=await Bi(e.path);return Xo=t,t}var Li,$i,js,Xo,Ft=g(()=>{"use strict";l();Li=require("fs"),$i=require("path");Ie();en();js=["commandkit.config.js","commandkit.config.mjs","commandkit.config.cjs","commandkit.config.ts"];i(Qo,"getPossibleConfigPaths");i(Hs,"findConfigFile");Xo=null;i(Ce,"loadConfigFile")});function Fi(n){W&&process.on("message",async e=>{if(typeof e!="object"||e===null)return;let{event:t,path:o,id:r}=e;if(!t)return;process.env.COMMANDKIT_DEBUG_HMR==="true"&&M.info(`Received HMR event: ${t}${o?` for ${o}`:""}`);let a=!1,s=!1,m=!1,u={accept(){a=!0},preventDefault(){s=!0},path:o,event:t};try{if(await n.plugins.execute(async(d,p)=>{var b;a||await((b=p.performHMR)==null?void 0:b.call(p,d,u))}),s)return;switch(t){case Y.ReloadCommands:n.commandHandler.reloadCommands(),m=!0;break;case Y.ReloadEvents:n.eventHandler.reloadEvents(),m=!0;break;case Y.Unknown:m=!1;break;default:break}}finally{r&&process.send&&process.send({type:"commandkit-hmr-ack",id:r,handled:m||a})}})}var Ni=g(()=>{"use strict";l();fe();ve();i(Fi,"registerDevHooks")});var Ui,Zo,pn,ji=g(()=>{"use strict";l();Ui=q(require("events")),Zo=class Zo{constructor(e){this.commandkit=e}emitter=new Ui.default;to(e){return{on:this.on.bind(this,e),off:this.off.bind(this,e),once:this.once.bind(this,e),emit:this.emit.bind(this,e),removeAllListeners:this.removeAllListeners.bind(this,e)}}on(e,t,o){this.emitter.on(`${e}:${t}`,o)}off(e,t,o){this.emitter.off(`${e}:${t}`,o)}once(e,t,o){this.emitter.once(`${e}:${t}`,o)}emit(e,t,...o){return this.emitter.emit(`${e}:${t}`,...o)}removeAllListeners(e,t){t?this.emitter.removeAllListeners(`${e}:${t}`):this.emitter.removeAllListeners(e)}};i(Zo,"CommandKitEventsChannel");pn=Zo});var Hi,er,fn,Gi=g(()=>{"use strict";l();Hi=require("discord.js"),er=class er extends Hi.Collection{};i(er,"FlagStore");fn=er});function Gs(n){hn.add(n)}function _s(n){gn.add(n)}var _i,Cn,tr,Vi,Wi,hn,gn,it,z,qi,Ji,zi,Yi,Xi,ne,Te,jt=g(()=>{"use strict";l();_i=q(require("events"));ye();io();ro();Cn=require("discord.js");It();tr=require("path");Ho();Jo();Ti();go();Ft();ve();Ni();Vi=require("fs");ji();he();Bt();fe();Gi();hn=new Set,gn=new Set;i(Gs,"onBootstrap");i(_s,"onApplicationBootstrap");ne=class ne extends _i.default{constructor(t){if(ne.instance&&process.emitWarning("CommandKit instance already exists. Having multiple instance in same project is discouraged and it may lead to unexpected behavior.",{code:"MultiInstanceWarning"}),!t.client)throw new Error(C.red('"client" is required when instantiating CommandKit.'));super();this.options=t;x(this,z);x(this,it,!1);I(this,"eventInterceptor");I(this,"config",{defaultLocale:Cn.Locale.EnglishUS,getMessageCommandPrefix:i(()=>"!","getMessageCommandPrefix")});I(this,"store",new Map);I(this,"flags",new fn);I(this,"commandsRouter");I(this,"eventsRouter");I(this,"commandHandler",new Ot(this));I(this,"eventHandler",new un(this));I(this,"plugins");I(this,"events",new pn(this));this.plugins=new Et(this),ne.instance||(ne.instance=this),Wi=ne.instance,v(this,z,qi).call(this)}async start(t){if(!c(this,it)){if(!this.options.client)throw new Error(C.red('"client" is required when starting CommandKit.'));if(this.eventInterceptor=new xt(this.client),W)try{Fi(this),await ot()}catch(o){process.env.COMMANDKIT_DEBUG_TYPEGEN&&M.error(o)}if(await this.loadPlugins(),await v(this,z,zi).call(this),this.commandHandler.registerCommandHandler(),this.incrementClientListenersCount(),t!==!1&&!this.options.client.isReady()){this.client.once(Cn.Events.ClientReady,async()=>{await this.commandHandler.registrar.register()}),await this.plugins.execute((r,a)=>{var s;return(s=a.onBeforeClientLogin)==null?void 0:s.call(a,r)});let o=t??this.options.client.token??process.env.TOKEN??process.env.DISCORD_TOKEN;await this.options.client.login(o),await this.plugins.execute((r,a)=>{var s;return(s=a.onAfterClientLogin)==null?void 0:s.call(a,r)})}else this.options.client.isReady()&&await this.commandHandler.registrar.register();h(this,it,!0),await v(this,z,Ji).call(this)}}async loadPlugins(){let o=(await Ce()).plugins.flat(2).filter(r=>mo(r));if(o.length)for(let r of o)await this.plugins.softRegisterPlugin(r)}get started(){return c(this,it)}setPrefixResolver(t){return this.config.getMessageCommandPrefix=t,this}setDefaultLocale(t){return this.config.defaultLocale=t,this}get client(){return this.options.client}async reloadCommands(){await this.commandHandler.reloadCommands()}async reloadEvents(){await this.eventHandler.reloadEvents()}incrementClientListenersCount(){this.options.client.setMaxListeners(this.options.client.getMaxListeners()+1)}decrementClientListenersCount(){this.options.client.setMaxListeners(this.options.client.getMaxListeners()-1)}getAppDirectory(){return hi()}getPath(t){let o=this.getAppDirectory();if(!o)return null;switch(t){case"commands":return(0,tr.join)(o,"commands");case"events":return(0,tr.join)(o,"events");default:return t}}};it=new WeakMap,z=new WeakSet,qi=i(async function(){for(let t of hn)try{await t(this)}catch(o){M.error("Error while executing bootstrap hook: ",o)}finally{hn.delete(t)}hn.clear()},"#bootstrapHooks"),Ji=i(async function(){for(let t of gn)try{await t(this)}catch(o){M.error("Error while executing application bootstrap hook: ",o)}finally{gn.delete(t)}gn.clear()},"#applicationBootstrapHooks"),zi=i(async function(){if(!this.getAppDirectory())return;let o=this.getPath("commands"),r=this.getPath("events");this.commandsRouter=new Lt({entrypoint:o}),await this.plugins.execute((a,s)=>s.onCommandsRouterInit(a)),this.eventsRouter=new $t({entrypoints:[r]}),await this.plugins.execute((a,s)=>s.onEventsRouterInit(a)),await v(this,z,Xi).call(this),await v(this,z,Yi).call(this)},"#init"),Yi=i(async function(){if(this.commandsRouter.isValidPath()){let t=await this.commandsRouter.scan();W&&(0,Vi.writeFileSync)("./.commandkit/commands.json",JSON.stringify(t,null,2))}await this.commandHandler.loadCommands(),this.commandHandler.printBanner()},"#initCommands"),Xi=i(async function(){this.eventsRouter.isValidPath()&&await this.eventsRouter.scan(),await this.eventHandler.loadEvents()},"#initEvents"),i(ne,"CommandKit"),I(ne,"createElement",no),I(ne,"Fragment",to),I(ne,"instance");Te=ne});var ea={};Qe(ea,{version:()=>yn});var yn,xn=g(()=>{"use strict";l();yn="1.0.0-dev.20250529125116"});function vn(n=!1){let e={NODE_ENV:"development",COMMANDKIT_IS_DEV:"true"};return n?Object.assign({},e):Object.assign({},process.env,e)}function En(n=!1){let e={NODE_ENV:"production",COMMANDKIT_IS_DEV:"false"};return n?Object.assign({},e):Object.assign({},process.env,e)}var ta,Ws,qs,na,oa,rr=g(()=>{"use strict";l();i(vn,"DevEnv");i(En,"ProdEnv");ta=[".env",".env.local"],Ws=[".env.development",".env.development.local"],qs=[".env.production",".env.production.local"],na=[...ta,...Ws],oa=[...ta,...qs]});function Js(n){return n?["pipe","pipe","pipe","ipc"]:["pipe","pipe","pipe"]}function wn(n,e,t){var a,s;(0,aa.existsSync)((0,ia.join)(e,n))||Se(`Could not locate the entrypoint file: ${n}`);let o=Js(t),r=(0,ra.spawn)("node",[`--title="CommandKit ${t?"Development":"Production"}"`,"--enable-source-maps",n],{cwd:e,windowsHide:!0,env:t?vn():En(),stdio:o});return(a=r.stdout)==null||a.pipe(process.stdout),(s=r.stderr)==null||s.pipe(process.stderr),r}var ra,ia,aa,ir=g(()=>{"use strict";l();ra=require("child_process");rr();ia=require("path"),aa=require("fs");Ie();i(Js,"getStdio");i(wn,"createAppProcess")});function Ys(n,e,t){let o=n.flattenDiagnosticMessageText(e.messageText,`
16
16
  `);if(!e.file)return`${C.red("error")}: ${o}`;let{line:r,character:a}=n.getLineAndCharacterOfPosition(e.file,e.start),s=(0,Mn.relative)(t,e.file.fileName),m=`${r+1}:${a+1}`,u=e.code?`TS${e.code}`:"";return[`${C.bold(C.cyan(s))}:${C.bold(C.yellow(m))} - ${C.red("error")} ${C.gray(u)}`,`${o}`].join(`
17
17
  `)}async function la(n){let e=(0,Mn.join)(n,"tsconfig.json");if(!(0,sa.existsSync)(e))return;let t=await Yo(zs),o={getCanonicalFileName:i(u=>u,"getCanonicalFileName"),getCurrentDirectory:t.sys.getCurrentDirectory,getNewLine:i(()=>t.sys.newLine,"getNewLine")},r=t.readConfigFile(e,t.sys.readFile);r.error&&(console.error(C.red(`Error reading tsconfig.json: ${t.formatDiagnostic(r.error,o)}`)),process.exit(1));let a=t.parseJsonConfigFileContent(r.config,t.sys,n);a.options.noEmit=!0;let s=t.createProgram({rootNames:a.fileNames,options:a.options,projectReferences:a.projectReferences}),m=[...s.getOptionsDiagnostics(),...s.getGlobalDiagnostics(),...s.getSyntacticDiagnostics(),...s.getSemanticDiagnostics()];if(m.length>0){console.log(""),console.error(C.bold(C.red("Type checking failed with the following errors:"))),console.log("");let u=new Map;for(let b of m){let y=b.file?b.file.fileName:"Global";u.has(y)||u.set(y,[]),u.get(y).push(b)}let d=m.length,p=0;for(let[b,y]of u)for(let E of y)p++,console.log(Ys(t,E,n)),p<d&&console.log("");console.log(""),console.error(C.bold(C.red(`Found ${d} error${d>1?"s":""}`))),console.log(""),process.exit(1)}console.log(C.green("\u2713 Type checking completed successfully."))}var sa,Mn,zs,ca=g(()=>{"use strict";l();sa=require("fs");Ie();Mn=require("path");ye();zs="TypeScript must be installed in order to use the type checker. Please install it using `npm install typescript` or `yarn add typescript`";i(Ys,"formatDiagnostic");i(la,"performTypeCheck")});async function Sn({plugins:n,esbuildPlugins:e,isDev:t,configPath:o}){var m;let r=await Ce(o);!t&&!((m=r==null?void 0:r.typescript)!=null&&m.ignoreBuildErrors)&&await la(o||process.cwd());let a=new wt(n||[]),s=a.isEmpty()?[]:[a.toEsbuildPlugin()];e!=null&&e.length&&s.push(...e.map(Co));try{let u=t?".commandkit":r.distDir;await(0,ga.rimraf)(u),await(0,pa.build)({esbuildPlugins:s,watch:!1,banner:{js:t?"":"/* Optimized production build generated by commandkit */"},cjsInterop:!0,dts:!1,clean:!0,format:["esm"],shims:!0,keepNames:!0,minify:!1,esbuildOptions:i(d=>(d.jsx="automatic",d.jsxImportSource="commandkit",d),"esbuildOptions"),minifyIdentifiers:!1,minifySyntax:!1,silent:!!t,splitting:!0,skipNodeModulesBundle:!0,name:"CommandKit",sourcemap:!0,target:"node16",outDir:u,env:t?vn(!0):En(!0),entry:["src",`!${r.distDir}`,"!.commandkit","!**/*.test.*","!**/*.spec.*"]}),await Oi("src",u),await Qs(o||process.cwd(),!!t,r.distDir)}catch(u){console.error("Build failed:",u),u instanceof Error&&console.error("Error details:",u.stack),process.exit(1)}finally{await a.cleanup()}}async function Qs(n,e,t){let o=`/* Entrypoint File Generated By CommandKit */
18
18
  ${e?`