@arox/framework 0.1.2-beta.2 → 0.1.3

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.
@@ -0,0 +1 @@
1
+ export declare const MAX_EXPORT_FACTORY_DEPTH = 16;
package/dist/index.cjs CHANGED
@@ -1,3 +1,3 @@
1
- "use strict";var bt=Object.create;var D=Object.defineProperty;var Mt=Object.getOwnPropertyDescriptor;var Ct=Object.getOwnPropertyNames;var xt=Object.getPrototypeOf,yt=Object.prototype.hasOwnProperty;var l=(e,t)=>()=>(e&&(t=e(e=0)),t);var B=(e,t)=>{for(var r in t)D(e,r,{get:t[r],enumerable:!0})},z=(e,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of Ct(t))!yt.call(e,s)&&s!==r&&D(e,s,{get:()=>t[s],enumerable:!(i=Mt(t,s))||i.enumerable});return e};var I=(e,t,r)=>(r=e!=null?bt(xt(e)):{},z(t||!e||!e.__esModule?D(r,"default",{value:e,enumerable:!0}):r,e)),At=e=>z(D({},"__esModule",{value:!0}),e);function _(e,t=15e3){return new Promise(r=>{setTimeout(()=>{e.delete().catch(()=>{}),r()},t)})}function N(e){if(e&&Dt.has(e))return e}function $(e){return e.isInteraction()?N(e.data.locale)??N(e.data.guildLocale)??O.Locale.EnglishUS:e.isMessage()?N(e.data.guild?.preferredLocale)??O.Locale.EnglishUS:O.Locale.EnglishUS}var O,V,Dt,H=l(()=>{"use strict";O=require("discord.js"),V=["id","en-US","en-GB","bg","zh-CN","zh-TW","hr","cs","da","nl","fi","fr","de","el","hi","hu","it","ja","ko","lt","no","pl","pt-BR","ro","ru","es-ES","es-419","sv-SE","th","tr","uk","vi"],Dt=new Set(V)});function v(e){return K.default.sync(["**/*.ts","**/*.js","**/*.cjs","**/*.mjs"],{cwd:e,absolute:!0,ignore:["**/*.d.ts","node_modules/**",".git/**","dist/**","lib/**","out/**","build/**",".next/**","coverage/**"]})}function k(){let e=[];e.push(m.default.resolve(process.cwd()));let t=typeof require<"u"?require.main?.filename:void 0;t&&e.push(m.default.dirname(m.default.resolve(t))),typeof module<"u"&&module.parent?.filename&&e.push(m.default.dirname(m.default.resolve(module.parent.filename)));for(let r of e){let i=Bt(r);if(i)return i}return e[0]}function Bt(e){let t=m.default.resolve(e);for(;;){let r=m.default.join(t,"package.json");if((0,q.existsSync)(r))return m.default.normalize(t);let i=m.default.dirname(t);if(i===t)return null;t=i}}var K,q,m,X=l(()=>{"use strict";K=I(require("fast-glob"),1),q=require("node:fs"),m=I(require("path"),1)});var n,U=l(()=>{"use strict";n=(function(e){return e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.None=100]="None",e})({})});var Q,Z,a,L,w,y,R,g,Jt,It,Ot,Nt,A,j=l(()=>{"use strict";Q=require("console"),Z=require("util"),a=I(require("colorette"),1),L=require("@sapphire/timestamp");U();U();w=class e{level;formats;join;depth;console;static instance=null;static LOG_METHODS=new Map([[n.Trace,"trace"],[n.Debug,"debug"],[n.Info,"info"],[n.Warn,"warn"],[n.Error,"error"],[n.Fatal,"error"]]);static DEFAULT_COLORS=new Map([[n.Trace,a.gray],[n.Debug,a.magenta],[n.Info,a.cyan],[n.Warn,a.yellow],[n.Error,a.red],[n.Fatal,a.bgRed],[n.None,a.white]]);static DEFAULT_NAMES=new Map([[n.Trace,"TRACE"],[n.Debug,"DEBUG"],[n.Info,"INFO"],[n.Warn,"WARN"],[n.Error,"ERROR"],[n.Fatal,"FATAL"],[n.None,""]]);constructor(t={}){this.level=t.level??n.Info,this.console=new Q.Console(t.stdout??process.stdout,t.stderr??process.stderr),this.formats=this.createFormatMap(t.format,t.defaultFormat??t.format?.none??{}),this.join=t.join??" ",this.depth=t.depth??2}static getInstance(){return this.instance||(this.instance=new e),this.instance}static get stylize(){return a.isColorSupported}setLevel(t){this.level=t}has(t){return t>=this.level}trace(...t){this.write(n.Trace,...t)}debug(...t){this.write(n.Debug,...t)}info(...t){this.write(n.Info,...t)}log(...t){this.write(n.Info,...t)}warn(...t){this.write(n.Warn,...t)}error(...t){this.write(n.Error,...t)}fatal(...t){this.write(n.Fatal,...t)}write(t,...r){if(t<this.level)return;let i=e.LOG_METHODS.get(t),o=(this.formats.get(t)??this.formats.get(n.None)).run(this.preprocess(r));switch(i){case"trace":this.console.trace(o);break;case"debug":this.console.debug(o);break;case"info":this.console.info(o);break;case"warn":this.console.warn(o);break;case"error":this.console.error(o);break;default:this.console.log(o)}}preprocess(t){let r={colors:a.isColorSupported,depth:this.depth};return t.map(i=>typeof i=="string"?i:(0,Z.inspect)(i,r)).join(this.join)}createFormatMap(t={},r){let i=new Map;for(let[s,o]of e.DEFAULT_COLORS){let h=e.DEFAULT_NAMES.get(s),c=t[this.getLevelKey(s)]??this.createDefaultLevel(r,o,h??"");i.set(s,c instanceof g?c:new g(c))}return i}createDefaultLevel(t,r,i){return new g({...t,timestamp:t.timestamp===null?null:{...t.timestamp,color:r},infix:i.length?`${r(i.padEnd(5," "))} `:""})}getLevelKey(t){return{[n.Trace]:"trace",[n.Debug]:"debug",[n.Info]:"info",[n.Warn]:"warn",[n.Error]:"error",[n.Fatal]:"fatal",[n.None]:"none"}[t]}},y=class{style;constructor(t={}){if(typeof t=="function")this.style=t;else{let r=this.buildStyleArray(t);this.style=this.combineStyles(r)}}run(t){return this.style(String(t))}buildStyleArray(t){let r=[];return t.effects&&r.push(...t.effects.map(i=>a[i])),t.text&&r.push(a[t.text]),t.background&&r.push(a[t.background]),r}combineStyles(t){return t.length===0?a.reset:t.length===1?t[0]:(r=>t.reduce((i,s)=>s(i),r))}},R=class{timestamp;utc;color;formatter;constructor(t={}){this.timestamp=new L.Timestamp(t.pattern??"YYYY-MM-DD HH:mm:ss"),this.utc=t.utc??!1,this.color=t.color===null?null:new y(t.color),this.formatter=t.formatter??(r=>`${r} `)}run(){let t=new Date,r=this.utc?this.timestamp.displayUTC(t):this.timestamp.display(t);return this.formatter(this.color?this.color.run(r):r)}},g=class{timestamp;infix;message;constructor(t={}){this.timestamp=t.timestamp===null?null:new R(t.timestamp),this.infix=t.infix??"",this.message=t.message===null?null:new y(t.message)}run(t){let r=(this.timestamp?.run()??"")+this.infix;if(r.length){let i=this.message?s=>r+this.message?.run(s):s=>r+s;return t.split(`
2
- `).map(i).join(`
3
- `)}return this.message?this.message.run(t):t}},Jt=w.getInstance(),It=(function(e){return e.Reset="reset",e.Bold="bold",e.Dim="dim",e.Italic="italic",e.Underline="underline",e.Inverse="inverse",e.Hidden="hidden",e.Strikethrough="strikethrough",e})({}),Ot=(function(e){return e.Black="black",e.Red="red",e.Green="green",e.Yellow="yellow",e.Blue="blue",e.Magenta="magenta",e.Cyan="cyan",e.White="white",e.Gray="gray",e.BlackBright="blackBright",e.RedBright="redBright",e.GreenBright="greenBright",e.YellowBright="yellowBright",e.BlueBright="blueBright",e.MagentaBright="magentaBright",e.CyanBright="cyanBright",e.WhiteBright="whiteBright",e})({}),Nt=(function(e){return e.Black="bgBlack",e.Red="bgRed",e.Green="bgGreen",e.Yellow="bgYellow",e.Blue="bgBlue",e.Magenta="bgMagenta",e.Cyan="bgCyan",e.White="bgWhite",e.BlackBright="bgBlackBright",e.RedBright="bgRedBright",e.GreenBright="bgGreenBright",e.YellowBright="bgYellowBright",e.BlueBright="bgBlueBright",e.MagentaBright="bgMagentaBright",e.CyanBright="bgCyanBright",e.WhiteBright="bgWhiteBright",e})({}),A=class{type="logger";constructor(t){this.logger=t}log(...t){this.logger.debug("[i18next]",...t)}warn(...t){this.logger.warn("[i18next]",...t)}error(...t){this.logger.error("[i18next]",...t)}}});var S=l(()=>{"use strict";H();X();j()});var et={};B(et,{default:()=>_t});var tt,_t,rt=l(()=>{"use strict";tt=require("discord.js");E();_t=new u(tt.Events.ClientReady).onExecute(async function(e){e.client.options.autoRegisterCommands&&await e.client.registerCommands()})});var b,G,W=l(()=>{"use strict";b="Command not found or disabled.",G="There was an error while executing this command!"});var it={};B(it,{default:()=>Rt});var p,Rt,st=l(()=>{"use strict";p=require("discord.js");W();E();Rt=new u(p.Events.InteractionCreate,!1).onExecute(async function(e,t){if(!t.isChatInputCommand())return;let r=e.client.commands.get(t.commandName),i=new d(e.client,{interaction:t});if(!r){await t.reply({content:i.t("error:command.notfound",{defaultValue:b}),flags:p.MessageFlags.Ephemeral});return}if(!r.supportsSlash){await t.reply({content:i.t("error:command.disabled",{defaultValue:b}),flags:p.MessageFlags.Ephemeral});return}try{e.logger.debug(`${i.author?.tag??"Unknown"} used ${r.data.name}(interaction)`),r._onInteraction&&await r._onInteraction(i.toJSON())}catch(s){e.client.logger.error(`Error executing command ${r.data.name}:`,s),t.replied||t.deferred?await t.followUp({content:G,flags:p.MessageFlags.Ephemeral}):await t.reply({content:G,flags:p.MessageFlags.Ephemeral})}})});var at={};B(at,{default:()=>St});var nt,St,ot=l(()=>{"use strict";nt=require("discord.js");W();E();S();St=new u(nt.Events.MessageCreate,!1,async function(e,t){if(t.author.bot)return;let r=e.client.prefix(new d(e.client,{message:t}));if(typeof r!="string"||r.length===0||!t.content.startsWith(r))return;let i=t.content.slice(r.length).trim().split(/ +/),s=i.shift()?.toLowerCase();if(!s)return;let o=e.client.aliases.findKey(x=>x.has(s)),h=new d(e.client,{message:t,args:i}),c=e.client.commands.get(o??s);if(!c){await t.reply({content:h.t("error:command.notfound",{defaultValue:b}),allowedMentions:{repliedUser:!1}}).then(_);return}if(!c.supportsPrefix){await t.reply({content:h.t("error:command.disabled",{defaultValue:b}),allowedMentions:{repliedUser:!1}}).then(_);return}try{e.logger.debug(`${h.author?.tag??"Unknown"} used ${c.data.name}(message)`),c._onMessage&&await c._onMessage(h.toJSON())}catch(x){e.client.logger.error(`Error executing command ${c.data.name}:`,x)}})});var f,lt,J,ht,Ft,P,ct=l(()=>{"use strict";f=require("discord.js"),lt=require("node:fs"),J=I(require("node:path"),1),ht=require("node:url");S();E();Ft={includePaths:["events","commands"],autoRegisterCommands:!0,getDefaultLang:$},P=class extends f.Client{logger;commands;aliases;prefix;i18n;constructor(t){super({...Ft,...t}),this.logger=new w(t.logger),this.commands=new f.Collection,this.aliases=new f.Collection,this.prefix=this.options.prefix??(()=>!1),this.options.i18n&&(this.i18n=this.options.i18n,this.i18n.use(new A(this.logger)))}async login(t){await this.#r();for(let r of this.options.includePaths)try{let i=J.default.isAbsolute(r)?r:J.default.join(k(),r);await this.#t(i)}catch(i){this.logger.error(`Error loading ${r}:`,i)}return this.i18n&&!this.i18n.isInitialized&&await this.i18n.init(),super.login(t)}async#t(t){if(!(0,lt.existsSync)(t)){this.logger.debug(`Directory not found: ${t}`);return}let r=v(t);for(let i of r)await this.#e(i)}async#r(){let t=[()=>Promise.resolve().then(()=>(rt(),et)),()=>Promise.resolve().then(()=>(st(),it))];for(let r of t){let i=await r();await this.#i(i,"[core]")}if(this.options.prefix){let r=await Promise.resolve().then(()=>(ot(),at));await this.#i(r,"[core]")}}async#e(t){try{let r=(0,ht.pathToFileURL)(t);r.searchParams.set("ts",Date.now().toString(36));let i=await import(r.href);await this.#i(i,t)}catch(r){this.logger.error(`Error loading file ${t}:`,r)}}async#i(t,r){let i=new Set;for(let s of Object.values(t))i.add(s);for(let s of i)await this.#s(s,r)}async#s(t,r){if(t!=null){if(Array.isArray(t)){for(let i of t)await this.#s(i,r);return}if(t instanceof M){t.attach(this);return}if(t instanceof u){t.attach(this);return}if(typeof t=="object"&&t!==null&&"attach"in t&&typeof t.attach=="function"){t.attach(this);return}if(typeof t=="function"){let i=await t(this);await this.#s(i,r);return}this.logger.debug(`Skipped unsupported export type in ${r}: ${typeof t}`)}}async registerCommands(){if(!this.token){this.logger.warn("registerCommands skipped: client token is not set.");return}if(!this.application){this.logger.warn("registerCommands skipped: client application is not ready.");return}let t=this.commands.filter(i=>i.supportsSlash).map(i=>i.data.toClientJSON(this)),r=new f.REST({version:"10"}).setToken(this.token);try{this.logger.debug(`Started refreshing ${t.length} application (/) commands.`),await r.put(f.Routes.applicationCommands(this.application.id),{body:t}),this.logger.info(`Loaded ${t.length} application (/) commands.`)}catch(i){this.logger.error("Failed to register commands:",i)}}}});var ut=l(()=>{"use strict";ct()});var M,Y,mt=l(()=>{"use strict";M=class{#t=null;#r=null;#e;#i;#s=!1;_onMessage;_onInteraction;get client(){if(!this.#t)throw new Error("Command is not attached to a client");return this.#t}get logger(){if(!this.#r)throw new Error("Command is not attached to a client");return this.#r}get supportsSlash(){return this.#e&&this._onInteraction}get supportsPrefix(){return this.#i&&this._onMessage}constructor(t){this.data=t;let r=t.toJSON(),{name:i}=r;if(this.#i=r.prefix_support??!1,this.#e=r.slash_support??!1,!this.#i&&!this.#e)throw new Error(`Command ${i} must support either slash or prefix commands.`)}attach(t){if(this.#s)return this;let r=this.data.toJSON(),{name:i,aliases:s}=r;if(this.#t=t,this.#r=t.logger,t.commands.has(i))throw new Error(`Command name "${i}" is already registered.`);let o=t.aliases.findKey(h=>h.has(i));if(o)throw new Error(`Command name "${i}" is already registered as an alias for command "${o}".`);for(let h of s){if(t.commands.has(h))throw new Error(`Alias "${h}" is already registered as a command name.`);let c=t.aliases.findKey(x=>x.has(h));if(c)throw new Error(`Alias "${h}" is already registered as an alias for command "${c}".`)}return t.commands.set(i,this),s.length>0&&t.aliases.set(i,new Set(s)),this.logger.debug(`Loaded Command ${i}`),this.#s=!0,this}onMessage(t){return this._onMessage=t,this}onInteraction(t){return this._onInteraction=t,this}},Y=class extends M{constructor(t){super(t.data);let r=t.data.toJSON(),i=t.execute;(r.prefix_support??!1)&&(t.onMessage||i)&&this.onMessage(s=>t.onMessage?t.onMessage(s):i?.(s)),(r.slash_support??!1)&&(t.onInteraction||i)&&this.onInteraction(s=>t.onInteraction?t.onInteraction(s):i?.(s))}}});var C,d,ft=l(()=>{"use strict";C=require("discord.js"),d=class{args;data;locale;constructor(t,r){this.client=t,this.args=r.args??[],"interaction"in r?this.data=r.interaction:this.data=r.message,this.locale=this.client.options.getDefaultLang?.(this)}isInteraction(){return this.data instanceof C.ChatInputCommandInteraction}isMessage(){return this.data instanceof C.Message}get author(){return this.isInteraction()?this.data.user:this.isMessage()?this.data.author:null}t(t,r){if(!this.client.i18n)throw new Error("i18n is not initialized");let i=this.locale??this.client.options.getDefaultLang?.(this)??(Array.isArray(this.client.i18n.options.fallbackLng)?this.client.i18n.options.fallbackLng[0]:this.client.i18n.options.fallbackLng)??C.Locale.EnglishUS,o=this.client.i18n.getFixedT(i)(t,r);return o===t&&r?.defaultValue?r.defaultValue:o}toJSON(){let{data:t,args:r,author:i}=this;return this.isInteraction()?{kind:"interaction",interaction:t,author:i,t:(s,o)=>this.t(s,o)}:{kind:"message",message:t,args:r,author:i,t:(s,o)=>this.t(s,o)}}}});var u,dt=l(()=>{"use strict";u=class{#t=null;#r=null;#e;#i=!1;get client(){if(!this.#t)throw new Error("Event is not attached to a client");return this.#t}get logger(){if(!this.#r)throw new Error("Event is not attached to a client");return this.#r}#s=async(...t)=>{if(this.#t&&this.#e)try{await this.#e(this,...t)}catch(r){this.client.logger.error(`Error executing event ${this.name} (${this.constructor.name}):`,r)}};constructor(t,r=!1,i){this.name=t,this.once=r,i&&(this.#e=i)}#n(){this.#i||!this.#e||!this.#t||!this.#r||(this.once?this.client.once(this.name,this.#s):this.client.on(this.name,this.#s),this.#i=!0,this.logger.debug(`Loaded Event ${String(this.name)}`))}attach(t){return this.#t?this:(this.#t=t,this.#r=t.logger,this.#n(),this)}onExecute(t){return this.#e=t,this.#n(),this}}});function F(e){return Array.isArray(e[0])?[...e[0]]:e}var pt=l(()=>{"use strict"});var gt,T,wt=l(()=>{"use strict";gt=require("discord.js");pt();T=class extends gt.SlashCommandBuilder{prefix_support=!0;slash_support=!0;aliases=[];setAliases(...t){return this.aliases=F(t),this}addAliases(...t){return this.aliases=F([...this.aliases,...F(t)]),this}setPrefixSupport(t){return this.prefix_support=t,this}setSlashSupport(t){return this.slash_support=t,this}toJSON(){return super.toJSON()}toClientJSON(t){return{...this.toJSON()}}}});var Et=l(()=>{"use strict";mt();ft();dt();wt()});var E=l(()=>{"use strict";ut();Et()});var vt={};B(vt,{ApplicationCommandBuilder:()=>T,Client:()=>P,Command:()=>Y,CommandBuilder:()=>M,Context:()=>d,EventBuilder:()=>u,I18nLoggerAdapter:()=>A,LogLevel:()=>n,Logger:()=>w,LoggerLevel:()=>g,LoggerStyle:()=>y,LoggerStyleBackground:()=>Nt,LoggerStyleEffect:()=>It,LoggerStyleText:()=>Ot,LoggerTimestamp:()=>R,allowedLocales:()=>V,deleteMessageAfterSent:()=>_,getDefaultLang:()=>$,getFiles:()=>v,getProjectRoot:()=>k,toAllowedLocale:()=>N,version:()=>$t});module.exports=At(vt);E();S();j();var $t="v0.1.2-beta.2";0&&(module.exports={ApplicationCommandBuilder,Client,Command,CommandBuilder,Context,EventBuilder,I18nLoggerAdapter,LogLevel,Logger,LoggerLevel,LoggerStyle,LoggerStyleBackground,LoggerStyleEffect,LoggerStyleText,LoggerTimestamp,allowedLocales,deleteMessageAfterSent,getDefaultLang,getFiles,getProjectRoot,toAllowedLocale,version});
1
+ "use strict";var Zt=Object.create;var J=Object.defineProperty;var te=Object.getOwnPropertyDescriptor;var ee=Object.getOwnPropertyNames;var re=Object.getPrototypeOf,ne=Object.prototype.hasOwnProperty;var u=(r,t)=>()=>(r&&(t=r(r=0)),t);var W=(r,t)=>{for(var e in t)J(r,e,{get:t[e],enumerable:!0})},xt=(r,t,e,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of ee(t))!ne.call(r,s)&&s!==e&&J(r,s,{get:()=>t[s],enumerable:!(n=te(t,s))||n.enumerable});return r};var L=(r,t,e)=>(e=r!=null?Zt(re(r)):{},xt(t||!r||!r.__esModule?J(e,"default",{value:r,enumerable:!0}):e,r)),se=r=>xt(J({},"__esModule",{value:!0}),r);function et(r){if(r==null)return"";let t;return typeof r=="string"?t=r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?t=`${r}`:r instanceof Date?t=r.toISOString():typeof r=="object"?t=JSON.stringify(r):typeof r=="symbol"?t=r.description?`Symbol(${r.description})`:"Symbol()":typeof r=="function"?t=r.name?`[Function: ${r.name}]`:"[Function]":t="",t.replaceAll("@","@\u200B")}function rt(r,t,e){let n=String(r),s=0,o="";for(;s<n.length;){let i=n.indexOf("{{",s);if(i===-1){o+=n.slice(s);break}o+=n.slice(s,i);let c=n.indexOf("}}",i+2);if(c===-1){o+=n.slice(i);break}let h=n.slice(i,c+2),f=n.slice(i+2,c),x=f.trim();if(!x||f.includes("{")||f.includes("}"))o+=h;else{let y=e(x,t);o+=typeof y=="string"?y:h}s=c+2}return o}function nt(r){let t=String(r),e=new Set,n=0;for(;n<t.length;){let s=t.indexOf("{{",n);if(s===-1)break;let o=t.indexOf("}}",s+2);if(o===-1)break;let i=t.slice(s+2,o),c=i.trim();c&&!i.includes("{")&&!i.includes("}")&&e.add(c),n=o+2}return e}function Y(r,t=15e3){return new Promise(e=>{setTimeout(()=>{r.delete().catch(()=>{}),e()},t)})}function V(r){if(r&&oe.has(r))return r}function st(r){return r.isInteraction()?V(r.data.locale)??V(r.data.guildLocale)??tt.Locale.EnglishUS:V(r.data.guild?.preferredLocale)??tt.Locale.EnglishUS}var tt,Ot,oe,ot=u(()=>{"use strict";tt=require("discord.js"),Ot=["id","en-US","en-GB","bg","zh-CN","zh-TW","hr","cs","da","nl","fi","fr","de","el","hi","hu","it","ja","ko","lt","no","pl","pt-BR","ro","ru","es-ES","es-419","sv-SE","th","tr","uk","vi"],oe=new Set(Ot)});function it(r){return Ct.default.sync(["**/*.ts","**/*.js","**/*.cjs","**/*.mjs"],{cwd:r,absolute:!0,ignore:["**/*.d.ts","node_modules/**",".git/**","dist/**","lib/**","out/**","build/**",".next/**","coverage/**"]})}function at(){let r=[];r.push(w.default.resolve(process.cwd()));let t=typeof require<"u"?require.main?.filename:void 0;t&&r.push(w.default.dirname(w.default.resolve(t))),typeof module<"u"&&module.parent?.filename&&r.push(w.default.dirname(w.default.resolve(module.parent.filename)));for(let e of r){let n=ie(e);if(n)return n}return r[0]}function ie(r){let t=w.default.resolve(r);for(;;){let e=w.default.join(t,"package.json");if((0,yt.existsSync)(e))return w.default.normalize(t);let n=w.default.dirname(t);if(n===t)return null;t=n}}var Ct,yt,w,St=u(()=>{"use strict";Ct=L(require("fast-glob"),1),yt=require("node:fs"),w=L(require("path"),1)});var a,lt=u(()=>{"use strict";a=(function(r){return r[r.Trace=10]="Trace",r[r.Debug=20]="Debug",r[r.Info=30]="Info",r[r.Warn=40]="Warn",r[r.Error=50]="Error",r[r.Fatal=60]="Fatal",r[r.None=100]="None",r})({})});var Et,At,d,Mt,M,D,H,A,Se,ae,le,ce,z,ct=u(()=>{"use strict";Et=require("console"),At=require("util"),d=L(require("colorette"),1),Mt=require("@sapphire/timestamp");lt();lt();M=class r{level;formats;join;depth;console;static instance=null;static LOG_METHODS=new Map([[a.Trace,"trace"],[a.Debug,"debug"],[a.Info,"info"],[a.Warn,"warn"],[a.Error,"error"],[a.Fatal,"error"]]);static DEFAULT_COLORS=new Map([[a.Trace,d.gray],[a.Debug,d.magenta],[a.Info,d.cyan],[a.Warn,d.yellow],[a.Error,d.red],[a.Fatal,d.bgRed],[a.None,d.white]]);static DEFAULT_NAMES=new Map([[a.Trace,"TRACE"],[a.Debug,"DEBUG"],[a.Info,"INFO"],[a.Warn,"WARN"],[a.Error,"ERROR"],[a.Fatal,"FATAL"],[a.None,""]]);constructor(t={}){this.level=t.level??a.Info,this.console=new Et.Console(t.stdout??process.stdout,t.stderr??process.stderr),this.formats=this.createFormatMap(t.format,t.defaultFormat??t.format?.none??{}),this.join=t.join??" ",this.depth=t.depth??2}static getInstance(){return this.instance||(this.instance=new r),this.instance}static get stylize(){return d.isColorSupported}setLevel(t){this.level=t}has(t){return t>=this.level}trace(...t){this.write(a.Trace,...t)}debug(...t){this.write(a.Debug,...t)}info(...t){this.write(a.Info,...t)}log(...t){this.write(a.Info,...t)}warn(...t){this.write(a.Warn,...t)}error(...t){this.write(a.Error,...t)}fatal(...t){this.write(a.Fatal,...t)}write(t,...e){if(t<this.level)return;let n=r.LOG_METHODS.get(t),o=(this.formats.get(t)??this.formats.get(a.None)).run(this.preprocess(e));switch(n){case"trace":this.console.trace(o);break;case"debug":this.console.debug(o);break;case"info":this.console.info(o);break;case"warn":this.console.warn(o);break;case"error":this.console.error(o);break;default:this.console.log(o)}}preprocess(t){let e={colors:d.isColorSupported,depth:this.depth};return t.map(n=>typeof n=="string"?n:(0,At.inspect)(n,e)).join(this.join)}createFormatMap(t={},e){let n=new Map;for(let[s,o]of r.DEFAULT_COLORS){let i=r.DEFAULT_NAMES.get(s),c=t[this.getLevelKey(s)]??this.createDefaultLevel(e,o,i??"");n.set(s,c instanceof A?c:new A(c))}return n}createDefaultLevel(t,e,n){return new A({...t,timestamp:t.timestamp===null?null:{...t.timestamp,color:e},infix:n.length?`${e(n.padEnd(5," "))} `:""})}getLevelKey(t){return{[a.Trace]:"trace",[a.Debug]:"debug",[a.Info]:"info",[a.Warn]:"warn",[a.Error]:"error",[a.Fatal]:"fatal",[a.None]:"none"}[t]}},D=class{style;constructor(t={}){if(typeof t=="function")this.style=t;else{let e=this.buildStyleArray(t);this.style=this.combineStyles(e)}}run(t){return this.style(String(t))}buildStyleArray(t){let e=[];return t.effects&&e.push(...t.effects.map(n=>d[n])),t.text&&e.push(d[t.text]),t.background&&e.push(d[t.background]),e}combineStyles(t){return t.length===0?d.reset:t.length===1?t[0]:(e=>t.reduce((n,s)=>s(n),e))}},H=class{timestamp;utc;color;formatter;constructor(t={}){this.timestamp=new Mt.Timestamp(t.pattern??"YYYY-MM-DD HH:mm:ss"),this.utc=t.utc??!1,this.color=t.color===null?null:new D(t.color),this.formatter=t.formatter??(e=>`${e} `)}run(){let t=new Date,e=this.utc?this.timestamp.displayUTC(t):this.timestamp.display(t);return this.formatter(this.color?this.color.run(e):e)}},A=class{timestamp;infix;message;constructor(t={}){this.timestamp=t.timestamp===null?null:new H(t.timestamp),this.infix=t.infix??"",this.message=t.message===null?null:new D(t.message)}run(t){let e=(this.timestamp?.run()??"")+this.infix;if(e.length){let n=this.message?s=>e+this.message?.run(s):s=>e+s;return t.split(`
2
+ `).map(n).join(`
3
+ `)}return this.message?this.message.run(t):t}},Se=M.getInstance(),ae=(function(r){return r.Reset="reset",r.Bold="bold",r.Dim="dim",r.Italic="italic",r.Underline="underline",r.Inverse="inverse",r.Hidden="hidden",r.Strikethrough="strikethrough",r})({}),le=(function(r){return r.Black="black",r.Red="red",r.Green="green",r.Yellow="yellow",r.Blue="blue",r.Magenta="magenta",r.Cyan="cyan",r.White="white",r.Gray="gray",r.BlackBright="blackBright",r.RedBright="redBright",r.GreenBright="greenBright",r.YellowBright="yellowBright",r.BlueBright="blueBright",r.MagentaBright="magentaBright",r.CyanBright="cyanBright",r.WhiteBright="whiteBright",r})({}),ce=(function(r){return r.Black="bgBlack",r.Red="bgRed",r.Green="bgGreen",r.Yellow="bgYellow",r.Blue="bgBlue",r.Magenta="bgMagenta",r.Cyan="bgCyan",r.White="bgWhite",r.BlackBright="bgBlackBright",r.RedBright="bgRedBright",r.GreenBright="bgGreenBright",r.YellowBright="bgYellowBright",r.BlueBright="bgBlueBright",r.MagentaBright="bgMagentaBright",r.CyanBright="bgCyanBright",r.WhiteBright="bgWhiteBright",r})({}),z=class{type="logger";constructor(t){this.logger=t}log(...t){this.logger.debug("[i18next]",...t)}warn(...t){this.logger.warn("[i18next]",...t)}error(...t){this.logger.error("[i18next]",...t)}}});var X=u(()=>{"use strict";ot();St();ct()});var kt=u(()=>{"use strict"});var It={};W(It,{default:()=>ue});var Nt,ue,Tt=u(()=>{"use strict";Nt=require("discord.js");k();ue=new b(Nt.Events.ClientReady).onExecute(async function(r){r.client.options.autoRegisterCommands&&await r.client.registerCommands()})});var N,ut,dt=u(()=>{"use strict";N="Command not found or disabled.",ut="There was an error while executing this command!"});var Dt={};W(Dt,{default:()=>de});var E,de,zt=u(()=>{"use strict";E=require("discord.js");dt();k();de=new b(E.Events.InteractionCreate,!1).onExecute(async function(r,t){if(!t.isChatInputCommand())return;let e=r.client.resolveInteractionCommand(t.commandName),n=new O(r.client,{interaction:t});if(!e){await t.reply({content:n.t("error:command.notfound",{defaultValue:N}),flags:E.MessageFlags.Ephemeral});return}if(!e.supportsSlash){await t.reply({content:n.t("error:command.disabled",{defaultValue:N}),flags:E.MessageFlags.Ephemeral});return}try{r.logger.debug(`${n.author?.tag??"Unknown"} used ${e.data.name}(interaction)`),e._onInteraction&&await e._onInteraction(n.toJSON())}catch(s){r.client.logger.error(`Error executing command ${e.data.name}:`,s),t.replied||t.deferred?await t.followUp({content:ut,flags:E.MessageFlags.Ephemeral}):await t.reply({content:ut,flags:E.MessageFlags.Ephemeral})}})});var Rt={};W(Rt,{default:()=>me});var Bt,me,$t=u(()=>{"use strict";Bt=require("discord.js");dt();k();X();me=new b(Bt.Events.MessageCreate,!1,async function(r,t){if(t.author.bot)return;let e=r.client.prefix(new O(r.client,{message:t}));if(typeof e!="string"||e.length===0||!t.content.startsWith(e))return;let n=t.content.slice(e.length).trim().split(/ +/),s=n.shift();if(!s)return;let o=new O(r.client,{message:t,args:n}),i=r.client.resolveMessageCommand(s);if(!i){await t.reply({content:o.t("error:command.notfound",{defaultValue:N}),allowedMentions:{repliedUser:!1}}).then(Y);return}if(!i.supportsPrefix){await t.reply({content:o.t("error:command.disabled",{defaultValue:N}),allowedMentions:{repliedUser:!1}}).then(Y);return}try{r.logger.debug(`${o.author?.tag??"Unknown"} used ${i.data.name}(message)`),i._onMessage&&await i._onMessage(o.toJSON())}catch(c){r.client.logger.error(`Error executing command ${i.data.name}:`,c)}})});var C,Ft,mt,Pt,he,ht,vt=u(()=>{"use strict";C=require("discord.js"),Ft=require("node:fs"),mt=L(require("node:path"),1),Pt=require("node:url");X();kt();k();he={includePaths:["events","commands"],autoRegisterCommands:!0,getDefaultLang:st},ht=class extends C.Client{logger;commands;slashCommandLookup=null;prefixCommandLookup=null;templateParsers=[];prefix;i18n;i18next;constructor(t){super({...he,...t}),this.logger=new M(t.logger),this.commands=new C.Collection,this.prefix=this.options.prefix??(()=>!1),this.options.i18n&&(this.i18n=this.options.i18n,this.i18n.use(new z(this.logger))),this.i18next={instance:this.i18n,parser:{addParser:e=>{this.addTemplateParser(e)},removeParser:e=>this.removeTemplateParser(e),clearParsers:()=>{this.clearTemplateParsers()}}}}async login(t){await this.#e();for(let e of this.options.includePaths)try{let n=mt.default.isAbsolute(e)?e:mt.default.join(at(),e);await this.#t(n)}catch(n){this.logger.error(`Error loading ${e}:`,n)}return this.i18n&&!this.i18n.isInitialized&&await this.i18n.init(),this.invalidateCommandLookupCache(),super.login(t)}async#t(t){if(!(0,Ft.existsSync)(t)){this.logger.debug(`Directory not found: ${t}`);return}let e=it(t);for(let n of e)await this.#r(n)}async#e(){let t=[()=>Promise.resolve().then(()=>(Tt(),It)),()=>Promise.resolve().then(()=>(zt(),Dt))];for(let e of t){let n=await e();await this.#n(n,"[core]")}if(this.options.prefix){let e=await Promise.resolve().then(()=>($t(),Rt));await this.#n(e,"[core]")}}async#r(t){try{let e=(0,Pt.pathToFileURL)(t);e.searchParams.set("ts",Date.now().toString(36));let n=await import(e.href);await this.#n(n,t)}catch(e){this.logger.error(`Error loading file ${t}:`,e)}}async#n(t,e){let n=new Set;for(let s of Object.values(t))n.add(s);for(let s of n)await this.registerExport(s,e)}async registerExport(t,e,n=0){if(t!=null){if(Array.isArray(t)){for(let s of t)await this.registerExport(s,e,n);return}if(t instanceof I){t.attach(this);return}if(t instanceof b){t.attach(this);return}if(typeof t=="object"&&"attach"in t&&typeof t.attach=="function"){await t.attach(this);return}if(typeof t=="function"){if(n>=16){this.logger.error(`Skipped export factory in ${e}: max depth (${16}) exceeded.`);return}let s=await t(this);await this.registerExport(s,e,n+1);return}this.logger.debug(`Skipped unsupported export type in ${e}: ${typeof t}`)}}normalizeCommandName(t){return t.trim().toLowerCase()}invalidateCommandLookupCache(){this.slashCommandLookup=null,this.prefixCommandLookup=null}addTemplateParser(t){this.templateParsers.includes(t)||this.templateParsers.push(t)}removeTemplateParser(t){let e=this.templateParsers.indexOf(t);return e===-1?!1:(this.templateParsers.splice(e,1),!0)}clearTemplateParsers(){this.templateParsers.length=0}parseTemplateToken(t,e){for(let n of this.templateParsers){let s=n(t,e);if(typeof s=="string")return s}}buildCommandLookup(t){let e=new Map;for(let n of this.commands.values()){if(t?!n.supportsPrefix:!n.supportsSlash)continue;let s=n.data.toClientJSON(this),o=Object.values(s.name_localizations??{}).filter(i=>typeof i=="string");for(let i of new Set([s.name,...o])){let c=this.normalizeCommandName(i),h=e.get(c);if(!h){e.set(c,n);continue}if(h!==n){let f=h.data.toJSON().name;this.logger.warn(`Command lookup conflict (${t?"prefix":"slash"}) for "${i}" (normalized: "${c}"): "${s.name}" conflicts with "${f}". Keeping "${f}".`)}}}return e}getSlashCommandLookup(){return this.slashCommandLookup||(this.slashCommandLookup=this.buildCommandLookup(!1)),this.slashCommandLookup}getPrefixCommandLookup(){return this.prefixCommandLookup||(this.prefixCommandLookup=this.buildCommandLookup(!0)),this.prefixCommandLookup}getSlashCommandsPayload(){return this.commands.filter(t=>t.supportsSlash).map(t=>t.data.toClientJSON(this))}resolveInteractionCommand(t){let e=this.normalizeCommandName(t),n=this.commands.get(e)??this.commands.get(t);return n?.supportsSlash?n:this.getSlashCommandLookup().get(e)}resolveMessageCommand(t){let e=this.normalizeCommandName(t),n=this.commands.get(e)??this.commands.get(t);return n?.supportsPrefix?n:this.getPrefixCommandLookup().get(e)}async registerCommands(){if(!this.token){this.logger.warn("registerCommands skipped: client token is not set.");return}if(!this.application){this.logger.warn("registerCommands skipped: client application is not ready.");return}let t=this.getSlashCommandsPayload(),e=new C.REST({version:"10"}).setToken(this.token);try{this.logger.debug(`Started refreshing ${t.length} application (/) commands.`),await e.put(C.Routes.applicationCommands(this.application.id),{body:t}),this.logger.info(`Loaded ${t.length} application (/) commands.`)}catch(n){this.logger.error("Failed to register commands:",n)}}}});var Ut=u(()=>{"use strict";vt()});var I,pt,Gt=u(()=>{"use strict";I=class{#t=null;#e=null;#r;#n;#s=!1;_onMessage;_onInteraction;createContextHandler(t,e){if(t)return n=>t(n);if(e)return n=>e(n)}get client(){if(!this.#t)throw new Error("Command is not attached to a client");return this.#t}get logger(){if(!this.#e)throw new Error("Command is not attached to a client");return this.#e}get supportsSlash(){return this.#r&&!!this._onInteraction}get supportsPrefix(){return this.#n&&!!this._onMessage}constructor(t){this.data=t;let e=t.toJSON(),{name:n}=e;if(this.#n=e.prefix_support??!1,this.#r=e.slash_support??!1,!this.#n&&!this.#r)throw new Error(`Command ${n} must support either slash or prefix commands.`)}attach(t){if(this.#s)return this;let e=this.data.toJSON(),{name:n}=e;if(this.#t=t,this.#e=t.logger,t.commands.has(n))throw new Error(`Command name "${n}" is already registered.`);return t.commands.set(n,this),t.invalidateCommandLookupCache(),this.logger.debug(`Loaded Command ${n}`),this.#s=!0,this}onMessage(t){return this._onMessage=t,this}onInteraction(t){return this._onInteraction=t,this}},pt=class extends I{constructor(t){super(t.data);let e=t.data.toJSON();if(e.prefix_support){let n=this.createContextHandler(t.onMessage,t.execute);n&&this.onMessage(n)}if(e.slash_support){let n=this.createContextHandler(t.onInteraction,t.execute);n&&this.onInteraction(n)}}}});var T,O,jt=u(()=>{"use strict";T=require("discord.js");ot();O=class{args;data;locale;constructor(t,e){this.client=t,this.args=e.args??[],"interaction"in e?this.data=e.interaction:this.data=e.message,this.locale=this.client.options.getDefaultLang?.(this)}#t(){let t=this.client.i18n.options.fallbackLng;return(Array.isArray(t)?t[0]:t)??T.Locale.EnglishUS}#e(){return this.locale??this.client.options.getDefaultLang?.(this)??this.#t()}#r(){return(t,e)=>this.t(t,e)}#n(){return(t,e)=>this.getDefaultLocalization(t,e)}#s(){return(t,e)=>this.getLocalizationAliases(t,e)}#o(t){return Array.isArray(t)?t.flatMap(e=>this.#o(e)).filter(e=>e.length>0):typeof t=="string"?t.split(/[,\n|]/g).map(e=>e.trim()).filter(e=>e.length>0):[]}isInteraction(){return this.data instanceof T.ChatInputCommandInteraction}isMessage(){return this.data instanceof T.Message}get author(){return this.isInteraction()?this.data.user:this.isMessage()?this.data.author:null}resolveIdentityToken(t,e){if(t){if(e===""||e==="name"||e==="username")return et(t.username);if(e==="id")return t.id;if(e==="ping"||e==="mention")return`<@${t.id}>`}}resolveContextToken(t){let[e,...n]=t.toLowerCase().split("."),s=n.join("."),o=e.trim();if(o==="user"||o==="author")return this.resolveIdentityToken(this.author,s);if(o==="bot")return s==="ws.ping"?`${this.client.ws.ping}`:this.resolveIdentityToken(this.client.user,s)}resolveTemplateToken(t){return this.resolveContextToken(t)??this.client.parseTemplateToken(t,this)}t(t,e){if(!this.client.i18n)throw new Error("i18n is not initialized");let n=this.client.i18n.getFixedT(this.#e()),s=n(t,{...e,skipInterpolation:!0}),o=s===t&&e?.defaultValue?e.defaultValue:s,i=nt(o),c=n(t,e),h=c===t&&e?.defaultValue?e.defaultValue:c;return i.size===0?h:rt(h,this,(f,x)=>{if(i.has(f))return x.resolveTemplateToken(f)})}getDefaultLocalization(t,e){if(!this.client.i18n)return e??t;let n=this.client.i18n.t(t,{lng:this.#t(),defaultValue:e??t});return typeof n=="string"?n:e??t}getLocalizationAliases(t,e){let n=this.#o(e??[]);if(!this.client.i18n)return n;let s=Array.from(new Set([this.#e(),this.#t()])),o=new Set;for(let i of s){let c=this.client.i18n.t(t,{lng:i,defaultValue:"",returnObjects:!0});for(let h of this.#o(c))h!==t&&o.add(h)}if(o.size===0)for(let i of n)o.add(i);return Array.from(o)}toJSON(){let{data:t,args:e,author:n}=this,s=this.#r(),o=this.#n(),i=this.#s();return this.isInteraction()?{kind:"interaction",interaction:t,author:n,t:s,getDefaultLocalization:o,getLocalizationAliases:i}:{kind:"message",message:t,args:e,author:n,t:s,getDefaultLocalization:o,getLocalizationAliases:i}}}});var b,Jt=u(()=>{"use strict";b=class{#t=null;#e=null;#r;#n=!1;get client(){if(!this.#t)throw new Error("Event is not attached to a client");return this.#t}get logger(){if(!this.#e)throw new Error("Event is not attached to a client");return this.#e}#s=async(...t)=>{if(this.#t&&this.#r)try{await this.#r(this,...t)}catch(e){this.client.logger.error(`Error executing event ${this.name} (${this.constructor.name}):`,e)}};constructor(t,e=!1,n){this.name=t,this.once=e,n&&(this.#r=n)}#o(){this.#n||!this.#r||!this.#t||!this.#e||(this.once?this.client.once(this.name,this.#s):this.client.on(this.name,this.#s),this.#n=!0,this.logger.debug(`Loaded Event ${String(this.name)}`))}attach(t){return this.#t?this:(this.#t=t,this.#e=t.logger,this.#o(),this)}onExecute(t){return this.#r=t,this.#o(),this}}});var p,m,Wt=u(()=>{"use strict";p=(r,t)=>(r.setName(t),r.setDescription(t),r),m=(r,t)=>(r instanceof t||Object.setPrototypeOf(r,t.prototype),r)});var g,pe,fe,q,Lt,Vt,Yt=u(()=>{"use strict";g=require("discord.js"),pe={[g.ApplicationCommandOptionType.User]:"user",[g.ApplicationCommandOptionType.String]:"string",[g.ApplicationCommandOptionType.Number]:"number",[g.ApplicationCommandOptionType.Integer]:"number",[g.ApplicationCommandOptionType.Boolean]:"boolean",[g.ApplicationCommandOptionType.Role]:"role",[g.ApplicationCommandOptionType.Channel]:"channel",[g.ApplicationCommandOptionType.Mentionable]:"mentionable",[g.ApplicationCommandOptionType.Attachment]:"attachment"},fe=r=>{let t=Object.keys(r.store.data),e=Array.isArray(r.options.supportedLngs)?r.options.supportedLngs.filter(n=>n!=="cimode"):[];return Array.from(new Set([...t,...e]))},q=(r,t,e)=>{let n={};for(let s of fe(r)){let o=r.t(t,{lng:s,defaultValue:e});n[s]=typeof o=="string"&&o.length>0?o:e}return n},Lt=(r,t,e)=>{let n;if(r.type===g.ApplicationCommandOptionType.Subcommand)n=`${t}.subcommand.${r.name}`;else if(r.type===g.ApplicationCommandOptionType.SubcommandGroup)n=`${t}.group.${r.name}`;else{let s=pe[r.type]??"option";n=`${t}.${s}.${r.name}`}r.name_localizations=q(e,`${n}.name`,r.name),typeof r.description=="string"&&(r.description_localizations=q(e,`${n}.description`,r.description));for(let s of r.options??[])Lt(s,n,e)},Vt=(r,t)=>{let e=`command:${r.name}`;r.name_localizations=q(t,`${e}.name`,r.name),r.description_localizations=q(t,`${e}.description`,r.description);for(let n of r.options??[])Lt(n,e,t);return r}});var l,B,R,$,_,F,P,v,U,G,j,K,ft,Ht=u(()=>{"use strict";l=require("discord.js");Wt();Yt();B=class extends l.SlashCommandStringOption{autoSet(t){return p(this,t)}},R=class extends l.SlashCommandIntegerOption{autoSet(t){return p(this,t)}},$=class extends l.SlashCommandNumberOption{autoSet(t){return p(this,t)}},_=class extends l.SlashCommandBooleanOption{autoSet(t){return p(this,t)}},F=class extends l.SlashCommandUserOption{autoSet(t){return p(this,t)}},P=class extends l.SlashCommandChannelOption{autoSet(t){return p(this,t)}},v=class extends l.SlashCommandRoleOption{autoSet(t){return p(this,t)}},U=class extends l.SlashCommandMentionableOption{autoSet(t){return p(this,t)}},G=class extends l.SlashCommandAttachmentOption{autoSet(t){return p(this,t)}},j=class extends l.SlashCommandSubcommandBuilder{autoSet(t){return p(this,t)}addStringOption(t){return typeof t!="function"?super.addStringOption(t):super.addStringOption(e=>t(m(e,B)))}addIntegerOption(t){return typeof t!="function"?super.addIntegerOption(t):super.addIntegerOption(e=>t(m(e,R)))}addNumberOption(t){return typeof t!="function"?super.addNumberOption(t):super.addNumberOption(e=>t(m(e,$)))}addBooleanOption(t){return typeof t!="function"?super.addBooleanOption(t):super.addBooleanOption(e=>t(m(e,_)))}addUserOption(t){return typeof t!="function"?super.addUserOption(t):super.addUserOption(e=>t(m(e,F)))}addChannelOption(t){return typeof t!="function"?super.addChannelOption(t):super.addChannelOption(e=>t(m(e,P)))}addRoleOption(t){return typeof t!="function"?super.addRoleOption(t):super.addRoleOption(e=>t(m(e,v)))}addMentionableOption(t){return typeof t!="function"?super.addMentionableOption(t):super.addMentionableOption(e=>t(m(e,U)))}addAttachmentOption(t){return typeof t!="function"?super.addAttachmentOption(t):super.addAttachmentOption(e=>t(m(e,G)))}},K=class extends l.SlashCommandSubcommandGroupBuilder{autoSet(t){return p(this,t)}addSubcommand(t){return typeof t!="function"?super.addSubcommand(t):super.addSubcommand(e=>t(m(e,j)))}},ft=class extends l.SlashCommandBuilder{prefix_support=!0;slash_support=!0;setPrefixSupport(t=!0){return this.prefix_support=t,this}setSlashSupport(t=!0){return this.slash_support=t,this}autoSet(t){return p(this,t)}addStringOption(t){return typeof t!="function"?super.addStringOption(t):super.addStringOption(e=>t(m(e,B)))}addIntegerOption(t){return typeof t!="function"?super.addIntegerOption(t):super.addIntegerOption(e=>t(m(e,R)))}addNumberOption(t){return typeof t!="function"?super.addNumberOption(t):super.addNumberOption(e=>t(m(e,$)))}addBooleanOption(t){return typeof t!="function"?super.addBooleanOption(t):super.addBooleanOption(e=>t(m(e,_)))}addUserOption(t){return typeof t!="function"?super.addUserOption(t):super.addUserOption(e=>t(m(e,F)))}addChannelOption(t){return typeof t!="function"?super.addChannelOption(t):super.addChannelOption(e=>t(m(e,P)))}addRoleOption(t){return typeof t!="function"?super.addRoleOption(t):super.addRoleOption(e=>t(m(e,v)))}addMentionableOption(t){return typeof t!="function"?super.addMentionableOption(t):super.addMentionableOption(e=>t(m(e,U)))}addAttachmentOption(t){return typeof t!="function"?super.addAttachmentOption(t):super.addAttachmentOption(e=>t(m(e,G)))}addSubcommand(t){return typeof t!="function"?super.addSubcommand(t):super.addSubcommand(e=>t(m(e,j)))}addSubcommandGroup(t){return typeof t!="function"?super.addSubcommandGroup(t):super.addSubcommandGroup(e=>t(m(e,K)))}toJSON(){let t=super.toJSON();return t.prefix_support=this.prefix_support,t.slash_support=this.slash_support,this.assertNoMixedTopLevelOptionTypes(t),t}toClientJSON(t){let e=this.toJSON();return t.i18n?Vt(e,t.i18n):e}assertNoMixedTopLevelOptionTypes(t){let e=t.options;if(!(!e||e.length===0||!e.some(o=>o.type===l.ApplicationCommandOptionType.Subcommand||o.type===l.ApplicationCommandOptionType.SubcommandGroup)||!e.some(o=>o.type!==l.ApplicationCommandOptionType.Subcommand&&o.type!==l.ApplicationCommandOptionType.SubcommandGroup)))throw new Error(`Command "${t.name}" mixes subcommands/subcommand groups with regular options at the top level. Discord requires choosing one structure.`)}}});var Xt=u(()=>{"use strict";Gt();jt();Jt();Ht()});var Q,gt,qt=u(()=>{"use strict";Q=require("fastest-levenshtein"),gt=class r{args;normalizedArgs;constructor(t){this.ctx=t,this.args=t.args,this.normalizedArgs=this.args.map(e=>r.normalizeToken(e))}static normalizeToken(t){return String(t).trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}getAliases(t,e=[]){return this.ctx.getLocalizationAliases(t,e).map(n=>r.normalizeToken(n)).filter((n,s,o)=>n.length>0&&o.indexOf(n)===s)}findClosestAlias(t,e,n=1){if(!t||e.length===0)return null;let s=(0,Q.closest)(t,e);return s&&(0,Q.distance)(t,s)<=n?s:null}matchesArg(t,e,n=[],s={}){let o=this.normalizedArgs[t];if(!o)return!1;let i=this.getAliases(e,n);return new Set(i).has(o)?!0:s.useFuzzy?this.findClosestAlias(o,i,s.maxDistance??1)!==null:!1}parseIntegerOption(t){let{key:e,fallbackAliases:n=[],defaultValue:s=0,startIndex:o=0,useFuzzy:i=!1,maxDistance:c=1}=t,h=this.getAliases(e,n),f=new Set(h),x=Number.parseInt(this.normalizedArgs[o+1]??"",10);if(Number.isFinite(x)&&x>=0)return x;for(let y=o+1;y<this.normalizedArgs.length;y+=1){let Z=this.normalizedArgs[y],[bt,wt]=Z.split(":"),Qt=i?this.findClosestAlias(bt,h,c):null;if(f.has(Z)||i&&this.findClosestAlias(Z,h,c)){let S=Number.parseInt(this.normalizedArgs[y+1]??"",10);if(Number.isFinite(S)&&S>=0)return S}if(wt&&(f.has(bt)||Qt)){let S=Number.parseInt(wt,10);if(Number.isFinite(S)&&S>=0)return S}}return s}}});var Kt=u(()=>{"use strict";qt()});var k=u(()=>{"use strict";Ut();Xt();Kt()});var be={};W(be,{ApplicationCommandBuilder:()=>ft,AutoSlashCommandAttachmentOption:()=>G,AutoSlashCommandBooleanOption:()=>_,AutoSlashCommandChannelOption:()=>P,AutoSlashCommandIntegerOption:()=>R,AutoSlashCommandMentionableOption:()=>U,AutoSlashCommandNumberOption:()=>$,AutoSlashCommandRoleOption:()=>v,AutoSlashCommandStringOption:()=>B,AutoSlashCommandSubcommandBuilder:()=>j,AutoSlashCommandSubcommandGroupBuilder:()=>K,AutoSlashCommandUserOption:()=>F,Client:()=>ht,Command:()=>pt,CommandBuilder:()=>I,Context:()=>O,EventBuilder:()=>b,I18nLoggerAdapter:()=>z,LogLevel:()=>a,Logger:()=>M,LoggerLevel:()=>A,LoggerStyle:()=>D,LoggerStyleBackground:()=>ce,LoggerStyleEffect:()=>ae,LoggerStyleText:()=>le,LoggerTimestamp:()=>H,MessageCommandParser:()=>gt,allowedLocales:()=>Ot,collectTemplateTokens:()=>nt,deleteMessageAfterSent:()=>Y,getDefaultLang:()=>st,getFiles:()=>it,getProjectRoot:()=>at,parseThings:()=>rt,sanitizeDiscordText:()=>et,toAllowedLocale:()=>V,version:()=>ge});module.exports=se(be);k();X();ct();var ge="v0.1.3";0&&(module.exports={ApplicationCommandBuilder,AutoSlashCommandAttachmentOption,AutoSlashCommandBooleanOption,AutoSlashCommandChannelOption,AutoSlashCommandIntegerOption,AutoSlashCommandMentionableOption,AutoSlashCommandNumberOption,AutoSlashCommandRoleOption,AutoSlashCommandStringOption,AutoSlashCommandSubcommandBuilder,AutoSlashCommandSubcommandGroupBuilder,AutoSlashCommandUserOption,Client,Command,CommandBuilder,Context,EventBuilder,I18nLoggerAdapter,LogLevel,Logger,LoggerLevel,LoggerStyle,LoggerStyleBackground,LoggerStyleEffect,LoggerStyleText,LoggerTimestamp,MessageCommandParser,allowedLocales,collectTemplateTokens,deleteMessageAfterSent,getDefaultLang,getFiles,getProjectRoot,parseThings,sanitizeDiscordText,toAllowedLocale,version});
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- var nt=Object.defineProperty;var D=(e=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(t,r)=>(typeof require<"u"?require:t)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});var l=(e,t)=>()=>(e&&(t=e(e=0)),t);var B=(e,t)=>{for(var r in t)nt(e,r,{get:t[r],enumerable:!0})};import{Locale as I}from"discord.js";function N(e,t=15e3){return new Promise(r=>{setTimeout(()=>{e.delete().catch(()=>{}),r()},t)})}function O(e){if(e&&ot.has(e))return e}function v(e){return e.isInteraction()?O(e.data.locale)??O(e.data.guildLocale)??I.EnglishUS:e.isMessage()?O(e.data.guild?.preferredLocale)??I.EnglishUS:I.EnglishUS}var at,ot,k=l(()=>{"use strict";at=["id","en-US","en-GB","bg","zh-CN","zh-TW","hr","cs","da","nl","fi","fr","de","el","hi","hu","it","ja","ko","lt","no","pl","pt-BR","ro","ru","es-ES","es-419","sv-SE","th","tr","uk","vi"],ot=new Set(at)});import lt from"fast-glob";import{existsSync as ht}from"node:fs";import m from"path";function U(e){return lt.sync(["**/*.ts","**/*.js","**/*.cjs","**/*.mjs"],{cwd:e,absolute:!0,ignore:["**/*.d.ts","node_modules/**",".git/**","dist/**","lib/**","out/**","build/**",".next/**","coverage/**"]})}function j(){let e=[];e.push(m.resolve(process.cwd()));let t=typeof D<"u"?D.main?.filename:void 0;t&&e.push(m.dirname(m.resolve(t))),typeof module<"u"&&module.parent?.filename&&e.push(m.dirname(m.resolve(module.parent.filename)));for(let r of e){let i=ct(r);if(i)return i}return e[0]}function ct(e){let t=m.resolve(e);for(;;){let r=m.join(t,"package.json");if(ht(r))return m.normalize(t);let i=m.dirname(t);if(i===t)return null;t=i}}var G=l(()=>{"use strict"});var s,_=l(()=>{"use strict";s=(function(e){return e[e.Trace=10]="Trace",e[e.Debug=20]="Debug",e[e.Info=30]="Info",e[e.Warn=40]="Warn",e[e.Error=50]="Error",e[e.Fatal=60]="Fatal",e[e.None=100]="None",e})({})});import{Console as ut}from"console";import{inspect as mt}from"util";import*as a from"colorette";import{Timestamp as ft}from"@sapphire/timestamp";var E,M,R,w,Yt,Tt,zt,Vt,C,S=l(()=>{"use strict";_();_();E=class e{level;formats;join;depth;console;static instance=null;static LOG_METHODS=new Map([[s.Trace,"trace"],[s.Debug,"debug"],[s.Info,"info"],[s.Warn,"warn"],[s.Error,"error"],[s.Fatal,"error"]]);static DEFAULT_COLORS=new Map([[s.Trace,a.gray],[s.Debug,a.magenta],[s.Info,a.cyan],[s.Warn,a.yellow],[s.Error,a.red],[s.Fatal,a.bgRed],[s.None,a.white]]);static DEFAULT_NAMES=new Map([[s.Trace,"TRACE"],[s.Debug,"DEBUG"],[s.Info,"INFO"],[s.Warn,"WARN"],[s.Error,"ERROR"],[s.Fatal,"FATAL"],[s.None,""]]);constructor(t={}){this.level=t.level??s.Info,this.console=new ut(t.stdout??process.stdout,t.stderr??process.stderr),this.formats=this.createFormatMap(t.format,t.defaultFormat??t.format?.none??{}),this.join=t.join??" ",this.depth=t.depth??2}static getInstance(){return this.instance||(this.instance=new e),this.instance}static get stylize(){return a.isColorSupported}setLevel(t){this.level=t}has(t){return t>=this.level}trace(...t){this.write(s.Trace,...t)}debug(...t){this.write(s.Debug,...t)}info(...t){this.write(s.Info,...t)}log(...t){this.write(s.Info,...t)}warn(...t){this.write(s.Warn,...t)}error(...t){this.write(s.Error,...t)}fatal(...t){this.write(s.Fatal,...t)}write(t,...r){if(t<this.level)return;let i=e.LOG_METHODS.get(t),o=(this.formats.get(t)??this.formats.get(s.None)).run(this.preprocess(r));switch(i){case"trace":this.console.trace(o);break;case"debug":this.console.debug(o);break;case"info":this.console.info(o);break;case"warn":this.console.warn(o);break;case"error":this.console.error(o);break;default:this.console.log(o)}}preprocess(t){let r={colors:a.isColorSupported,depth:this.depth};return t.map(i=>typeof i=="string"?i:mt(i,r)).join(this.join)}createFormatMap(t={},r){let i=new Map;for(let[n,o]of e.DEFAULT_COLORS){let h=e.DEFAULT_NAMES.get(n),c=t[this.getLevelKey(n)]??this.createDefaultLevel(r,o,h??"");i.set(n,c instanceof w?c:new w(c))}return i}createDefaultLevel(t,r,i){return new w({...t,timestamp:t.timestamp===null?null:{...t.timestamp,color:r},infix:i.length?`${r(i.padEnd(5," "))} `:""})}getLevelKey(t){return{[s.Trace]:"trace",[s.Debug]:"debug",[s.Info]:"info",[s.Warn]:"warn",[s.Error]:"error",[s.Fatal]:"fatal",[s.None]:"none"}[t]}},M=class{style;constructor(t={}){if(typeof t=="function")this.style=t;else{let r=this.buildStyleArray(t);this.style=this.combineStyles(r)}}run(t){return this.style(String(t))}buildStyleArray(t){let r=[];return t.effects&&r.push(...t.effects.map(i=>a[i])),t.text&&r.push(a[t.text]),t.background&&r.push(a[t.background]),r}combineStyles(t){return t.length===0?a.reset:t.length===1?t[0]:(r=>t.reduce((i,n)=>n(i),r))}},R=class{timestamp;utc;color;formatter;constructor(t={}){this.timestamp=new ft(t.pattern??"YYYY-MM-DD HH:mm:ss"),this.utc=t.utc??!1,this.color=t.color===null?null:new M(t.color),this.formatter=t.formatter??(r=>`${r} `)}run(){let t=new Date,r=this.utc?this.timestamp.displayUTC(t):this.timestamp.display(t);return this.formatter(this.color?this.color.run(r):r)}},w=class{timestamp;infix;message;constructor(t={}){this.timestamp=t.timestamp===null?null:new R(t.timestamp),this.infix=t.infix??"",this.message=t.message===null?null:new M(t.message)}run(t){let r=(this.timestamp?.run()??"")+this.infix;if(r.length){let i=this.message?n=>r+this.message?.run(n):n=>r+n;return t.split(`
2
- `).map(i).join(`
3
- `)}return this.message?this.message.run(t):t}},Yt=E.getInstance(),Tt=(function(e){return e.Reset="reset",e.Bold="bold",e.Dim="dim",e.Italic="italic",e.Underline="underline",e.Inverse="inverse",e.Hidden="hidden",e.Strikethrough="strikethrough",e})({}),zt=(function(e){return e.Black="black",e.Red="red",e.Green="green",e.Yellow="yellow",e.Blue="blue",e.Magenta="magenta",e.Cyan="cyan",e.White="white",e.Gray="gray",e.BlackBright="blackBright",e.RedBright="redBright",e.GreenBright="greenBright",e.YellowBright="yellowBright",e.BlueBright="blueBright",e.MagentaBright="magentaBright",e.CyanBright="cyanBright",e.WhiteBright="whiteBright",e})({}),Vt=(function(e){return e.Black="bgBlack",e.Red="bgRed",e.Green="bgGreen",e.Yellow="bgYellow",e.Blue="bgBlue",e.Magenta="bgMagenta",e.Cyan="bgCyan",e.White="bgWhite",e.BlackBright="bgBlackBright",e.RedBright="bgRedBright",e.GreenBright="bgGreenBright",e.YellowBright="bgYellowBright",e.BlueBright="bgBlueBright",e.MagentaBright="bgMagentaBright",e.CyanBright="bgCyanBright",e.WhiteBright="bgWhiteBright",e})({}),C=class{type="logger";constructor(t){this.logger=t}log(...t){this.logger.debug("[i18next]",...t)}warn(...t){this.logger.warn("[i18next]",...t)}error(...t){this.logger.error("[i18next]",...t)}}});var x=l(()=>{"use strict";k();G();S()});var W={};B(W,{default:()=>pt});import{Events as dt}from"discord.js";var pt,J=l(()=>{"use strict";d();pt=new u(dt.ClientReady).onExecute(async function(e){e.client.options.autoRegisterCommands&&await e.client.registerCommands()})});var p,F,$=l(()=>{"use strict";p="Command not found or disabled.",F="There was an error while executing this command!"});var P={};B(P,{default:()=>wt});import{Events as gt,MessageFlags as y}from"discord.js";var wt,Y=l(()=>{"use strict";$();d();wt=new u(gt.InteractionCreate,!1).onExecute(async function(e,t){if(!t.isChatInputCommand())return;let r=e.client.commands.get(t.commandName),i=new f(e.client,{interaction:t});if(!r){await t.reply({content:i.t("error:command.notfound",{defaultValue:p}),flags:y.Ephemeral});return}if(!r.supportsSlash){await t.reply({content:i.t("error:command.disabled",{defaultValue:p}),flags:y.Ephemeral});return}try{e.logger.debug(`${i.author?.tag??"Unknown"} used ${r.data.name}(interaction)`),r._onInteraction&&await r._onInteraction(i.toJSON())}catch(n){e.client.logger.error(`Error executing command ${r.data.name}:`,n),t.replied||t.deferred?await t.followUp({content:F,flags:y.Ephemeral}):await t.reply({content:F,flags:y.Ephemeral})}})});var T={};B(T,{default:()=>bt});import{Events as Et}from"discord.js";var bt,z=l(()=>{"use strict";$();d();x();bt=new u(Et.MessageCreate,!1,async function(e,t){if(t.author.bot)return;let r=e.client.prefix(new f(e.client,{message:t}));if(typeof r!="string"||r.length===0||!t.content.startsWith(r))return;let i=t.content.slice(r.length).trim().split(/ +/),n=i.shift()?.toLowerCase();if(!n)return;let o=e.client.aliases.findKey(g=>g.has(n)),h=new f(e.client,{message:t,args:i}),c=e.client.commands.get(o??n);if(!c){await t.reply({content:h.t("error:command.notfound",{defaultValue:p}),allowedMentions:{repliedUser:!1}}).then(N);return}if(!c.supportsPrefix){await t.reply({content:h.t("error:command.disabled",{defaultValue:p}),allowedMentions:{repliedUser:!1}}).then(N);return}try{e.logger.debug(`${h.author?.tag??"Unknown"} used ${c.data.name}(message)`),c._onMessage&&await c._onMessage(h.toJSON())}catch(g){e.client.logger.error(`Error executing command ${c.data.name}:`,g)}})});import{Client as Mt,Collection as V,REST as Ct,Routes as xt}from"discord.js";import{existsSync as yt}from"node:fs";import H from"node:path";import{pathToFileURL as At}from"node:url";var Dt,K,q=l(()=>{"use strict";x();d();Dt={includePaths:["events","commands"],autoRegisterCommands:!0,getDefaultLang:v},K=class extends Mt{logger;commands;aliases;prefix;i18n;constructor(t){super({...Dt,...t}),this.logger=new E(t.logger),this.commands=new V,this.aliases=new V,this.prefix=this.options.prefix??(()=>!1),this.options.i18n&&(this.i18n=this.options.i18n,this.i18n.use(new C(this.logger)))}async login(t){await this.#r();for(let r of this.options.includePaths)try{let i=H.isAbsolute(r)?r:H.join(j(),r);await this.#t(i)}catch(i){this.logger.error(`Error loading ${r}:`,i)}return this.i18n&&!this.i18n.isInitialized&&await this.i18n.init(),super.login(t)}async#t(t){if(!yt(t)){this.logger.debug(`Directory not found: ${t}`);return}let r=U(t);for(let i of r)await this.#e(i)}async#r(){let t=[()=>Promise.resolve().then(()=>(J(),W)),()=>Promise.resolve().then(()=>(Y(),P))];for(let r of t){let i=await r();await this.#i(i,"[core]")}if(this.options.prefix){let r=await Promise.resolve().then(()=>(z(),T));await this.#i(r,"[core]")}}async#e(t){try{let r=At(t);r.searchParams.set("ts",Date.now().toString(36));let i=await import(r.href);await this.#i(i,t)}catch(r){this.logger.error(`Error loading file ${t}:`,r)}}async#i(t,r){let i=new Set;for(let n of Object.values(t))i.add(n);for(let n of i)await this.#s(n,r)}async#s(t,r){if(t!=null){if(Array.isArray(t)){for(let i of t)await this.#s(i,r);return}if(t instanceof b){t.attach(this);return}if(t instanceof u){t.attach(this);return}if(typeof t=="object"&&t!==null&&"attach"in t&&typeof t.attach=="function"){t.attach(this);return}if(typeof t=="function"){let i=await t(this);await this.#s(i,r);return}this.logger.debug(`Skipped unsupported export type in ${r}: ${typeof t}`)}}async registerCommands(){if(!this.token){this.logger.warn("registerCommands skipped: client token is not set.");return}if(!this.application){this.logger.warn("registerCommands skipped: client application is not ready.");return}let t=this.commands.filter(i=>i.supportsSlash).map(i=>i.data.toClientJSON(this)),r=new Ct({version:"10"}).setToken(this.token);try{this.logger.debug(`Started refreshing ${t.length} application (/) commands.`),await r.put(xt.applicationCommands(this.application.id),{body:t}),this.logger.info(`Loaded ${t.length} application (/) commands.`)}catch(i){this.logger.error("Failed to register commands:",i)}}}});var X=l(()=>{"use strict";q()});var b,Q,Z=l(()=>{"use strict";b=class{#t=null;#r=null;#e;#i;#s=!1;_onMessage;_onInteraction;get client(){if(!this.#t)throw new Error("Command is not attached to a client");return this.#t}get logger(){if(!this.#r)throw new Error("Command is not attached to a client");return this.#r}get supportsSlash(){return this.#e&&this._onInteraction}get supportsPrefix(){return this.#i&&this._onMessage}constructor(t){this.data=t;let r=t.toJSON(),{name:i}=r;if(this.#i=r.prefix_support??!1,this.#e=r.slash_support??!1,!this.#i&&!this.#e)throw new Error(`Command ${i} must support either slash or prefix commands.`)}attach(t){if(this.#s)return this;let r=this.data.toJSON(),{name:i,aliases:n}=r;if(this.#t=t,this.#r=t.logger,t.commands.has(i))throw new Error(`Command name "${i}" is already registered.`);let o=t.aliases.findKey(h=>h.has(i));if(o)throw new Error(`Command name "${i}" is already registered as an alias for command "${o}".`);for(let h of n){if(t.commands.has(h))throw new Error(`Alias "${h}" is already registered as a command name.`);let c=t.aliases.findKey(g=>g.has(h));if(c)throw new Error(`Alias "${h}" is already registered as an alias for command "${c}".`)}return t.commands.set(i,this),n.length>0&&t.aliases.set(i,new Set(n)),this.logger.debug(`Loaded Command ${i}`),this.#s=!0,this}onMessage(t){return this._onMessage=t,this}onInteraction(t){return this._onInteraction=t,this}},Q=class extends b{constructor(t){super(t.data);let r=t.data.toJSON(),i=t.execute;(r.prefix_support??!1)&&(t.onMessage||i)&&this.onMessage(n=>t.onMessage?t.onMessage(n):i?.(n)),(r.slash_support??!1)&&(t.onInteraction||i)&&this.onInteraction(n=>t.onInteraction?t.onInteraction(n):i?.(n))}}});import{ChatInputCommandInteraction as Bt,Locale as It,Message as Ot}from"discord.js";var f,L=l(()=>{"use strict";f=class{args;data;locale;constructor(t,r){this.client=t,this.args=r.args??[],"interaction"in r?this.data=r.interaction:this.data=r.message,this.locale=this.client.options.getDefaultLang?.(this)}isInteraction(){return this.data instanceof Bt}isMessage(){return this.data instanceof Ot}get author(){return this.isInteraction()?this.data.user:this.isMessage()?this.data.author:null}t(t,r){if(!this.client.i18n)throw new Error("i18n is not initialized");let i=this.locale??this.client.options.getDefaultLang?.(this)??(Array.isArray(this.client.i18n.options.fallbackLng)?this.client.i18n.options.fallbackLng[0]:this.client.i18n.options.fallbackLng)??It.EnglishUS,o=this.client.i18n.getFixedT(i)(t,r);return o===t&&r?.defaultValue?r.defaultValue:o}toJSON(){let{data:t,args:r,author:i}=this;return this.isInteraction()?{kind:"interaction",interaction:t,author:i,t:(n,o)=>this.t(n,o)}:{kind:"message",message:t,args:r,author:i,t:(n,o)=>this.t(n,o)}}}});var u,tt=l(()=>{"use strict";u=class{#t=null;#r=null;#e;#i=!1;get client(){if(!this.#t)throw new Error("Event is not attached to a client");return this.#t}get logger(){if(!this.#r)throw new Error("Event is not attached to a client");return this.#r}#s=async(...t)=>{if(this.#t&&this.#e)try{await this.#e(this,...t)}catch(r){this.client.logger.error(`Error executing event ${this.name} (${this.constructor.name}):`,r)}};constructor(t,r=!1,i){this.name=t,this.once=r,i&&(this.#e=i)}#n(){this.#i||!this.#e||!this.#t||!this.#r||(this.once?this.client.once(this.name,this.#s):this.client.on(this.name,this.#s),this.#i=!0,this.logger.debug(`Loaded Event ${String(this.name)}`))}attach(t){return this.#t?this:(this.#t=t,this.#r=t.logger,this.#n(),this)}onExecute(t){return this.#e=t,this.#n(),this}}});function A(e){return Array.isArray(e[0])?[...e[0]]:e}var et=l(()=>{"use strict"});import{SlashCommandBuilder as Nt}from"discord.js";var rt,it=l(()=>{"use strict";et();rt=class extends Nt{prefix_support=!0;slash_support=!0;aliases=[];setAliases(...t){return this.aliases=A(t),this}addAliases(...t){return this.aliases=A([...this.aliases,...A(t)]),this}setPrefixSupport(t){return this.prefix_support=t,this}setSlashSupport(t){return this.slash_support=t,this}toJSON(){return super.toJSON()}toClientJSON(t){return{...this.toJSON()}}}});var st=l(()=>{"use strict";Z();L();tt();it()});var d=l(()=>{"use strict";X();st()});d();x();S();var $e="v0.1.2-beta.2";export{rt as ApplicationCommandBuilder,K as Client,Q as Command,b as CommandBuilder,f as Context,u as EventBuilder,C as I18nLoggerAdapter,s as LogLevel,E as Logger,w as LoggerLevel,M as LoggerStyle,Vt as LoggerStyleBackground,Tt as LoggerStyleEffect,zt as LoggerStyleText,R as LoggerTimestamp,at as allowedLocales,N as deleteMessageAfterSent,v as getDefaultLang,U as getFiles,j as getProjectRoot,O as toAllowedLocale,$e as version};
1
+ var Pt=Object.defineProperty;var W=(r=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(r,{get:(t,e)=>(typeof require<"u"?require:t)[e]}):r)(function(r){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+r+'" is not supported')});var c=(r,t)=>()=>(r&&(t=r(r=0)),t);var L=(r,t)=>{for(var e in t)Pt(r,e,{get:t[e],enumerable:!0})};import{Locale as nt}from"discord.js";function st(r){if(r==null)return"";let t;return typeof r=="string"?t=r:typeof r=="number"||typeof r=="boolean"||typeof r=="bigint"?t=`${r}`:r instanceof Date?t=r.toISOString():typeof r=="object"?t=JSON.stringify(r):typeof r=="symbol"?t=r.description?`Symbol(${r.description})`:"Symbol()":typeof r=="function"?t=r.name?`[Function: ${r.name}]`:"[Function]":t="",t.replaceAll("@","@\u200B")}function ot(r,t,e){let n=String(r),s=0,o="";for(;s<n.length;){let i=n.indexOf("{{",s);if(i===-1){o+=n.slice(s);break}o+=n.slice(s,i);let l=n.indexOf("}}",i+2);if(l===-1){o+=n.slice(i);break}let m=n.slice(i,l+2),p=n.slice(i+2,l),w=p.trim();if(!w||p.includes("{")||p.includes("}"))o+=m;else{let x=e(w,t);o+=typeof x=="string"?x:m}s=l+2}return o}function it(r){let t=String(r),e=new Set,n=0;for(;n<t.length;){let s=t.indexOf("{{",n);if(s===-1)break;let o=t.indexOf("}}",s+2);if(o===-1)break;let i=t.slice(s+2,o),l=i.trim();l&&!i.includes("{")&&!i.includes("}")&&e.add(l),n=o+2}return e}function Y(r,t=15e3){return new Promise(e=>{setTimeout(()=>{r.delete().catch(()=>{}),e()},t)})}function V(r){if(r&&Ut.has(r))return r}function at(r){return r.isInteraction()?V(r.data.locale)??V(r.data.guildLocale)??nt.EnglishUS:V(r.data.guild?.preferredLocale)??nt.EnglishUS}var vt,Ut,H=c(()=>{"use strict";vt=["id","en-US","en-GB","bg","zh-CN","zh-TW","hr","cs","da","nl","fi","fr","de","el","hi","hu","it","ja","ko","lt","no","pl","pt-BR","ro","ru","es-ES","es-419","sv-SE","th","tr","uk","vi"],Ut=new Set(vt)});import Gt from"fast-glob";import{existsSync as jt}from"node:fs";import b from"path";function lt(r){return Gt.sync(["**/*.ts","**/*.js","**/*.cjs","**/*.mjs"],{cwd:r,absolute:!0,ignore:["**/*.d.ts","node_modules/**",".git/**","dist/**","lib/**","out/**","build/**",".next/**","coverage/**"]})}function ct(){let r=[];r.push(b.resolve(process.cwd()));let t=typeof W<"u"?W.main?.filename:void 0;t&&r.push(b.dirname(b.resolve(t))),typeof module<"u"&&module.parent?.filename&&r.push(b.dirname(b.resolve(module.parent.filename)));for(let e of r){let n=Jt(e);if(n)return n}return r[0]}function Jt(r){let t=b.resolve(r);for(;;){let e=b.join(t,"package.json");if(jt(e))return b.normalize(t);let n=b.dirname(t);if(n===t)return null;t=n}}var ut=c(()=>{"use strict"});var a,X=c(()=>{"use strict";a=(function(r){return r[r.Trace=10]="Trace",r[r.Debug=20]="Debug",r[r.Info=30]="Info",r[r.Warn=40]="Warn",r[r.Error=50]="Error",r[r.Fatal=60]="Fatal",r[r.None=100]="None",r})({})});import{Console as Wt}from"console";import{inspect as Lt}from"util";import*as u from"colorette";import{Timestamp as Vt}from"@sapphire/timestamp";var A,k,q,E,Pe,ve,Ue,Ge,N,K=c(()=>{"use strict";X();X();A=class r{level;formats;join;depth;console;static instance=null;static LOG_METHODS=new Map([[a.Trace,"trace"],[a.Debug,"debug"],[a.Info,"info"],[a.Warn,"warn"],[a.Error,"error"],[a.Fatal,"error"]]);static DEFAULT_COLORS=new Map([[a.Trace,u.gray],[a.Debug,u.magenta],[a.Info,u.cyan],[a.Warn,u.yellow],[a.Error,u.red],[a.Fatal,u.bgRed],[a.None,u.white]]);static DEFAULT_NAMES=new Map([[a.Trace,"TRACE"],[a.Debug,"DEBUG"],[a.Info,"INFO"],[a.Warn,"WARN"],[a.Error,"ERROR"],[a.Fatal,"FATAL"],[a.None,""]]);constructor(t={}){this.level=t.level??a.Info,this.console=new Wt(t.stdout??process.stdout,t.stderr??process.stderr),this.formats=this.createFormatMap(t.format,t.defaultFormat??t.format?.none??{}),this.join=t.join??" ",this.depth=t.depth??2}static getInstance(){return this.instance||(this.instance=new r),this.instance}static get stylize(){return u.isColorSupported}setLevel(t){this.level=t}has(t){return t>=this.level}trace(...t){this.write(a.Trace,...t)}debug(...t){this.write(a.Debug,...t)}info(...t){this.write(a.Info,...t)}log(...t){this.write(a.Info,...t)}warn(...t){this.write(a.Warn,...t)}error(...t){this.write(a.Error,...t)}fatal(...t){this.write(a.Fatal,...t)}write(t,...e){if(t<this.level)return;let n=r.LOG_METHODS.get(t),o=(this.formats.get(t)??this.formats.get(a.None)).run(this.preprocess(e));switch(n){case"trace":this.console.trace(o);break;case"debug":this.console.debug(o);break;case"info":this.console.info(o);break;case"warn":this.console.warn(o);break;case"error":this.console.error(o);break;default:this.console.log(o)}}preprocess(t){let e={colors:u.isColorSupported,depth:this.depth};return t.map(n=>typeof n=="string"?n:Lt(n,e)).join(this.join)}createFormatMap(t={},e){let n=new Map;for(let[s,o]of r.DEFAULT_COLORS){let i=r.DEFAULT_NAMES.get(s),l=t[this.getLevelKey(s)]??this.createDefaultLevel(e,o,i??"");n.set(s,l instanceof E?l:new E(l))}return n}createDefaultLevel(t,e,n){return new E({...t,timestamp:t.timestamp===null?null:{...t.timestamp,color:e},infix:n.length?`${e(n.padEnd(5," "))} `:""})}getLevelKey(t){return{[a.Trace]:"trace",[a.Debug]:"debug",[a.Info]:"info",[a.Warn]:"warn",[a.Error]:"error",[a.Fatal]:"fatal",[a.None]:"none"}[t]}},k=class{style;constructor(t={}){if(typeof t=="function")this.style=t;else{let e=this.buildStyleArray(t);this.style=this.combineStyles(e)}}run(t){return this.style(String(t))}buildStyleArray(t){let e=[];return t.effects&&e.push(...t.effects.map(n=>u[n])),t.text&&e.push(u[t.text]),t.background&&e.push(u[t.background]),e}combineStyles(t){return t.length===0?u.reset:t.length===1?t[0]:(e=>t.reduce((n,s)=>s(n),e))}},q=class{timestamp;utc;color;formatter;constructor(t={}){this.timestamp=new Vt(t.pattern??"YYYY-MM-DD HH:mm:ss"),this.utc=t.utc??!1,this.color=t.color===null?null:new k(t.color),this.formatter=t.formatter??(e=>`${e} `)}run(){let t=new Date,e=this.utc?this.timestamp.displayUTC(t):this.timestamp.display(t);return this.formatter(this.color?this.color.run(e):e)}},E=class{timestamp;infix;message;constructor(t={}){this.timestamp=t.timestamp===null?null:new q(t.timestamp),this.infix=t.infix??"",this.message=t.message===null?null:new k(t.message)}run(t){let e=(this.timestamp?.run()??"")+this.infix;if(e.length){let n=this.message?s=>e+this.message?.run(s):s=>e+s;return t.split(`
2
+ `).map(n).join(`
3
+ `)}return this.message?this.message.run(t):t}},Pe=A.getInstance(),ve=(function(r){return r.Reset="reset",r.Bold="bold",r.Dim="dim",r.Italic="italic",r.Underline="underline",r.Inverse="inverse",r.Hidden="hidden",r.Strikethrough="strikethrough",r})({}),Ue=(function(r){return r.Black="black",r.Red="red",r.Green="green",r.Yellow="yellow",r.Blue="blue",r.Magenta="magenta",r.Cyan="cyan",r.White="white",r.Gray="gray",r.BlackBright="blackBright",r.RedBright="redBright",r.GreenBright="greenBright",r.YellowBright="yellowBright",r.BlueBright="blueBright",r.MagentaBright="magentaBright",r.CyanBright="cyanBright",r.WhiteBright="whiteBright",r})({}),Ge=(function(r){return r.Black="bgBlack",r.Red="bgRed",r.Green="bgGreen",r.Yellow="bgYellow",r.Blue="bgBlue",r.Magenta="bgMagenta",r.Cyan="bgCyan",r.White="bgWhite",r.BlackBright="bgBlackBright",r.RedBright="bgRedBright",r.GreenBright="bgGreenBright",r.YellowBright="bgYellowBright",r.BlueBright="bgBlueBright",r.MagentaBright="bgMagentaBright",r.CyanBright="bgCyanBright",r.WhiteBright="bgWhiteBright",r})({}),N=class{type="logger";constructor(t){this.logger=t}log(...t){this.logger.debug("[i18next]",...t)}warn(...t){this.logger.warn("[i18next]",...t)}error(...t){this.logger.error("[i18next]",...t)}}});var I=c(()=>{"use strict";H();ut();K()});var dt=c(()=>{"use strict"});var mt={};L(mt,{default:()=>Ht});import{Events as Yt}from"discord.js";var Ht,ht=c(()=>{"use strict";y();Ht=new g(Yt.ClientReady).onExecute(async function(r){r.client.options.autoRegisterCommands&&await r.client.registerCommands()})});var S,Q,Z=c(()=>{"use strict";S="Command not found or disabled.",Q="There was an error while executing this command!"});var pt={};L(pt,{default:()=>qt});import{Events as Xt,MessageFlags as T}from"discord.js";var qt,ft=c(()=>{"use strict";Z();y();qt=new g(Xt.InteractionCreate,!1).onExecute(async function(r,t){if(!t.isChatInputCommand())return;let e=r.client.resolveInteractionCommand(t.commandName),n=new C(r.client,{interaction:t});if(!e){await t.reply({content:n.t("error:command.notfound",{defaultValue:S}),flags:T.Ephemeral});return}if(!e.supportsSlash){await t.reply({content:n.t("error:command.disabled",{defaultValue:S}),flags:T.Ephemeral});return}try{r.logger.debug(`${n.author?.tag??"Unknown"} used ${e.data.name}(interaction)`),e._onInteraction&&await e._onInteraction(n.toJSON())}catch(s){r.client.logger.error(`Error executing command ${e.data.name}:`,s),t.replied||t.deferred?await t.followUp({content:Q,flags:T.Ephemeral}):await t.reply({content:Q,flags:T.Ephemeral})}})});var gt={};L(gt,{default:()=>Qt});import{Events as Kt}from"discord.js";var Qt,bt=c(()=>{"use strict";Z();y();I();Qt=new g(Kt.MessageCreate,!1,async function(r,t){if(t.author.bot)return;let e=r.client.prefix(new C(r.client,{message:t}));if(typeof e!="string"||e.length===0||!t.content.startsWith(e))return;let n=t.content.slice(e.length).trim().split(/ +/),s=n.shift();if(!s)return;let o=new C(r.client,{message:t,args:n}),i=r.client.resolveMessageCommand(s);if(!i){await t.reply({content:o.t("error:command.notfound",{defaultValue:S}),allowedMentions:{repliedUser:!1}}).then(Y);return}if(!i.supportsPrefix){await t.reply({content:o.t("error:command.disabled",{defaultValue:S}),allowedMentions:{repliedUser:!1}}).then(Y);return}try{r.logger.debug(`${o.author?.tag??"Unknown"} used ${i.data.name}(message)`),i._onMessage&&await i._onMessage(o.toJSON())}catch(l){r.client.logger.error(`Error executing command ${i.data.name}:`,l)}})});import{Client as Zt,Collection as te,REST as ee,Routes as re}from"discord.js";import{existsSync as ne}from"node:fs";import xt from"node:path";import{pathToFileURL as se}from"node:url";var oe,Ot,Ct=c(()=>{"use strict";I();dt();y();oe={includePaths:["events","commands"],autoRegisterCommands:!0,getDefaultLang:at},Ot=class extends Zt{logger;commands;slashCommandLookup=null;prefixCommandLookup=null;templateParsers=[];prefix;i18n;i18next;constructor(t){super({...oe,...t}),this.logger=new A(t.logger),this.commands=new te,this.prefix=this.options.prefix??(()=>!1),this.options.i18n&&(this.i18n=this.options.i18n,this.i18n.use(new N(this.logger))),this.i18next={instance:this.i18n,parser:{addParser:e=>{this.addTemplateParser(e)},removeParser:e=>this.removeTemplateParser(e),clearParsers:()=>{this.clearTemplateParsers()}}}}async login(t){await this.#e();for(let e of this.options.includePaths)try{let n=xt.isAbsolute(e)?e:xt.join(ct(),e);await this.#t(n)}catch(n){this.logger.error(`Error loading ${e}:`,n)}return this.i18n&&!this.i18n.isInitialized&&await this.i18n.init(),this.invalidateCommandLookupCache(),super.login(t)}async#t(t){if(!ne(t)){this.logger.debug(`Directory not found: ${t}`);return}let e=lt(t);for(let n of e)await this.#r(n)}async#e(){let t=[()=>Promise.resolve().then(()=>(ht(),mt)),()=>Promise.resolve().then(()=>(ft(),pt))];for(let e of t){let n=await e();await this.#n(n,"[core]")}if(this.options.prefix){let e=await Promise.resolve().then(()=>(bt(),gt));await this.#n(e,"[core]")}}async#r(t){try{let e=se(t);e.searchParams.set("ts",Date.now().toString(36));let n=await import(e.href);await this.#n(n,t)}catch(e){this.logger.error(`Error loading file ${t}:`,e)}}async#n(t,e){let n=new Set;for(let s of Object.values(t))n.add(s);for(let s of n)await this.registerExport(s,e)}async registerExport(t,e,n=0){if(t!=null){if(Array.isArray(t)){for(let s of t)await this.registerExport(s,e,n);return}if(t instanceof M){t.attach(this);return}if(t instanceof g){t.attach(this);return}if(typeof t=="object"&&"attach"in t&&typeof t.attach=="function"){await t.attach(this);return}if(typeof t=="function"){if(n>=16){this.logger.error(`Skipped export factory in ${e}: max depth (${16}) exceeded.`);return}let s=await t(this);await this.registerExport(s,e,n+1);return}this.logger.debug(`Skipped unsupported export type in ${e}: ${typeof t}`)}}normalizeCommandName(t){return t.trim().toLowerCase()}invalidateCommandLookupCache(){this.slashCommandLookup=null,this.prefixCommandLookup=null}addTemplateParser(t){this.templateParsers.includes(t)||this.templateParsers.push(t)}removeTemplateParser(t){let e=this.templateParsers.indexOf(t);return e===-1?!1:(this.templateParsers.splice(e,1),!0)}clearTemplateParsers(){this.templateParsers.length=0}parseTemplateToken(t,e){for(let n of this.templateParsers){let s=n(t,e);if(typeof s=="string")return s}}buildCommandLookup(t){let e=new Map;for(let n of this.commands.values()){if(t?!n.supportsPrefix:!n.supportsSlash)continue;let s=n.data.toClientJSON(this),o=Object.values(s.name_localizations??{}).filter(i=>typeof i=="string");for(let i of new Set([s.name,...o])){let l=this.normalizeCommandName(i),m=e.get(l);if(!m){e.set(l,n);continue}if(m!==n){let p=m.data.toJSON().name;this.logger.warn(`Command lookup conflict (${t?"prefix":"slash"}) for "${i}" (normalized: "${l}"): "${s.name}" conflicts with "${p}". Keeping "${p}".`)}}}return e}getSlashCommandLookup(){return this.slashCommandLookup||(this.slashCommandLookup=this.buildCommandLookup(!1)),this.slashCommandLookup}getPrefixCommandLookup(){return this.prefixCommandLookup||(this.prefixCommandLookup=this.buildCommandLookup(!0)),this.prefixCommandLookup}getSlashCommandsPayload(){return this.commands.filter(t=>t.supportsSlash).map(t=>t.data.toClientJSON(this))}resolveInteractionCommand(t){let e=this.normalizeCommandName(t),n=this.commands.get(e)??this.commands.get(t);return n?.supportsSlash?n:this.getSlashCommandLookup().get(e)}resolveMessageCommand(t){let e=this.normalizeCommandName(t),n=this.commands.get(e)??this.commands.get(t);return n?.supportsPrefix?n:this.getPrefixCommandLookup().get(e)}async registerCommands(){if(!this.token){this.logger.warn("registerCommands skipped: client token is not set.");return}if(!this.application){this.logger.warn("registerCommands skipped: client application is not ready.");return}let t=this.getSlashCommandsPayload(),e=new ee({version:"10"}).setToken(this.token);try{this.logger.debug(`Started refreshing ${t.length} application (/) commands.`),await e.put(re.applicationCommands(this.application.id),{body:t}),this.logger.info(`Loaded ${t.length} application (/) commands.`)}catch(n){this.logger.error("Failed to register commands:",n)}}}});var yt=c(()=>{"use strict";Ct()});var M,St,Et=c(()=>{"use strict";M=class{#t=null;#e=null;#r;#n;#s=!1;_onMessage;_onInteraction;createContextHandler(t,e){if(t)return n=>t(n);if(e)return n=>e(n)}get client(){if(!this.#t)throw new Error("Command is not attached to a client");return this.#t}get logger(){if(!this.#e)throw new Error("Command is not attached to a client");return this.#e}get supportsSlash(){return this.#r&&!!this._onInteraction}get supportsPrefix(){return this.#n&&!!this._onMessage}constructor(t){this.data=t;let e=t.toJSON(),{name:n}=e;if(this.#n=e.prefix_support??!1,this.#r=e.slash_support??!1,!this.#n&&!this.#r)throw new Error(`Command ${n} must support either slash or prefix commands.`)}attach(t){if(this.#s)return this;let e=this.data.toJSON(),{name:n}=e;if(this.#t=t,this.#e=t.logger,t.commands.has(n))throw new Error(`Command name "${n}" is already registered.`);return t.commands.set(n,this),t.invalidateCommandLookupCache(),this.logger.debug(`Loaded Command ${n}`),this.#s=!0,this}onMessage(t){return this._onMessage=t,this}onInteraction(t){return this._onInteraction=t,this}},St=class extends M{constructor(t){super(t.data);let e=t.data.toJSON();if(e.prefix_support){let n=this.createContextHandler(t.onMessage,t.execute);n&&this.onMessage(n)}if(e.slash_support){let n=this.createContextHandler(t.onInteraction,t.execute);n&&this.onInteraction(n)}}}});import{ChatInputCommandInteraction as ie,Locale as ae,Message as le}from"discord.js";var C,At=c(()=>{"use strict";H();C=class{args;data;locale;constructor(t,e){this.client=t,this.args=e.args??[],"interaction"in e?this.data=e.interaction:this.data=e.message,this.locale=this.client.options.getDefaultLang?.(this)}#t(){let t=this.client.i18n.options.fallbackLng;return(Array.isArray(t)?t[0]:t)??ae.EnglishUS}#e(){return this.locale??this.client.options.getDefaultLang?.(this)??this.#t()}#r(){return(t,e)=>this.t(t,e)}#n(){return(t,e)=>this.getDefaultLocalization(t,e)}#s(){return(t,e)=>this.getLocalizationAliases(t,e)}#o(t){return Array.isArray(t)?t.flatMap(e=>this.#o(e)).filter(e=>e.length>0):typeof t=="string"?t.split(/[,\n|]/g).map(e=>e.trim()).filter(e=>e.length>0):[]}isInteraction(){return this.data instanceof ie}isMessage(){return this.data instanceof le}get author(){return this.isInteraction()?this.data.user:this.isMessage()?this.data.author:null}resolveIdentityToken(t,e){if(t){if(e===""||e==="name"||e==="username")return st(t.username);if(e==="id")return t.id;if(e==="ping"||e==="mention")return`<@${t.id}>`}}resolveContextToken(t){let[e,...n]=t.toLowerCase().split("."),s=n.join("."),o=e.trim();if(o==="user"||o==="author")return this.resolveIdentityToken(this.author,s);if(o==="bot")return s==="ws.ping"?`${this.client.ws.ping}`:this.resolveIdentityToken(this.client.user,s)}resolveTemplateToken(t){return this.resolveContextToken(t)??this.client.parseTemplateToken(t,this)}t(t,e){if(!this.client.i18n)throw new Error("i18n is not initialized");let n=this.client.i18n.getFixedT(this.#e()),s=n(t,{...e,skipInterpolation:!0}),o=s===t&&e?.defaultValue?e.defaultValue:s,i=it(o),l=n(t,e),m=l===t&&e?.defaultValue?e.defaultValue:l;return i.size===0?m:ot(m,this,(p,w)=>{if(i.has(p))return w.resolveTemplateToken(p)})}getDefaultLocalization(t,e){if(!this.client.i18n)return e??t;let n=this.client.i18n.t(t,{lng:this.#t(),defaultValue:e??t});return typeof n=="string"?n:e??t}getLocalizationAliases(t,e){let n=this.#o(e??[]);if(!this.client.i18n)return n;let s=Array.from(new Set([this.#e(),this.#t()])),o=new Set;for(let i of s){let l=this.client.i18n.t(t,{lng:i,defaultValue:"",returnObjects:!0});for(let m of this.#o(l))m!==t&&o.add(m)}if(o.size===0)for(let i of n)o.add(i);return Array.from(o)}toJSON(){let{data:t,args:e,author:n}=this,s=this.#r(),o=this.#n(),i=this.#s();return this.isInteraction()?{kind:"interaction",interaction:t,author:n,t:s,getDefaultLocalization:o,getLocalizationAliases:i}:{kind:"message",message:t,args:e,author:n,t:s,getDefaultLocalization:o,getLocalizationAliases:i}}}});var g,Mt=c(()=>{"use strict";g=class{#t=null;#e=null;#r;#n=!1;get client(){if(!this.#t)throw new Error("Event is not attached to a client");return this.#t}get logger(){if(!this.#e)throw new Error("Event is not attached to a client");return this.#e}#s=async(...t)=>{if(this.#t&&this.#r)try{await this.#r(this,...t)}catch(e){this.client.logger.error(`Error executing event ${this.name} (${this.constructor.name}):`,e)}};constructor(t,e=!1,n){this.name=t,this.once=e,n&&(this.#r=n)}#o(){this.#n||!this.#r||!this.#t||!this.#e||(this.once?this.client.once(this.name,this.#s):this.client.on(this.name,this.#s),this.#n=!0,this.logger.debug(`Loaded Event ${String(this.name)}`))}attach(t){return this.#t?this:(this.#t=t,this.#e=t.logger,this.#o(),this)}onExecute(t){return this.#r=t,this.#o(),this}}});var h,d,kt=c(()=>{"use strict";h=(r,t)=>(r.setName(t),r.setDescription(t),r),d=(r,t)=>(r instanceof t||Object.setPrototypeOf(r,t.prototype),r)});import{ApplicationCommandOptionType as f}from"discord.js";var ce,ue,D,Nt,It,Tt=c(()=>{"use strict";ce={[f.User]:"user",[f.String]:"string",[f.Number]:"number",[f.Integer]:"number",[f.Boolean]:"boolean",[f.Role]:"role",[f.Channel]:"channel",[f.Mentionable]:"mentionable",[f.Attachment]:"attachment"},ue=r=>{let t=Object.keys(r.store.data),e=Array.isArray(r.options.supportedLngs)?r.options.supportedLngs.filter(n=>n!=="cimode"):[];return Array.from(new Set([...t,...e]))},D=(r,t,e)=>{let n={};for(let s of ue(r)){let o=r.t(t,{lng:s,defaultValue:e});n[s]=typeof o=="string"&&o.length>0?o:e}return n},Nt=(r,t,e)=>{let n;if(r.type===f.Subcommand)n=`${t}.subcommand.${r.name}`;else if(r.type===f.SubcommandGroup)n=`${t}.group.${r.name}`;else{let s=ce[r.type]??"option";n=`${t}.${s}.${r.name}`}r.name_localizations=D(e,`${n}.name`,r.name),typeof r.description=="string"&&(r.description_localizations=D(e,`${n}.description`,r.description));for(let s of r.options??[])Nt(s,n,e)},It=(r,t)=>{let e=`command:${r.name}`;r.name_localizations=D(t,`${e}.name`,r.name),r.description_localizations=D(t,`${e}.description`,r.description);for(let n of r.options??[])Nt(n,e,t);return r}});import{ApplicationCommandOptionType as z,SlashCommandAttachmentOption as de,SlashCommandBooleanOption as me,SlashCommandBuilder as he,SlashCommandChannelOption as pe,SlashCommandIntegerOption as fe,SlashCommandMentionableOption as ge,SlashCommandNumberOption as be,SlashCommandRoleOption as we,SlashCommandStringOption as xe,SlashCommandSubcommandBuilder as Oe,SlashCommandSubcommandGroupBuilder as Ce,SlashCommandUserOption as ye}from"discord.js";var B,R,$,_,F,P,v,U,G,j,tt,Dt,zt=c(()=>{"use strict";kt();Tt();B=class extends xe{autoSet(t){return h(this,t)}},R=class extends fe{autoSet(t){return h(this,t)}},$=class extends be{autoSet(t){return h(this,t)}},_=class extends me{autoSet(t){return h(this,t)}},F=class extends ye{autoSet(t){return h(this,t)}},P=class extends pe{autoSet(t){return h(this,t)}},v=class extends we{autoSet(t){return h(this,t)}},U=class extends ge{autoSet(t){return h(this,t)}},G=class extends de{autoSet(t){return h(this,t)}},j=class extends Oe{autoSet(t){return h(this,t)}addStringOption(t){return typeof t!="function"?super.addStringOption(t):super.addStringOption(e=>t(d(e,B)))}addIntegerOption(t){return typeof t!="function"?super.addIntegerOption(t):super.addIntegerOption(e=>t(d(e,R)))}addNumberOption(t){return typeof t!="function"?super.addNumberOption(t):super.addNumberOption(e=>t(d(e,$)))}addBooleanOption(t){return typeof t!="function"?super.addBooleanOption(t):super.addBooleanOption(e=>t(d(e,_)))}addUserOption(t){return typeof t!="function"?super.addUserOption(t):super.addUserOption(e=>t(d(e,F)))}addChannelOption(t){return typeof t!="function"?super.addChannelOption(t):super.addChannelOption(e=>t(d(e,P)))}addRoleOption(t){return typeof t!="function"?super.addRoleOption(t):super.addRoleOption(e=>t(d(e,v)))}addMentionableOption(t){return typeof t!="function"?super.addMentionableOption(t):super.addMentionableOption(e=>t(d(e,U)))}addAttachmentOption(t){return typeof t!="function"?super.addAttachmentOption(t):super.addAttachmentOption(e=>t(d(e,G)))}},tt=class extends Ce{autoSet(t){return h(this,t)}addSubcommand(t){return typeof t!="function"?super.addSubcommand(t):super.addSubcommand(e=>t(d(e,j)))}},Dt=class extends he{prefix_support=!0;slash_support=!0;setPrefixSupport(t=!0){return this.prefix_support=t,this}setSlashSupport(t=!0){return this.slash_support=t,this}autoSet(t){return h(this,t)}addStringOption(t){return typeof t!="function"?super.addStringOption(t):super.addStringOption(e=>t(d(e,B)))}addIntegerOption(t){return typeof t!="function"?super.addIntegerOption(t):super.addIntegerOption(e=>t(d(e,R)))}addNumberOption(t){return typeof t!="function"?super.addNumberOption(t):super.addNumberOption(e=>t(d(e,$)))}addBooleanOption(t){return typeof t!="function"?super.addBooleanOption(t):super.addBooleanOption(e=>t(d(e,_)))}addUserOption(t){return typeof t!="function"?super.addUserOption(t):super.addUserOption(e=>t(d(e,F)))}addChannelOption(t){return typeof t!="function"?super.addChannelOption(t):super.addChannelOption(e=>t(d(e,P)))}addRoleOption(t){return typeof t!="function"?super.addRoleOption(t):super.addRoleOption(e=>t(d(e,v)))}addMentionableOption(t){return typeof t!="function"?super.addMentionableOption(t):super.addMentionableOption(e=>t(d(e,U)))}addAttachmentOption(t){return typeof t!="function"?super.addAttachmentOption(t):super.addAttachmentOption(e=>t(d(e,G)))}addSubcommand(t){return typeof t!="function"?super.addSubcommand(t):super.addSubcommand(e=>t(d(e,j)))}addSubcommandGroup(t){return typeof t!="function"?super.addSubcommandGroup(t):super.addSubcommandGroup(e=>t(d(e,tt)))}toJSON(){let t=super.toJSON();return t.prefix_support=this.prefix_support,t.slash_support=this.slash_support,this.assertNoMixedTopLevelOptionTypes(t),t}toClientJSON(t){let e=this.toJSON();return t.i18n?It(e,t.i18n):e}assertNoMixedTopLevelOptionTypes(t){let e=t.options;if(!(!e||e.length===0||!e.some(o=>o.type===z.Subcommand||o.type===z.SubcommandGroup)||!e.some(o=>o.type!==z.Subcommand&&o.type!==z.SubcommandGroup)))throw new Error(`Command "${t.name}" mixes subcommands/subcommand groups with regular options at the top level. Discord requires choosing one structure.`)}}});var Bt=c(()=>{"use strict";Et();At();Mt();zt()});import{closest as Se,distance as Ee}from"fastest-levenshtein";var Rt,$t=c(()=>{"use strict";Rt=class r{args;normalizedArgs;constructor(t){this.ctx=t,this.args=t.args,this.normalizedArgs=this.args.map(e=>r.normalizeToken(e))}static normalizeToken(t){return String(t).trim().toLowerCase().normalize("NFD").replace(/[\u0300-\u036f]/g,"")}getAliases(t,e=[]){return this.ctx.getLocalizationAliases(t,e).map(n=>r.normalizeToken(n)).filter((n,s,o)=>n.length>0&&o.indexOf(n)===s)}findClosestAlias(t,e,n=1){if(!t||e.length===0)return null;let s=Se(t,e);return s&&Ee(t,s)<=n?s:null}matchesArg(t,e,n=[],s={}){let o=this.normalizedArgs[t];if(!o)return!1;let i=this.getAliases(e,n);return new Set(i).has(o)?!0:s.useFuzzy?this.findClosestAlias(o,i,s.maxDistance??1)!==null:!1}parseIntegerOption(t){let{key:e,fallbackAliases:n=[],defaultValue:s=0,startIndex:o=0,useFuzzy:i=!1,maxDistance:l=1}=t,m=this.getAliases(e,n),p=new Set(m),w=Number.parseInt(this.normalizedArgs[o+1]??"",10);if(Number.isFinite(w)&&w>=0)return w;for(let x=o+1;x<this.normalizedArgs.length;x+=1){let J=this.normalizedArgs[x],[et,rt]=J.split(":"),Ft=i?this.findClosestAlias(et,m,l):null;if(p.has(J)||i&&this.findClosestAlias(J,m,l)){let O=Number.parseInt(this.normalizedArgs[x+1]??"",10);if(Number.isFinite(O)&&O>=0)return O}if(rt&&(p.has(et)||Ft)){let O=Number.parseInt(rt,10);if(Number.isFinite(O)&&O>=0)return O}}return s}}});var _t=c(()=>{"use strict";$t()});var y=c(()=>{"use strict";yt();Bt();_t()});y();I();K();var Ur="v0.1.3";export{Dt as ApplicationCommandBuilder,G as AutoSlashCommandAttachmentOption,_ as AutoSlashCommandBooleanOption,P as AutoSlashCommandChannelOption,R as AutoSlashCommandIntegerOption,U as AutoSlashCommandMentionableOption,$ as AutoSlashCommandNumberOption,v as AutoSlashCommandRoleOption,B as AutoSlashCommandStringOption,j as AutoSlashCommandSubcommandBuilder,tt as AutoSlashCommandSubcommandGroupBuilder,F as AutoSlashCommandUserOption,Ot as Client,St as Command,M as CommandBuilder,C as Context,g as EventBuilder,N as I18nLoggerAdapter,a as LogLevel,A as Logger,E as LoggerLevel,k as LoggerStyle,Ge as LoggerStyleBackground,ve as LoggerStyleEffect,Ue as LoggerStyleText,q as LoggerTimestamp,Rt as MessageCommandParser,vt as allowedLocales,it as collectTemplateTokens,Y as deleteMessageAfterSent,at as getDefaultLang,lt as getFiles,ct as getProjectRoot,ot as parseThings,st as sanitizeDiscordText,V as toAllowedLocale,Ur as version};
@@ -1,18 +1,70 @@
1
- import { SlashCommandBuilder, RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord.js";
1
+ import { SlashCommandAttachmentOption, SlashCommandBooleanOption, SlashCommandBuilder, SlashCommandChannelOption, SlashCommandIntegerOption, SlashCommandMentionableOption, SlashCommandNumberOption, SlashCommandRoleOption, SlashCommandStringOption, SlashCommandSubcommandBuilder, SlashCommandSubcommandGroupBuilder, SlashCommandUserOption, type RESTPostAPIChatInputApplicationCommandsJSONBody } from "discord.js";
2
2
  import { Client } from "../core/index.js";
3
3
  export interface ApplicationJSONBody extends RESTPostAPIChatInputApplicationCommandsJSONBody {
4
4
  prefix_support: boolean;
5
5
  slash_support: boolean;
6
- aliases: string[];
6
+ }
7
+ export declare class AutoSlashCommandStringOption extends SlashCommandStringOption {
8
+ autoSet(key: string): this;
9
+ }
10
+ export declare class AutoSlashCommandIntegerOption extends SlashCommandIntegerOption {
11
+ autoSet(key: string): this;
12
+ }
13
+ export declare class AutoSlashCommandNumberOption extends SlashCommandNumberOption {
14
+ autoSet(key: string): this;
15
+ }
16
+ export declare class AutoSlashCommandBooleanOption extends SlashCommandBooleanOption {
17
+ autoSet(key: string): this;
18
+ }
19
+ export declare class AutoSlashCommandUserOption extends SlashCommandUserOption {
20
+ autoSet(key: string): this;
21
+ }
22
+ export declare class AutoSlashCommandChannelOption extends SlashCommandChannelOption {
23
+ autoSet(key: string): this;
24
+ }
25
+ export declare class AutoSlashCommandRoleOption extends SlashCommandRoleOption {
26
+ autoSet(key: string): this;
27
+ }
28
+ export declare class AutoSlashCommandMentionableOption extends SlashCommandMentionableOption {
29
+ autoSet(key: string): this;
30
+ }
31
+ export declare class AutoSlashCommandAttachmentOption extends SlashCommandAttachmentOption {
32
+ autoSet(key: string): this;
33
+ }
34
+ export declare class AutoSlashCommandSubcommandBuilder extends SlashCommandSubcommandBuilder {
35
+ autoSet(key: string): this;
36
+ addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): SlashCommandSubcommandBuilder;
37
+ addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): SlashCommandSubcommandBuilder;
38
+ addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): SlashCommandSubcommandBuilder;
39
+ addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): SlashCommandSubcommandBuilder;
40
+ addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): SlashCommandSubcommandBuilder;
41
+ addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): SlashCommandSubcommandBuilder;
42
+ addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): SlashCommandSubcommandBuilder;
43
+ addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): SlashCommandSubcommandBuilder;
44
+ addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): SlashCommandSubcommandBuilder;
45
+ }
46
+ export declare class AutoSlashCommandSubcommandGroupBuilder extends SlashCommandSubcommandGroupBuilder {
47
+ autoSet(key: string): this;
48
+ addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): this;
7
49
  }
8
50
  export declare class ApplicationCommandBuilder extends SlashCommandBuilder {
9
51
  protected prefix_support: boolean;
10
52
  protected slash_support: boolean;
11
- protected aliases: string[];
12
- setAliases(...alias: string[]): this;
13
- addAliases(...alias: string[]): this;
14
- setPrefixSupport(support: boolean): this;
15
- setSlashSupport(support: boolean): this;
53
+ setPrefixSupport(value?: boolean): this;
54
+ setSlashSupport(value?: boolean): this;
55
+ autoSet(key: string): this;
56
+ addStringOption(input: SlashCommandStringOption | ((builder: SlashCommandStringOption) => SlashCommandStringOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
57
+ addIntegerOption(input: SlashCommandIntegerOption | ((builder: SlashCommandIntegerOption) => SlashCommandIntegerOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
58
+ addNumberOption(input: SlashCommandNumberOption | ((builder: SlashCommandNumberOption) => SlashCommandNumberOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
59
+ addBooleanOption(input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
60
+ addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
61
+ addChannelOption(input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
62
+ addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
63
+ addMentionableOption(input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
64
+ addAttachmentOption(input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption)): import("discord.js").SlashCommandOptionsOnlyBuilder;
65
+ addSubcommand(input: SlashCommandSubcommandBuilder | ((subcommandGroup: SlashCommandSubcommandBuilder) => SlashCommandSubcommandBuilder)): import("discord.js").SlashCommandSubcommandsOnlyBuilder;
66
+ addSubcommandGroup(input: SlashCommandSubcommandGroupBuilder | ((subcommandGroup: SlashCommandSubcommandGroupBuilder) => SlashCommandSubcommandGroupBuilder)): import("discord.js").SlashCommandSubcommandsOnlyBuilder;
16
67
  toJSON(): ApplicationJSONBody;
17
68
  toClientJSON(_client: Client): ReturnType<ApplicationCommandBuilder["toJSON"]>;
69
+ private assertNoMixedTopLevelOptionTypes;
18
70
  }
@@ -11,10 +11,11 @@ export declare class CommandBuilder {
11
11
  readonly data: ApplicationCommandBuilder;
12
12
  _onMessage?: (ctx: MessageContext) => MaybePromise<void>;
13
13
  _onInteraction?: (ctx: InteractionContext) => MaybePromise<void>;
14
+ protected createContextHandler<T extends CommandContext>(primary: ((ctx: T) => MaybePromise<void>) | undefined, fallback: ((ctx: CommandContext) => MaybePromise<void>) | undefined): ((ctx: T) => MaybePromise<void>) | undefined;
14
15
  get client(): Client;
15
16
  get logger(): Logger;
16
- get supportsSlash(): false | ((ctx: InteractionContext) => MaybePromise<void>) | undefined;
17
- get supportsPrefix(): false | ((ctx: MessageContext) => MaybePromise<void>) | undefined;
17
+ get supportsSlash(): boolean;
18
+ get supportsPrefix(): boolean;
18
19
  constructor(data: ApplicationCommandBuilder);
19
20
  attach(client: Client): this;
20
21
  onMessage(func: (ctx: MessageContext) => MaybePromise<void>): this;
@@ -11,11 +11,15 @@ type ContextPayload<T extends ChatInputCommandInteraction | Message> = T extends
11
11
  type TranslateFn = (key: string, options?: TOptions & {
12
12
  defaultValue?: string;
13
13
  }) => string;
14
+ type DefaultLocalizationFn = (key: string, fallback?: string) => string;
15
+ type LocalizationAliasesFn = (key: string, fallback?: string | string[]) => string[];
14
16
  export interface InteractionContextJSON {
15
17
  kind: "interaction";
16
18
  interaction: ChatInputCommandInteraction;
17
19
  author: User | null;
18
20
  t: TranslateFn;
21
+ getDefaultLocalization: DefaultLocalizationFn;
22
+ getLocalizationAliases: LocalizationAliasesFn;
19
23
  }
20
24
  export interface MessageContextJSON {
21
25
  kind: "message";
@@ -23,8 +27,11 @@ export interface MessageContextJSON {
23
27
  args: string[];
24
28
  author: User | null;
25
29
  t: TranslateFn;
30
+ getDefaultLocalization: DefaultLocalizationFn;
31
+ getLocalizationAliases: LocalizationAliasesFn;
26
32
  }
27
33
  export declare class Context<T extends ChatInputCommandInteraction | Message> {
34
+ #private;
28
35
  readonly client: Client;
29
36
  readonly args: string[];
30
37
  readonly data: T;
@@ -33,9 +40,14 @@ export declare class Context<T extends ChatInputCommandInteraction | Message> {
33
40
  isInteraction(): this is Context<ChatInputCommandInteraction>;
34
41
  isMessage(): this is Context<Message>;
35
42
  get author(): User | null;
43
+ private resolveIdentityToken;
44
+ private resolveContextToken;
45
+ private resolveTemplateToken;
36
46
  t(key: string, options?: TOptions & {
37
47
  defaultValue?: string;
38
48
  }): string;
49
+ getDefaultLocalization(key: string, fallback?: string): string;
50
+ getLocalizationAliases(key: string, fallback?: string | string[]): string[];
39
51
  toJSON(this: Context<ChatInputCommandInteraction>): InteractionContextJSON;
40
52
  toJSON(this: Context<Message>): MessageContextJSON;
41
53
  }
@@ -1,4 +1,4 @@
1
- import { ClientEvents } from "discord.js";
1
+ import type { ClientEvents } from "discord.js";
2
2
  import type { MaybePromise } from "#types/extra.js";
3
3
  import { Client } from "../index.js";
4
4
  import { Logger } from "../../utils/index.js";
@@ -1,19 +1,42 @@
1
1
  import { Client as DiscordClient, Collection, IntentsBitField } from "discord.js";
2
2
  import type { i18n } from "i18next";
3
- import type { FrameworkOptions, PrefixFn } from "#types/client.js";
3
+ import type { FrameworkOptions, ModuleExport, PrefixFn, TemplateContext, TemplateParserFn } from "#types/client.js";
4
4
  import { Logger } from "../../utils/index.js";
5
5
  import { CommandBuilder } from "../index.js";
6
6
  export declare class Client<Ready extends boolean = boolean> extends DiscordClient<Ready> {
7
7
  #private;
8
8
  readonly logger: Logger;
9
9
  commands: Collection<string, CommandBuilder>;
10
- aliases: Collection<string, Set<string>>;
10
+ private slashCommandLookup;
11
+ private prefixCommandLookup;
12
+ private readonly templateParsers;
11
13
  readonly prefix: PrefixFn;
12
14
  i18n: i18n | undefined;
15
+ readonly i18next: {
16
+ readonly instance: i18n | undefined;
17
+ readonly parser: {
18
+ addParser: (parser: TemplateParserFn) => void;
19
+ removeParser: (parser: TemplateParserFn) => boolean;
20
+ clearParsers: () => void;
21
+ };
22
+ };
13
23
  options: Omit<FrameworkOptions, "intents"> & {
14
24
  intents: IntentsBitField;
15
25
  };
16
26
  constructor(opts: FrameworkOptions);
17
27
  login(token?: string): Promise<string>;
28
+ registerExport(exported: ModuleExport, source: string, factoryDepth?: number): Promise<void>;
29
+ private normalizeCommandName;
30
+ invalidateCommandLookupCache(): void;
31
+ addTemplateParser(parser: TemplateParserFn): void;
32
+ removeTemplateParser(parser: TemplateParserFn): boolean;
33
+ clearTemplateParsers(): void;
34
+ parseTemplateToken(key: string, context: TemplateContext): string | undefined;
35
+ private buildCommandLookup;
36
+ private getSlashCommandLookup;
37
+ private getPrefixCommandLookup;
38
+ getSlashCommandsPayload(): import("../index.js").ApplicationJSONBody[];
39
+ resolveInteractionCommand(commandName: string): CommandBuilder | undefined;
40
+ resolveMessageCommand(commandName: string): CommandBuilder | undefined;
18
41
  registerCommands(): Promise<void>;
19
42
  }
@@ -1,2 +1,3 @@
1
1
  export * from "./core/index.js";
2
2
  export * from "./builder/index.js";
3
+ export * from "./parser/index.js";
@@ -0,0 +1,25 @@
1
+ import type { MessageContextJSON } from "../builder/Context.js";
2
+ interface IntegerOptionConfig {
3
+ key: string;
4
+ fallbackAliases?: string[];
5
+ defaultValue?: number;
6
+ startIndex?: number;
7
+ useFuzzy?: boolean;
8
+ maxDistance?: number;
9
+ }
10
+ interface MatchOptions {
11
+ useFuzzy?: boolean;
12
+ maxDistance?: number;
13
+ }
14
+ export declare class MessageCommandParser {
15
+ private readonly ctx;
16
+ readonly args: string[];
17
+ readonly normalizedArgs: string[];
18
+ constructor(ctx: MessageContextJSON);
19
+ static normalizeToken(value: string): string;
20
+ getAliases(key: string, fallbackAliases?: string[]): string[];
21
+ private findClosestAlias;
22
+ matchesArg(index: number, key: string, fallbackAliases?: string[], options?: MatchOptions): boolean;
23
+ parseIntegerOption(config: IntegerOptionConfig): number;
24
+ }
25
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./MessageCommandParser.js";
@@ -0,0 +1,3 @@
1
+ import type { i18n } from "i18next";
2
+ import type { ApplicationJSONBody } from "../structures/builder/Builder.js";
3
+ export declare const localizeApplicationCommand: (json: ApplicationJSONBody, instance: i18n) => ApplicationJSONBody;
@@ -0,0 +1,7 @@
1
+ type AutoSetTarget = {
2
+ setName(name: string): unknown;
3
+ setDescription(description: string): unknown;
4
+ };
5
+ export declare const applyAutoSet: <T extends AutoSetTarget>(target: T, key: string) => T;
6
+ export declare const asCustomBuilder: <T extends object>(builder: object, ctor: new () => T) => T;
7
+ export {};
@@ -27,7 +27,7 @@ export declare enum LogLevel {
27
27
  */
28
28
  Fatal = 60,
29
29
  /**
30
- * An unknown or uncategorized level.
30
+ * An uncategorized level.
31
31
  */
32
32
  None = 100
33
33
  }
@@ -3,10 +3,10 @@ import type { Color } from "colorette";
3
3
  import { Timestamp } from "@sapphire/timestamp";
4
4
  import type { ILogger } from "./ILogger.js";
5
5
  import { LogLevel } from "./ILogger.js";
6
- import type { LoggerLevelOptions, LoggerOptions, LoggerStyleResolvable, LoggerTimestampFormatter, LoggerTimestampOptions } from "#types/logger.js";
6
+ import type { LoggerLevelOptions, LoggerOptions, LoggerStyleResolvable, LoggerValues, LoggerTimestampFormatter, LoggerTimestampOptions } from "#types/logger.js";
7
7
  import type { LoggerModule } from "i18next";
8
8
  export { LogLevel } from "./ILogger.js";
9
- export type { LoggerFormatOptions, LoggerLevelOptions, LoggerOptions, LoggerStyleOptions, LoggerStyleResolvable, LoggerTimestampFormatter, LoggerTimestampOptions, } from "#types/logger.js";
9
+ export type { LoggerFormatOptions, LoggerLevelOptions, LoggerOptions, LoggerStyleOptions, LoggerStyleResolvable, LoggerValues, LoggerTimestampFormatter, LoggerTimestampOptions, } from "#types/logger.js";
10
10
  export declare class Logger implements ILogger {
11
11
  level: LogLevel;
12
12
  readonly formats: Map<LogLevel, LoggerLevel>;
@@ -22,15 +22,15 @@ export declare class Logger implements ILogger {
22
22
  static get stylize(): boolean;
23
23
  setLevel(level: LogLevel): void;
24
24
  has(level: LogLevel): boolean;
25
- trace(...values: readonly unknown[]): void;
26
- debug(...values: readonly unknown[]): void;
27
- info(...values: readonly unknown[]): void;
28
- log(...values: readonly unknown[]): void;
29
- warn(...values: readonly unknown[]): void;
30
- error(...values: readonly unknown[]): void;
31
- fatal(...values: readonly unknown[]): void;
32
- write(level: LogLevel, ...values: readonly unknown[]): void;
33
- protected preprocess(values: readonly unknown[]): string;
25
+ trace(...values: LoggerValues): void;
26
+ debug(...values: LoggerValues): void;
27
+ info(...values: LoggerValues): void;
28
+ log(...values: LoggerValues): void;
29
+ warn(...values: LoggerValues): void;
30
+ error(...values: LoggerValues): void;
31
+ fatal(...values: LoggerValues): void;
32
+ write(level: LogLevel, ...values: LoggerValues): void;
33
+ protected preprocess(values: LoggerValues): string;
34
34
  private createFormatMap;
35
35
  private createDefaultLevel;
36
36
  private getLevelKey;
@@ -110,7 +110,7 @@ export declare class I18nLoggerAdapter implements LoggerModule {
110
110
  private readonly logger;
111
111
  readonly type = "logger";
112
112
  constructor(logger: Logger);
113
- log(...args: unknown[]): void;
114
- warn(...args: unknown[]): void;
115
- error(...args: unknown[]): void;
113
+ log(...args: Parameters<LoggerModule["log"]>): void;
114
+ warn(...args: Parameters<LoggerModule["warn"]>): void;
115
+ error(...args: Parameters<LoggerModule["error"]>): void;
116
116
  }
@@ -1,6 +1,9 @@
1
1
  import { ChatInputCommandInteraction, InteractionResponse, Locale, Message } from "discord.js";
2
2
  import type { Context } from "../structures/index.js";
3
3
  export declare const allowedLocales: readonly ["id", "en-US", "en-GB", "bg", "zh-CN", "zh-TW", "hr", "cs", "da", "nl", "fi", "fr", "de", "el", "hi", "hu", "it", "ja", "ko", "lt", "no", "pl", "pt-BR", "ro", "ru", "es-ES", "es-419", "sv-SE", "th", "tr", "uk", "vi"];
4
+ export declare function sanitizeDiscordText(value: unknown): string;
5
+ export declare function parseThings<TContext>(value: string, ctx: TContext, resolver: (name: string, ctx: TContext) => string | undefined): string;
6
+ export declare function collectTemplateTokens(value: string): Set<string>;
4
7
  export declare function deleteMessageAfterSent(message: Message | InteractionResponse, time?: number): Promise<void>;
5
8
  export declare function toAllowedLocale(locale: string | null | undefined): `${Locale}` | undefined;
6
9
  export declare function getDefaultLang(ctx: Context<ChatInputCommandInteraction | Message>): `${Locale}`;
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@arox/framework","version":"0.1.2-beta.2","description":"","keywords":["arox","discord.js","framework"],"homepage":"https://github.com/AroxBot/framework#readme","bugs":{"url":"https://github.com/AroxBot/framework/issues"},"license":"Apache-2.0","author":"vrdons","contributors":["fhyrox"],"repository":{"type":"git","url":"git+https://github.com/AroxBot/framework.git"},"type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","imports":{"#types/*":"./types/*.d.ts"},"exports":{".":{"types":"./dist/index.d.ts","require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"default":"./dist/index.js"}},"dependencies":{"@sapphire/timestamp":"^1.0.5","colorette":"^2.0.20","fast-glob":"^3.3.3","i18next":"^25.8.0"},"peerDependencies":{"discord.js":">=14.25.1"}}
1
+ {"name":"@arox/framework","version":"0.1.3","description":"","keywords":["arox","discord.js","framework"],"homepage":"https://github.com/AroxBot/framework#readme","bugs":{"url":"https://github.com/AroxBot/framework/issues"},"license":"Apache-2.0","author":"vrdons","contributors":["fhyrox"],"repository":{"type":"git","url":"git+https://github.com/AroxBot/framework.git"},"type":"module","main":"dist/index.cjs","module":"dist/index.js","types":"dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"},"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"default":"./dist/index.js"}},"dependencies":{"@sapphire/timestamp":"^1.0.5","colorette":"^2.0.20","fast-glob":"^3.3.3","fastest-levenshtein":"^1.0.16","i18next":"^25.8.0"},"peerDependencies":{"discord.js":">=14.25.1"}}
package/types/client.d.ts CHANGED
@@ -7,11 +7,19 @@ import {
7
7
  import type { LoggerOptions } from "./logger.js";
8
8
  import { i18n } from "i18next";
9
9
  import type { Context } from "../src/structures/builder/Context.js";
10
+ import type { CommandBuilder } from "../src/structures/builder/Command.js";
11
+ import type { EventBuilder } from "../src/structures/builder/Event.js";
12
+ import type { Client } from "../src/structures/core/Client.js";
10
13
 
11
14
  export type PrefixFn = (ctx: Context<Message>) => string | false;
15
+ export type TemplateContext = Context<ChatInputCommandInteraction | Message>;
12
16
  export type GetDefaultLangFn = (
13
- ctx: Context<ChatInputCommandInteraction | Message>
17
+ ctx: TemplateContext
14
18
  ) => `${Locale}` | undefined;
19
+ export type TemplateParserFn = (
20
+ key: string,
21
+ context: TemplateContext
22
+ ) => string | undefined | null;
15
23
 
16
24
  export interface FrameworkOptions extends ClientOptions {
17
25
  logger?: LoggerOptions;
@@ -21,3 +29,24 @@ export interface FrameworkOptions extends ClientOptions {
21
29
  includePaths: string[];
22
30
  i18n?: i18n;
23
31
  }
32
+
33
+ export type AttachableExport = {
34
+ attach: (client: Client) => void | Promise<void>;
35
+ };
36
+
37
+ export type ModuleExport =
38
+ | CommandBuilder
39
+ | EventBuilder<keyof import("discord.js").ClientEvents>
40
+ | AttachableExport
41
+ | ModuleExportFactory
42
+ | readonly ModuleExport[]
43
+ | null
44
+ | undefined;
45
+
46
+ /**
47
+ * Factory function that produces module exports.
48
+ * The implementation must handle nested factories with appropriate depth limiting.
49
+ */
50
+ export type ModuleExportFactory = (
51
+ client: Client
52
+ ) => ModuleExport | Promise<ModuleExport>;
package/types/logger.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import type { Color } from "colorette";
2
+ import type { Console } from "node:console";
2
3
  import type { LogLevel } from "../src/utils/logger/ILogger.js";
3
4
  import type {
4
5
  LoggerStyleBackground,
@@ -8,13 +9,13 @@ import type {
8
9
 
9
10
  export interface ILogger {
10
11
  has(level: LogLevel): boolean;
11
- trace(...values: readonly unknown[]): void;
12
- debug(...values: readonly unknown[]): void;
13
- info(...values: readonly unknown[]): void;
14
- warn(...values: readonly unknown[]): void;
15
- error(...values: readonly unknown[]): void;
16
- fatal(...values: readonly unknown[]): void;
17
- write(level: LogLevel, ...values: readonly unknown[]): void;
12
+ trace(...values: LoggerValues): void;
13
+ debug(...values: LoggerValues): void;
14
+ info(...values: LoggerValues): void;
15
+ warn(...values: LoggerValues): void;
16
+ error(...values: LoggerValues): void;
17
+ fatal(...values: LoggerValues): void;
18
+ write(level: LogLevel, ...values: LoggerValues): void;
18
19
  }
19
20
 
20
21
  export interface LoggerOptions {
@@ -60,4 +61,6 @@ export interface LoggerStyleOptions {
60
61
  background?: LoggerStyleBackground;
61
62
  }
62
63
 
64
+ export type LoggerValues = Parameters<Console["log"]>;
65
+
63
66
  export type LoggerStyleResolvable = Color | LoggerStyleOptions;
File without changes