"use strict";var t=require("discord.js"),e=require("fs/promises"),r=require("url"),i=require("path"),n=require("fs"),s=null;function a(){if(null!==s)return s;const t=process.cwd();try{const e=JSON.parse(n.readFileSync(i.join(t,"package.json"),"utf8"));s=i.dirname(i.join(t,e.main))}catch{s=t}return s}async function o({directory:t,extFilter:n}){const s=a(),o=r.pathToFileURL(i.join(s,t));return{directoryPath:r.fileURLToPath(o),filteredFiles:(await e.readdir(o)).filter((t=>t.endsWith(`.${n}`)))}}var c=class extends t.Client{registry;commands;constructor(e){super(e),this.commands=new t.Collection,this.registry=new class{client;constructor(t){return this.client=t,this}async registerEvent(t,e){const r=this.createImportUrl(e,t).href,{AppEvent:i}=await import(r),n=new i(this.client);n.metadata.once?this.client.once(n.metadata.name,((...t)=>n.execute?.(...t))):this.client.on(n.metadata.name,((...t)=>n.execute?.(...t)))}async registerEvents(t){const{directoryPath:e,filteredFiles:r}=await o({directory:t,extFilter:"js"});for(const t of r)await this.registerEvent(t,e);return this}async registerCommand(t,e){const r=this.createImportUrl(e,t).href,{AppCommand:i}=await import(r),n=new i(this.client);void 0!==n.buildAppCommand?.()&&this.client.commands.set(n.buildAppCommand().name,n)}async registerCommands(t){const{directoryPath:e,filteredFiles:r}=await o({directory:t,extFilter:"js"});for(const t of r)await this.registerCommand(t,e);return this}createImportUrl(t,e){return r.pathToFileURL(i.join(t,e))}}(this)}};exports.Command=class{client;constructor(t){return this.client=t,this}},exports.Event=class{client;metadata;constructor(t,{name:e,once:r}){return this.client=t,this.metadata={name:e,once:r},this}},exports.NexClient=c,exports.getRootPath=a,exports.readDirectory=o;//# sourceMappingURL=index.cjs.map