@arox/framework 0.1.2-beta.1 → 0.1.2-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/constants/messages.d.ts +2 -0
- package/dist/events/interaction.d.ts +4 -1
- package/dist/events/message.d.ts +4 -1
- package/dist/events/ready.d.ts +4 -1
- package/dist/index.cjs +3 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -1194
- package/dist/structures/builder/Builder.d.ts +1 -2
- package/dist/structures/builder/Command.d.ts +20 -9
- package/dist/structures/builder/Context.d.ts +21 -18
- package/dist/structures/builder/Event.d.ts +6 -5
- package/dist/structures/builder/index.d.ts +4 -4
- package/dist/structures/core/Client.d.ts +5 -5
- package/dist/structures/core/index.d.ts +1 -1
- package/dist/structures/index.d.ts +2 -2
- package/dist/utils/index.d.ts +3 -3
- package/dist/utils/logger/ILogger.d.ts +1 -43
- package/dist/utils/logger/Logger.d.ts +6 -42
- package/dist/utils/util.d.ts +5 -3
- package/package.json +1 -1
- package/types/client.d.ts +14 -13
- package/types/logger.d.ts +63 -0
- package/dist/context.d.ts +0 -4
package/dist/events/message.d.ts
CHANGED
package/dist/events/ready.d.ts
CHANGED
package/dist/index.cjs
ADDED
|
@@ -0,0 +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});
|
package/dist/index.d.cts
ADDED
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from "./structures";
|
|
2
|
-
export * from "./utils/
|
|
3
|
-
export * from "./
|
|
1
|
+
export * from "./structures/index.js";
|
|
2
|
+
export * from "./utils/index.js";
|
|
3
|
+
export * from "./utils/logger/Logger.js";
|
|
4
4
|
export declare const version = "[VI]{{version}}[/VI]";
|