commandkit 0.1.11-dev.20240203230231 → 0.1.11-dev.20241214134338
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/bin/build.mjs +126 -0
- package/bin/common.mjs +125 -0
- package/bin/development.mjs +180 -0
- package/bin/index.mjs +53 -0
- package/bin/parse-env.mjs +65 -0
- package/bin/production.mjs +86 -0
- package/dist/{CommandKit-GIHMEeqf.d.ts → CommandKit-Co5QNlps.d.ts} +143 -144
- package/dist/{CommandKit--SA9LcIq.d.mts → CommandKit-D84HlsL0.d.mts} +143 -144
- package/dist/CommandKit.d.mts +1 -1
- package/dist/CommandKit.d.ts +1 -1
- package/dist/CommandKit.js +1 -1
- package/dist/CommandKit.js.map +1 -1
- package/dist/CommandKit.mjs +1 -1
- package/dist/{chunk-BXBLPEWT.mjs → chunk-6B4TPFI4.mjs} +2 -2
- package/dist/chunk-6B4TPFI4.mjs.map +1 -0
- package/dist/{chunk-R6PIHRXD.mjs → chunk-6J4XVVL4.mjs} +2 -2
- package/dist/{chunk-7KD7ZCH6.mjs → chunk-6TIBWNPX.mjs} +1 -1
- package/dist/{chunk-KUU3KDAE.mjs → chunk-7YWJADOI.mjs} +2 -2
- package/dist/{chunk-TZXZ3UZS.mjs → chunk-CATZUF3K.mjs} +2 -2
- package/dist/{chunk-KATLDJ7Z.mjs → chunk-EQ62HPWY.mjs} +2 -2
- package/dist/{chunk-Q7UFCVZL.mjs → chunk-FBYSGXIA.mjs} +2 -2
- package/dist/chunk-FBYSGXIA.mjs.map +1 -0
- package/dist/{chunk-6CLMSPNA.mjs → chunk-IHDVSF4H.mjs} +2 -2
- package/dist/{chunk-6CLMSPNA.mjs.map → chunk-IHDVSF4H.mjs.map} +1 -1
- package/dist/{chunk-RQQKHSL6.mjs → chunk-JWT7PUZJ.mjs} +2 -2
- package/dist/chunk-JWT7PUZJ.mjs.map +1 -0
- package/dist/{chunk-SYOEMO4R.mjs → chunk-KR3OAQKX.mjs} +2 -2
- package/dist/chunk-MTG5LNGD.mjs +2 -0
- package/dist/chunk-MTG5LNGD.mjs.map +1 -0
- package/dist/{chunk-77LPS2WP.mjs → chunk-PXNT5WYC.mjs} +2 -2
- package/dist/{chunk-CHI4NRSH.mjs → chunk-Q7JC46G6.mjs} +2 -2
- package/dist/chunk-Q7JC46G6.mjs.map +1 -0
- package/dist/chunk-VHU3SDTR.mjs +2 -0
- package/dist/{chunk-FQGSVSCT.mjs.map → chunk-VHU3SDTR.mjs.map} +1 -1
- package/dist/chunk-XVIYQWRZ.mjs +2 -0
- package/dist/{chunk-SXUJOOQY.mjs → chunk-Y7QBWZVQ.mjs} +2 -2
- package/dist/components/ButtonKit.js +1 -1
- package/dist/components/ButtonKit.js.map +1 -1
- package/dist/components/ButtonKit.mjs +1 -1
- package/dist/components/index.js +1 -1
- package/dist/components/index.js.map +1 -1
- package/dist/components/index.mjs +1 -1
- package/dist/config.d.mts +5 -7
- package/dist/config.d.ts +5 -7
- package/dist/config.js +1 -1
- package/dist/config.js.map +1 -1
- package/dist/config.mjs +1 -1
- package/dist/handlers/command-handler/CommandHandler.d.mts +1 -1
- package/dist/handlers/command-handler/CommandHandler.d.ts +1 -1
- package/dist/handlers/command-handler/CommandHandler.js +1 -1
- package/dist/handlers/command-handler/CommandHandler.js.map +1 -1
- package/dist/handlers/command-handler/CommandHandler.mjs +1 -1
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.mts +1 -1
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.d.ts +1 -1
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.js +1 -1
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.js.map +1 -1
- package/dist/handlers/command-handler/functions/loadCommandsWithRest.mjs +1 -1
- package/dist/handlers/command-handler/functions/registerCommands.d.mts +1 -1
- package/dist/handlers/command-handler/functions/registerCommands.d.ts +1 -1
- package/dist/handlers/command-handler/functions/registerCommands.js +1 -1
- package/dist/handlers/command-handler/functions/registerCommands.js.map +1 -1
- package/dist/handlers/command-handler/functions/registerCommands.mjs +1 -1
- package/dist/handlers/command-handler/typings.d.mts +1 -1
- package/dist/handlers/command-handler/typings.d.ts +1 -1
- package/dist/handlers/command-handler/typings.js.map +1 -1
- package/dist/handlers/command-handler/utils/areSlashCommandsDifferent.mjs +1 -1
- package/dist/handlers/command-handler/validations/devOnly.d.mts +1 -1
- package/dist/handlers/command-handler/validations/devOnly.d.ts +1 -1
- package/dist/handlers/command-handler/validations/devOnly.mjs +1 -1
- package/dist/handlers/command-handler/validations/index.d.mts +1 -1
- package/dist/handlers/command-handler/validations/index.d.ts +1 -1
- package/dist/handlers/command-handler/validations/index.mjs +1 -1
- package/dist/handlers/command-handler/validations/permissions.d.mts +1 -1
- package/dist/handlers/command-handler/validations/permissions.d.ts +1 -1
- package/dist/handlers/command-handler/validations/permissions.mjs +1 -1
- package/dist/handlers/event-handler/EventHandler.d.mts +1 -1
- package/dist/handlers/event-handler/EventHandler.d.ts +1 -1
- package/dist/handlers/event-handler/EventHandler.js +1 -1
- package/dist/handlers/event-handler/EventHandler.js.map +1 -1
- package/dist/handlers/event-handler/EventHandler.mjs +1 -1
- package/dist/handlers/event-handler/typings.d.mts +1 -1
- package/dist/handlers/event-handler/typings.d.ts +1 -1
- package/dist/handlers/index.d.mts +1 -1
- package/dist/handlers/index.d.ts +1 -1
- package/dist/handlers/index.js +1 -1
- package/dist/handlers/index.js.map +1 -1
- package/dist/handlers/index.mjs +1 -1
- package/dist/handlers/validation-handler/ValidationHandler.js +1 -1
- package/dist/handlers/validation-handler/ValidationHandler.js.map +1 -1
- package/dist/handlers/validation-handler/ValidationHandler.mjs +1 -1
- package/dist/index.d.mts +1 -12
- package/dist/index.d.ts +1 -12
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/types.d.mts +5 -0
- package/dist/types.d.ts +5 -0
- package/dist/{types/index.js → types.js} +1 -1
- package/dist/types.js.map +1 -0
- package/dist/types.mjs +2 -0
- package/dist/types.mjs.map +1 -0
- package/dist/utils/clone.mjs +1 -1
- package/dist/utils/colors.js +1 -1
- package/dist/utils/colors.js.map +1 -1
- package/dist/utils/colors.mjs +1 -1
- package/dist/utils/get-paths.mjs +1 -1
- package/dist/utils/resolve-file-url.mjs +1 -1
- package/package.json +7 -8
- package/bin/index.cjs +0 -3
- package/dist/bootstrap/client.d.mts +0 -13
- package/dist/bootstrap/client.d.ts +0 -13
- package/dist/bootstrap/client.js +0 -2
- package/dist/bootstrap/client.js.map +0 -1
- package/dist/bootstrap/client.mjs +0 -2
- package/dist/bootstrap/loadEnv.d.mts +0 -3
- package/dist/bootstrap/loadEnv.d.ts +0 -3
- package/dist/bootstrap/loadEnv.js +0 -2
- package/dist/bootstrap/loadEnv.js.map +0 -1
- package/dist/bootstrap/loadEnv.mjs +0 -2
- package/dist/bootstrap/loadEnv.mjs.map +0 -1
- package/dist/chunk-5AIBE2QR.mjs +0 -2
- package/dist/chunk-7KD7ZCH6.mjs.map +0 -1
- package/dist/chunk-BCQP4DZP.mjs +0 -2
- package/dist/chunk-BCQP4DZP.mjs.map +0 -1
- package/dist/chunk-BJCWVCAY.mjs +0 -2
- package/dist/chunk-BJCWVCAY.mjs.map +0 -1
- package/dist/chunk-BXBLPEWT.mjs.map +0 -1
- package/dist/chunk-CHI4NRSH.mjs.map +0 -1
- package/dist/chunk-DEB7FLUS.mjs +0 -2
- package/dist/chunk-DEB7FLUS.mjs.map +0 -1
- package/dist/chunk-FQGSVSCT.mjs +0 -2
- package/dist/chunk-IFTUM7TS.mjs +0 -2
- package/dist/chunk-IFTUM7TS.mjs.map +0 -1
- package/dist/chunk-Q7UFCVZL.mjs.map +0 -1
- package/dist/chunk-QC2F7O3S.mjs +0 -2
- package/dist/chunk-QC2F7O3S.mjs.map +0 -1
- package/dist/chunk-QYJ4DE3N.mjs +0 -2
- package/dist/chunk-QYJ4DE3N.mjs.map +0 -1
- package/dist/chunk-RQQKHSL6.mjs.map +0 -1
- package/dist/chunk-SB3FAFCD.mjs +0 -2
- package/dist/chunk-SB3FAFCD.mjs.map +0 -1
- package/dist/chunk-UV2LVAQV.mjs +0 -2
- package/dist/chunk-UV2LVAQV.mjs.map +0 -1
- package/dist/chunk-ZJRAI4W5.mjs +0 -2
- package/dist/chunk-ZJRAI4W5.mjs.map +0 -1
- package/dist/environment/actions/development.d.mts +0 -8
- package/dist/environment/actions/development.d.ts +0 -8
- package/dist/environment/actions/development.js +0 -2
- package/dist/environment/actions/development.js.map +0 -1
- package/dist/environment/actions/development.mjs +0 -2
- package/dist/environment/actions/development.mjs.map +0 -1
- package/dist/environment/bundler/bundle.d.mts +0 -3
- package/dist/environment/bundler/bundle.d.ts +0 -3
- package/dist/environment/bundler/bundle.js +0 -2
- package/dist/environment/bundler/bundle.js.map +0 -1
- package/dist/environment/bundler/bundle.mjs +0 -2
- package/dist/environment/bundler/bundle.mjs.map +0 -1
- package/dist/environment/bundler/shims.d.mts +0 -3
- package/dist/environment/bundler/shims.d.ts +0 -3
- package/dist/environment/bundler/shims.js +0 -11
- package/dist/environment/bundler/shims.js.map +0 -1
- package/dist/environment/bundler/shims.mjs +0 -11
- package/dist/environment/bundler/shims.mjs.map +0 -1
- package/dist/environment/cli.d.mts +0 -2
- package/dist/environment/cli.d.ts +0 -2
- package/dist/environment/cli.js +0 -2
- package/dist/environment/cli.js.map +0 -1
- package/dist/environment/cli.mjs +0 -2
- package/dist/environment/cli.mjs.map +0 -1
- package/dist/environment/common/config.d.mts +0 -7
- package/dist/environment/common/config.d.ts +0 -7
- package/dist/environment/common/config.js +0 -2
- package/dist/environment/common/config.js.map +0 -1
- package/dist/environment/common/config.mjs +0 -2
- package/dist/environment/common/config.mjs.map +0 -1
- package/dist/environment/common/logger.d.mts +0 -9
- package/dist/environment/common/logger.d.ts +0 -9
- package/dist/environment/common/logger.js +0 -2
- package/dist/environment/common/logger.js.map +0 -1
- package/dist/environment/common/logger.mjs +0 -2
- package/dist/environment/common/logger.mjs.map +0 -1
- package/dist/hooks/common.d.mts +0 -12
- package/dist/hooks/common.d.ts +0 -12
- package/dist/hooks/common.js +0 -11
- package/dist/hooks/common.js.map +0 -1
- package/dist/hooks/common.mjs +0 -2
- package/dist/hooks/common.mjs.map +0 -1
- package/dist/hooks/index.d.mts +0 -14
- package/dist/hooks/index.d.ts +0 -14
- package/dist/hooks/index.js +0 -11
- package/dist/hooks/index.js.map +0 -1
- package/dist/hooks/index.mjs +0 -2
- package/dist/hooks/index.mjs.map +0 -1
- package/dist/hooks/response.d.mts +0 -7
- package/dist/hooks/response.d.ts +0 -7
- package/dist/hooks/response.js +0 -11
- package/dist/hooks/response.js.map +0 -1
- package/dist/hooks/response.mjs +0 -2
- package/dist/hooks/response.mjs.map +0 -1
- package/dist/hooks/useChannel.d.mts +0 -5
- package/dist/hooks/useChannel.d.ts +0 -5
- package/dist/hooks/useChannel.js +0 -11
- package/dist/hooks/useChannel.js.map +0 -1
- package/dist/hooks/useChannel.mjs +0 -2
- package/dist/hooks/useChannel.mjs.map +0 -1
- package/dist/hooks/useClient.d.mts +0 -5
- package/dist/hooks/useClient.d.ts +0 -5
- package/dist/hooks/useClient.js +0 -11
- package/dist/hooks/useClient.js.map +0 -1
- package/dist/hooks/useClient.mjs +0 -2
- package/dist/hooks/useClient.mjs.map +0 -1
- package/dist/hooks/useCommandData.d.mts +0 -5
- package/dist/hooks/useCommandData.d.ts +0 -5
- package/dist/hooks/useCommandData.js +0 -11
- package/dist/hooks/useCommandData.js.map +0 -1
- package/dist/hooks/useCommandData.mjs +0 -2
- package/dist/hooks/useCommandData.mjs.map +0 -1
- package/dist/hooks/useCommandKit.d.mts +0 -9
- package/dist/hooks/useCommandKit.d.ts +0 -9
- package/dist/hooks/useCommandKit.js +0 -11
- package/dist/hooks/useCommandKit.js.map +0 -1
- package/dist/hooks/useCommandKit.mjs +0 -2
- package/dist/hooks/useCommandKit.mjs.map +0 -1
- package/dist/hooks/useGuild.d.mts +0 -5
- package/dist/hooks/useGuild.d.ts +0 -5
- package/dist/hooks/useGuild.js +0 -11
- package/dist/hooks/useGuild.js.map +0 -1
- package/dist/hooks/useGuild.mjs +0 -2
- package/dist/hooks/useGuild.mjs.map +0 -1
- package/dist/hooks/useInteraction.d.mts +0 -9
- package/dist/hooks/useInteraction.d.ts +0 -9
- package/dist/hooks/useInteraction.js +0 -11
- package/dist/hooks/useInteraction.js.map +0 -1
- package/dist/hooks/useInteraction.mjs +0 -2
- package/dist/hooks/useInteraction.mjs.map +0 -1
- package/dist/hooks/useMember.d.mts +0 -5
- package/dist/hooks/useMember.d.ts +0 -5
- package/dist/hooks/useMember.js +0 -11
- package/dist/hooks/useMember.js.map +0 -1
- package/dist/hooks/useMember.mjs +0 -2
- package/dist/hooks/useMember.mjs.map +0 -1
- package/dist/hooks/useUser.d.mts +0 -5
- package/dist/hooks/useUser.d.ts +0 -5
- package/dist/hooks/useUser.js +0 -11
- package/dist/hooks/useUser.js.map +0 -1
- package/dist/hooks/useUser.mjs +0 -2
- package/dist/hooks/useUser.mjs.map +0 -1
- package/dist/types/index.d.mts +0 -5
- package/dist/types/index.d.ts +0 -5
- package/dist/types/index.js.map +0 -1
- package/dist/types/index.mjs +0 -2
- package/dist/types/index.mjs.map +0 -1
- package/dist/typings.d.mts +0 -5
- package/dist/typings.d.ts +0 -5
- package/dist/typings.js +0 -2
- package/dist/typings.js.map +0 -1
- package/dist/typings.mjs +0 -1
- package/dist/typings.mjs.map +0 -1
- package/dist/utils/signal.d.mts +0 -21
- package/dist/utils/signal.d.ts +0 -21
- package/dist/utils/signal.js +0 -2
- package/dist/utils/signal.js.map +0 -1
- package/dist/utils/signal.mjs +0 -2
- package/dist/utils/signal.mjs.map +0 -1
- /package/dist/{chunk-R6PIHRXD.mjs.map → chunk-6J4XVVL4.mjs.map} +0 -0
- /package/dist/{bootstrap/client.mjs.map → chunk-6TIBWNPX.mjs.map} +0 -0
- /package/dist/{chunk-KUU3KDAE.mjs.map → chunk-7YWJADOI.mjs.map} +0 -0
- /package/dist/{chunk-TZXZ3UZS.mjs.map → chunk-CATZUF3K.mjs.map} +0 -0
- /package/dist/{chunk-KATLDJ7Z.mjs.map → chunk-EQ62HPWY.mjs.map} +0 -0
- /package/dist/{chunk-SYOEMO4R.mjs.map → chunk-KR3OAQKX.mjs.map} +0 -0
- /package/dist/{chunk-77LPS2WP.mjs.map → chunk-PXNT5WYC.mjs.map} +0 -0
- /package/dist/{chunk-5AIBE2QR.mjs.map → chunk-XVIYQWRZ.mjs.map} +0 -0
- /package/dist/{chunk-SXUJOOQY.mjs.map → chunk-Y7QBWZVQ.mjs.map} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var loadCommandsWithRest_exports={};__export(loadCommandsWithRest_exports,{default:()=>loadCommandsWithRest});module.exports=__toCommonJS(loadCommandsWithRest_exports);var resetColor="\x1B[0m",colors_default={reset:text=>`${text}${resetColor}`,bright:text=>`\x1B[1m${text}${resetColor}`,dim:text=>`\x1B[2m${text}${resetColor}`,underscore:text=>`\x1B[4m${text}${resetColor}`,blink:text=>`\x1B[5m${text}${resetColor}`,reverse:text=>`\x1B[7m${text}${resetColor}`,hidden:text=>`\x1B[8m${text}${resetColor}`,black:text=>`\x1B[30m${text}${resetColor}`,red:text=>`\x1B[31m${text}${resetColor}`,green:text=>`\x1B[32m${text}${resetColor}`,yellow:text=>`\x1B[33m${text}${resetColor}`,blue:text=>`\x1B[34m${text}${resetColor}`,magenta:text=>`\x1B[35m${text}${resetColor}`,cyan:text=>`\x1B[36m${text}${resetColor}`,white:text=>`\x1B[37m${text}${resetColor}`,bgBlack:text=>`\x1B[40m${text}${resetColor}`,bgRed:text=>`\x1B[41m${text}${resetColor}`,bgGreen:text=>`\x1B[42m${text}${resetColor}`,bgYellow:text=>`\x1B[43m${text}${resetColor}`,bgBlue:text=>`\x1B[44m${text}${resetColor}`,bgMagenta:text=>`\x1B[45m${text}${resetColor}`,bgCyan:text=>`\x1B[46m${text}${resetColor}`,bgWhite:text=>`\x1B[47m${text}${resetColor}
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var loadCommandsWithRest_exports={};__export(loadCommandsWithRest_exports,{default:()=>loadCommandsWithRest});module.exports=__toCommonJS(loadCommandsWithRest_exports);var resetColor="\x1B[0m",colors_default={reset:__name(text=>`${text}${resetColor}`,"reset"),bright:__name(text=>`\x1B[1m${text}${resetColor}`,"bright"),dim:__name(text=>`\x1B[2m${text}${resetColor}`,"dim"),underscore:__name(text=>`\x1B[4m${text}${resetColor}`,"underscore"),blink:__name(text=>`\x1B[5m${text}${resetColor}`,"blink"),reverse:__name(text=>`\x1B[7m${text}${resetColor}`,"reverse"),hidden:__name(text=>`\x1B[8m${text}${resetColor}`,"hidden"),black:__name(text=>`\x1B[30m${text}${resetColor}`,"black"),red:__name(text=>`\x1B[31m${text}${resetColor}`,"red"),green:__name(text=>`\x1B[32m${text}${resetColor}`,"green"),yellow:__name(text=>`\x1B[33m${text}${resetColor}`,"yellow"),blue:__name(text=>`\x1B[34m${text}${resetColor}`,"blue"),magenta:__name(text=>`\x1B[35m${text}${resetColor}`,"magenta"),cyan:__name(text=>`\x1B[36m${text}${resetColor}`,"cyan"),white:__name(text=>`\x1B[37m${text}${resetColor}`,"white"),bgBlack:__name(text=>`\x1B[40m${text}${resetColor}`,"bgBlack"),bgRed:__name(text=>`\x1B[41m${text}${resetColor}`,"bgRed"),bgGreen:__name(text=>`\x1B[42m${text}${resetColor}`,"bgGreen"),bgYellow:__name(text=>`\x1B[43m${text}${resetColor}`,"bgYellow"),bgBlue:__name(text=>`\x1B[44m${text}${resetColor}`,"bgBlue"),bgMagenta:__name(text=>`\x1B[45m${text}${resetColor}`,"bgMagenta"),bgCyan:__name(text=>`\x1B[46m${text}${resetColor}`,"bgCyan"),bgWhite:__name(text=>`\x1B[47m${text}${resetColor}`,"bgWhite")};async function loadCommandsWithRest(props){if(props.reloading)if(props.client.isReady())await handleLoading(props.client,props.commands,props.devGuildIds,props.reloading,props.type);else throw new Error(colors_default.red("Cannot reload commands when client is not ready."));else props.client.once("ready",async c=>{await handleLoading(c,props.commands,props.devGuildIds,props.reloading,props.type)})}__name(loadCommandsWithRest,"loadCommandsWithRest");async function handleLoading(client,commands,devGuildIds,reloading,type){commands=commands.filter(cmd=>!cmd.options?.deleted);let devOnlyCommands=commands.filter(cmd=>cmd.options?.devOnly),globalCommands=commands.filter(cmd=>!cmd.options?.devOnly);type==="dev"?await loadDevCommands(client,devOnlyCommands,devGuildIds,reloading):type==="global"?await loadGlobalCommands(client,globalCommands,reloading):(await loadDevCommands(client,devOnlyCommands,devGuildIds,reloading),await loadGlobalCommands(client,globalCommands,reloading))}__name(handleLoading,"handleLoading");async function loadGlobalCommands(client,commands,reloading){let requestBody=commands.map(cmd=>cmd.data);await client.application.commands.set(requestBody).catch(error=>{throw new Error(colors_default.red(`Error ${reloading?"reloading":"loading"} global application commands.
|
|
2
2
|
`),error)}),console.log(colors_default.green(`${reloading?"Reloaded":"Loaded"} ${requestBody.length} global commands.`))}__name(loadGlobalCommands,"loadGlobalCommands");async function loadDevCommands(client,commands,guildIds,reloading){let requestBody=commands.map(cmd=>cmd.data);for(let guildId of guildIds){let targetGuild=client.guilds.cache.get(guildId)||await client.guilds.fetch(guildId);if(!targetGuild){process.emitWarning(`Cannot ${reloading?"reload":"load"} commands in guild "${guildId}" - guild doesn't exist or client isn't part of the guild.`);continue}await targetGuild.commands.set(requestBody).catch(error=>{throw new Error(colors_default.red(`Error ${reloading?"reloading":"loading"} developer application commands in guild "${targetGuild?.name||guildId}".
|
|
3
3
|
`),error)}),console.log(colors_default.green(`${reloading?"Reloaded":"Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`))}}__name(loadDevCommands,"loadDevCommands");
|
|
4
4
|
//# sourceMappingURL=loadCommandsWithRest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/handlers/command-handler/functions/loadCommandsWithRest.ts","../../../../src/utils/colors.ts"],"sourcesContent":["import type { ApplicationCommandDataResolvable, Client } from 'discord.js';\nimport type { CommandFileObject, ReloadOptions } from '../../../
|
|
1
|
+
{"version":3,"sources":["../../../../src/handlers/command-handler/functions/loadCommandsWithRest.ts","../../../../src/utils/colors.ts"],"sourcesContent":["import type { ApplicationCommandDataResolvable, Client } from 'discord.js';\nimport type { CommandFileObject, ReloadOptions } from '../../../types';\n\nimport colors from '../../../utils/colors';\n\ntype LoadCommandsWithRestProps = {\n /**\n * The main client.\n */\n client: Client;\n\n /**\n * An array of command objects.\n */\n commands: CommandFileObject[];\n\n /**\n * An array of developer guild IDs.\n */\n devGuildIds: string[];\n\n /**\n * A boolean indicating whether these commands are reloading.\n */\n reloading?: boolean;\n\n /**\n * A type for reloading the commands (if this is reloading).\n */\n type?: ReloadOptions;\n};\n\n/**\n * Use REST to load commands.\n * @param props - Options for loading commands.\n */\nexport default async function loadCommandsWithRest(\n props: LoadCommandsWithRestProps,\n) {\n if (props.reloading) {\n if (props.client.isReady()) {\n await handleLoading(\n props.client,\n props.commands,\n props.devGuildIds,\n props.reloading,\n props.type,\n );\n } else {\n throw new Error(\n colors.red(`Cannot reload commands when client is not ready.`),\n );\n }\n } else {\n props.client.once('ready', async (c) => {\n await handleLoading(\n c,\n props.commands,\n props.devGuildIds,\n props.reloading,\n props.type,\n );\n });\n }\n}\n\n/**\n * Handles loading commands.\n * @param client - The discord.js client instance.\n * @param commands - An array of command file objects.\n * @param devGuildIds - An array of developer guild IDs.\n * @param reloading - A boolean indicating whether this is reloading.\n * @param type - A type for reloading the commands (if this is reloading).\n */\nasync function handleLoading(\n client: Client<true>,\n commands: CommandFileObject[],\n devGuildIds: string[],\n reloading?: boolean,\n type?: ReloadOptions,\n) {\n commands = commands.filter((cmd) => !cmd.options?.deleted);\n const devOnlyCommands = commands.filter((cmd) => cmd.options?.devOnly);\n const globalCommands = commands.filter((cmd) => !cmd.options?.devOnly);\n\n if (type === 'dev') {\n await loadDevCommands(client, devOnlyCommands, devGuildIds, reloading);\n } else if (type === 'global') {\n await loadGlobalCommands(client, globalCommands, reloading);\n } else {\n await loadDevCommands(client, devOnlyCommands, devGuildIds, reloading);\n await loadGlobalCommands(client, globalCommands, reloading);\n }\n}\n\n/**\n * Load commands globally.\n * @param client - The discord.js client instance.\n * @param commands - An array of command file objects.\n * @param reloading - A boolean indicating whether the commands are reloading.\n */\nasync function loadGlobalCommands(\n client: Client<true>,\n commands: CommandFileObject[],\n reloading?: boolean,\n) {\n const requestBody = commands.map((cmd) => cmd.data);\n\n await client.application.commands\n .set(requestBody as ApplicationCommandDataResolvable[])\n .catch((error) => {\n throw new Error(\n colors.red(\n `Error ${\n reloading ? 'reloading' : 'loading'\n } global application commands.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `${reloading ? 'Reloaded' : 'Loaded'} ${\n requestBody.length\n } global commands.`,\n ),\n );\n}\n\n/**\n * Load commands for dev guilds.\n * @param client - The discord.js client instance.\n * @param commands - An array of command file objects.\n * @param guildIds - An array of developer guild IDs.\n * @param reloading - A boolean indicating whether the commands are reloading.\n */\nasync function loadDevCommands(\n client: Client<true>,\n commands: CommandFileObject[],\n guildIds: string[],\n reloading?: boolean,\n) {\n const requestBody = commands.map((cmd) => cmd.data);\n\n for (const guildId of guildIds) {\n const targetGuild =\n client.guilds.cache.get(guildId) || (await client.guilds.fetch(guildId));\n\n if (!targetGuild) {\n process.emitWarning(\n `Cannot ${\n reloading ? 'reload' : 'load'\n } commands in guild \"${guildId}\" - guild doesn't exist or client isn't part of the guild.`,\n );\n\n continue;\n }\n\n await targetGuild.commands\n .set(requestBody as ApplicationCommandDataResolvable[])\n .catch((error) => {\n throw new Error(\n colors.red(\n `Error ${\n reloading ? 'reloading' : 'loading'\n } developer application commands in guild \"${\n targetGuild?.name || guildId\n }\".\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `${reloading ? 'Reloaded' : 'Loaded'} ${\n requestBody.length\n } developer commands in guild \"${targetGuild.name}\".`,\n ),\n );\n }\n}\n","const resetColor = '\\x1b[0m';\n\nexport default {\n reset: (text: string) => `${text}${resetColor}`,\n bright: (text: string) => `\\x1b[1m${text}${resetColor}`,\n dim: (text: string) => `\\x1b[2m${text}${resetColor}`,\n underscore: (text: string) => `\\x1b[4m${text}${resetColor}`,\n blink: (text: string) => `\\x1b[5m${text}${resetColor}`,\n reverse: (text: string) => `\\x1b[7m${text}${resetColor}`,\n hidden: (text: string) => `\\x1b[8m${text}${resetColor}`,\n\n black: (text: string) => `\\x1b[30m${text}${resetColor}`,\n red: (text: string) => `\\x1b[31m${text}${resetColor}`,\n green: (text: string) => `\\x1b[32m${text}${resetColor}`,\n yellow: (text: string) => `\\x1b[33m${text}${resetColor}`,\n blue: (text: string) => `\\x1b[34m${text}${resetColor}`,\n magenta: (text: string) => `\\x1b[35m${text}${resetColor}`,\n cyan: (text: string) => `\\x1b[36m${text}${resetColor}`,\n white: (text: string) => `\\x1b[37m${text}${resetColor}`,\n\n bgBlack: (text: string) => `\\x1b[40m${text}${resetColor}`,\n bgRed: (text: string) => `\\x1b[41m${text}${resetColor}`,\n bgGreen: (text: string) => `\\x1b[42m${text}${resetColor}`,\n bgYellow: (text: string) => `\\x1b[43m${text}${resetColor}`,\n bgBlue: (text: string) => `\\x1b[44m${text}${resetColor}`,\n bgMagenta: (text: string) => `\\x1b[45m${text}${resetColor}`,\n bgCyan: (text: string) => `\\x1b[46m${text}${resetColor}`,\n bgWhite: (text: string) => `\\x1b[47m${text}${resetColor}`,\n};\n"],"mappings":"ouBAAA,wKCAA,IAAM,WAAa,UAEZ,eAAQ,CACb,MAAO,OAAC,MAAiB,GAAG,IAAI,GAAG,UAAU,GAAtC,SACP,OAAQ,OAAC,MAAiB,UAAU,IAAI,GAAG,UAAU,GAA7C,UACR,IAAK,OAAC,MAAiB,UAAU,IAAI,GAAG,UAAU,GAA7C,OACL,WAAY,OAAC,MAAiB,UAAU,IAAI,GAAG,UAAU,GAA7C,cACZ,MAAO,OAAC,MAAiB,UAAU,IAAI,GAAG,UAAU,GAA7C,SACP,QAAS,OAAC,MAAiB,UAAU,IAAI,GAAG,UAAU,GAA7C,WACT,OAAQ,OAAC,MAAiB,UAAU,IAAI,GAAG,UAAU,GAA7C,UAER,MAAO,OAAC,MAAiB,WAAW,IAAI,GAAG,UAAU,GAA9C,SACP,IAAK,OAAC,MAAiB,WAAW,IAAI,GAAG,UAAU,GAA9C,OACL,MAAO,OAAC,MAAiB,WAAW,IAAI,GAAG,UAAU,GAA9C,SACP,OAAQ,OAAC,MAAiB,WAAW,IAAI,GAAG,UAAU,GAA9C,UACR,KAAM,OAAC,MAAiB,WAAW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iB,YAAa,SAAS,EAC5D,OAAS,SAClB,MAAM,mBAAmB,OAAQ,eAAgB,SAAS,GAE1D,MAAM,gBAAgB,OAAQ,gBAAiB,YAAa,SAAS,EACrE,MAAM,mBAAmB,OAAQ,eAAgB,SAAS,EAE9D,CAnBe,sCA2Bf,eAAe,mBACb,OACA,SACA,UACA,CACA,IAAM,YAAc,SAAS,IAAK,KAAQ,IAAI,IAAI,EAElD,MAAM,OAAO,YAAY,SACtB,IAAI,WAAiD,EACrD,MAAO,OAAU,CAChB,MAAM,IAAI,MACR,eAAO,IACL,SACE,UAAY,YAAc,SAC5B;AAAA,CACF,EACA,KACF,CACF,CAAC,EAEH,QAAQ,IACN,eAAO,MACL,GAAG,UAAY,WAAa,QAAQ,IAClC,YAAY,MACd,mBACF,CACF,CACF,CA3Be,gDAoCf,eAAe,gBACb,OACA,SACA,SACA,UACA,CACA,IAAM,YAAc,SAAS,IAAK,KAAQ,IAAI,IAAI,EAElD,QAAW,WAAW,SAAU,CAC9B,IAAM,YACJ,OAAO,OAAO,MAAM,IAAI,OAAO,GAAM,MAAM,OAAO,OAAO,MAAM,OAAO,EAExE,GAAI,CAAC,YAAa,CAChB,QAAQ,YACN,UACE,UAAY,SAAW,MACzB,uBAAuB,OAAO,4DAChC,EAEA,QACF,CAEA,MAAM,YAAY,SACf,IAAI,WAAiD,EACrD,MAAO,OAAU,CAChB,MAAM,IAAI,MACR,eAAO,IACL,SACE,UAAY,YAAc,SAC5B,6CACE,aAAa,MAAQ,OACvB;AAAA,CACF,EACA,KACF,CACF,CAAC,EAEH,QAAQ,IACN,eAAO,MACL,GAAG,UAAY,WAAa,QAAQ,IAClC,YAAY,MACd,iCAAiC,YAAY,IAAI,IACnD,CACF,CACF,CACF,CA7Ce","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{loadCommandsWithRest}from"../../../chunk-
|
|
1
|
+
import{loadCommandsWithRest}from"../../../chunk-JWT7PUZJ.mjs";import"../../../chunk-VHU3SDTR.mjs";import"../../../chunk-6TIBWNPX.mjs";export{loadCommandsWithRest as default};
|
|
2
2
|
//# sourceMappingURL=loadCommandsWithRest.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from 'discord.js';
|
|
2
|
-
import {
|
|
2
|
+
import { d as CommandFileObject, R as ReloadOptions } from '../../../CommandKit-D84HlsL0.mjs';
|
|
3
3
|
import '../../validation-handler/ValidationHandler.mjs';
|
|
4
4
|
import '../../validation-handler/typings.mjs';
|
|
5
5
|
import 'async_hooks';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Client } from 'discord.js';
|
|
2
|
-
import {
|
|
2
|
+
import { d as CommandFileObject, R as ReloadOptions } from '../../../CommandKit-Co5QNlps.js';
|
|
3
3
|
import '../../validation-handler/ValidationHandler.js';
|
|
4
4
|
import '../../validation-handler/typings.js';
|
|
5
5
|
import 'async_hooks';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var registerCommands_exports={};__export(registerCommands_exports,{default:()=>registerCommands});module.exports=__toCommonJS(registerCommands_exports);function areSlashCommandsDifferent(appCommand,localCommand){if(appCommand.options||(appCommand.options=[]),localCommand.options||(localCommand.options=[]),appCommand.description||(appCommand.description=""),localCommand.description||(localCommand.description=""),localCommand.description!==appCommand.description||localCommand.options.length!==appCommand.options.length)return!0}__name(areSlashCommandsDifferent,"areSlashCommandsDifferent");var resetColor="\x1B[0m",colors_default={reset:text=>`${text}${resetColor}`,bright:text=>`\x1B[1m${text}${resetColor}`,dim:text=>`\x1B[2m${text}${resetColor}`,underscore:text=>`\x1B[4m${text}${resetColor}`,blink:text=>`\x1B[5m${text}${resetColor}`,reverse:text=>`\x1B[7m${text}${resetColor}`,hidden:text=>`\x1B[8m${text}${resetColor}`,black:text=>`\x1B[30m${text}${resetColor}`,red:text=>`\x1B[31m${text}${resetColor}`,green:text=>`\x1B[32m${text}${resetColor}`,yellow:text=>`\x1B[33m${text}${resetColor}`,blue:text=>`\x1B[34m${text}${resetColor}`,magenta:text=>`\x1B[35m${text}${resetColor}`,cyan:text=>`\x1B[36m${text}${resetColor}`,white:text=>`\x1B[37m${text}${resetColor}`,bgBlack:text=>`\x1B[40m${text}${resetColor}`,bgRed:text=>`\x1B[41m${text}${resetColor}`,bgGreen:text=>`\x1B[42m${text}${resetColor}`,bgYellow:text=>`\x1B[43m${text}${resetColor}`,bgBlue:text=>`\x1B[44m${text}${resetColor}`,bgMagenta:text=>`\x1B[45m${text}${resetColor}`,bgCyan:text=>`\x1B[46m${text}${resetColor}`,bgWhite:text=>`\x1B[47m${text}${resetColor}
|
|
1
|
+
"use strict";var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var registerCommands_exports={};__export(registerCommands_exports,{default:()=>registerCommands});module.exports=__toCommonJS(registerCommands_exports);function areSlashCommandsDifferent(appCommand,localCommand){if(appCommand.options||(appCommand.options=[]),localCommand.options||(localCommand.options=[]),appCommand.description||(appCommand.description=""),localCommand.description||(localCommand.description=""),localCommand.description!==appCommand.description||localCommand.options.length!==appCommand.options.length)return!0}__name(areSlashCommandsDifferent,"areSlashCommandsDifferent");var resetColor="\x1B[0m",colors_default={reset:__name(text=>`${text}${resetColor}`,"reset"),bright:__name(text=>`\x1B[1m${text}${resetColor}`,"bright"),dim:__name(text=>`\x1B[2m${text}${resetColor}`,"dim"),underscore:__name(text=>`\x1B[4m${text}${resetColor}`,"underscore"),blink:__name(text=>`\x1B[5m${text}${resetColor}`,"blink"),reverse:__name(text=>`\x1B[7m${text}${resetColor}`,"reverse"),hidden:__name(text=>`\x1B[8m${text}${resetColor}`,"hidden"),black:__name(text=>`\x1B[30m${text}${resetColor}`,"black"),red:__name(text=>`\x1B[31m${text}${resetColor}`,"red"),green:__name(text=>`\x1B[32m${text}${resetColor}`,"green"),yellow:__name(text=>`\x1B[33m${text}${resetColor}`,"yellow"),blue:__name(text=>`\x1B[34m${text}${resetColor}`,"blue"),magenta:__name(text=>`\x1B[35m${text}${resetColor}`,"magenta"),cyan:__name(text=>`\x1B[36m${text}${resetColor}`,"cyan"),white:__name(text=>`\x1B[37m${text}${resetColor}`,"white"),bgBlack:__name(text=>`\x1B[40m${text}${resetColor}`,"bgBlack"),bgRed:__name(text=>`\x1B[41m${text}${resetColor}`,"bgRed"),bgGreen:__name(text=>`\x1B[42m${text}${resetColor}`,"bgGreen"),bgYellow:__name(text=>`\x1B[43m${text}${resetColor}`,"bgYellow"),bgBlue:__name(text=>`\x1B[44m${text}${resetColor}`,"bgBlue"),bgMagenta:__name(text=>`\x1B[45m${text}${resetColor}`,"bgMagenta"),bgCyan:__name(text=>`\x1B[46m${text}${resetColor}`,"bgCyan"),bgWhite:__name(text=>`\x1B[47m${text}${resetColor}`,"bgWhite")};async function registerCommands(props){if(props.reloading)if(props.client.isReady())await handleRegistration(props.client,props.commands,props.devGuildIds,props.type);else throw new Error(colors_default.red("Cannot reload commands when client is not ready."));else props.client.once("ready",async c=>{await handleRegistration(c,props.commands,props.devGuildIds,props.type)})}__name(registerCommands,"registerCommands");async function handleRegistration(client,commands,devGuildIds,type){let devOnlyCommands=commands.filter(cmd=>cmd.options?.devOnly),globalCommands=commands.filter(cmd=>!cmd.options?.devOnly);type==="dev"?await registerDevCommands(client,devOnlyCommands,devGuildIds):type==="global"?await registerGlobalCommands(client,globalCommands):(await registerDevCommands(client,devOnlyCommands,devGuildIds),await registerGlobalCommands(client,globalCommands))}__name(handleRegistration,"handleRegistration");async function registerGlobalCommands(client,commands){let appCommandsManager=client.application.commands;await appCommandsManager.fetch();for(let command of commands){let targetCommand=appCommandsManager.cache.find(cmd=>cmd.name===command.data.name);if(command.options?.deleted){targetCommand?(await targetCommand.delete().catch(error=>{throw new Error(colors_default.red(`Failed to delete command "${command.data.name}" globally.
|
|
2
2
|
`),error)}),console.log(colors_default.green(`Deleted command "${command.data.name}" globally.`))):process.emitWarning(colors_default.yellow(`Ignoring: Command "${command.data.name}" is globally marked as deleted.`));continue}if(targetCommand&&areSlashCommandsDifferent(targetCommand,command.data)){await targetCommand.edit(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to edit command "${command.data.name}" globally.
|
|
3
3
|
`),error)}),console.log(colors_default.green(`Edited command "${command.data.name}" globally.`));continue}targetCommand||(await appCommandsManager.create(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to register command "${command.data.name}" globally.
|
|
4
4
|
`),error)}),console.log(colors_default.green(`Registered command "${command.data.name}" globally.`)))}}__name(registerGlobalCommands,"registerGlobalCommands");async function registerDevCommands(client,commands,guildIds){let devGuilds=[];for(let guildId of guildIds){let guild=client.guilds.cache.get(guildId)||await client.guilds.fetch(guildId);if(!guild){process.emitWarning(colors_default.yellow(`Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.`));continue}devGuilds.push(guild)}let guildCommandsManagers=[];for(let guild of devGuilds){let guildCommandsManager=guild.commands;await guildCommandsManager.fetch(),guildCommandsManagers.push(guildCommandsManager)}for(let command of commands)for(let guildCommands of guildCommandsManagers){let targetCommand=guildCommands.cache.find(cmd=>cmd.name===command.data.name);if(command.options?.deleted){targetCommand?(await targetCommand.delete().catch(error=>{throw new Error(colors_default.red(`Failed to delete command "${command.data.name}" in ${guildCommands.guild.name}.`),error)}),console.log(colors_default.green(`Deleted command "${command.data.name}" in ${guildCommands.guild.name}.`))):process.emitWarning(colors_default.yellow(`Ignoring: Command "${command.data.name}" is marked as deleted in ${guildCommands.guild.name}.`));continue}if(targetCommand&&areSlashCommandsDifferent(targetCommand,command.data)){await targetCommand.edit(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to edit command "${command.data.name}" in ${guildCommands.guild.name}.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/handlers/command-handler/functions/registerCommands.ts","../../../../src/handlers/command-handler/utils/areSlashCommandsDifferent.ts","../../../../src/utils/colors.ts"],"sourcesContent":["import type {\n Guild,\n Client,\n ApplicationCommandData,\n GuildApplicationCommandManager,\n ApplicationCommandDataResolvable,\n} from 'discord.js';\nimport type { CommandFileObject, ReloadOptions } from '../../../typings';\n\nimport areSlashCommandsDifferent from '../utils/areSlashCommandsDifferent';\n\nimport colors from '../../../utils/colors';\n\ntype RegisterCommandProps = {\n client: Client;\n commands: CommandFileObject[];\n devGuildIds: string[];\n reloading?: boolean;\n type?: ReloadOptions;\n};\n\n/**\n * Register client commands to Discord.\n * @param props\n */\nexport default async function registerCommands(props: RegisterCommandProps) {\n if (props.reloading) {\n if (props.client.isReady()) {\n await handleRegistration(\n props.client,\n props.commands,\n props.devGuildIds,\n props.type,\n );\n } else {\n throw new Error(\n colors.red(`Cannot reload commands when client is not ready.`),\n );\n }\n } else {\n props.client.once('ready', async (c) => {\n await handleRegistration(\n c,\n props.commands,\n props.devGuildIds,\n props.type,\n );\n });\n }\n}\n\nasync function handleRegistration(\n client: Client<true>,\n commands: CommandFileObject[],\n devGuildIds: string[],\n type?: ReloadOptions,\n) {\n const devOnlyCommands = commands.filter((cmd) => cmd.options?.devOnly);\n const globalCommands = commands.filter((cmd) => !cmd.options?.devOnly);\n\n if (type === 'dev') {\n await registerDevCommands(client, devOnlyCommands, devGuildIds);\n } else if (type === 'global') {\n await registerGlobalCommands(client, globalCommands);\n } else {\n await registerDevCommands(client, devOnlyCommands, devGuildIds);\n await registerGlobalCommands(client, globalCommands);\n }\n}\n\nasync function registerGlobalCommands(\n client: Client<true>,\n commands: CommandFileObject[],\n) {\n const appCommandsManager = client.application.commands;\n await appCommandsManager.fetch();\n\n for (const command of commands) {\n const targetCommand = appCommandsManager.cache.find(\n (cmd) => cmd.name === command.data.name,\n );\n\n // <!-- Delete global command -->\n if (command.options?.deleted) {\n if (!targetCommand) {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Command \"${command.data.name}\" is globally marked as deleted.`,\n ),\n );\n } else {\n await targetCommand.delete().catch((error) => {\n throw new Error(\n colors.red(\n `Failed to delete command \"${command.data.name}\" globally.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(`Deleted command \"${command.data.name}\" globally.`),\n );\n }\n\n continue;\n }\n\n // <!-- Edit global command -->\n if (targetCommand) {\n const commandsAreDifferent = areSlashCommandsDifferent(\n targetCommand,\n command.data,\n );\n\n if (commandsAreDifferent) {\n await targetCommand\n .edit(command.data as Partial<ApplicationCommandData>)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to edit command \"${command.data.name}\" globally.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(`Edited command \"${command.data.name}\" globally.`),\n );\n\n continue;\n }\n }\n\n // <!-- Register global command -->\n if (targetCommand) continue;\n\n await appCommandsManager\n .create(command.data as ApplicationCommandDataResolvable)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to register command \"${command.data.name}\" globally.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(`Registered command \"${command.data.name}\" globally.`),\n );\n }\n}\n\nasync function registerDevCommands(\n client: Client<true>,\n commands: CommandFileObject[],\n guildIds: string[],\n) {\n const devGuilds: Guild[] = [];\n\n for (const guildId of guildIds) {\n const guild =\n client.guilds.cache.get(guildId) || (await client.guilds.fetch(guildId));\n\n if (!guild) {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.`,\n ),\n );\n continue;\n }\n\n devGuilds.push(guild);\n }\n\n const guildCommandsManagers: GuildApplicationCommandManager[] = [];\n\n for (const guild of devGuilds) {\n const guildCommandsManager = guild.commands;\n await guildCommandsManager.fetch();\n\n guildCommandsManagers.push(guildCommandsManager);\n }\n\n for (const command of commands) {\n for (const guildCommands of guildCommandsManagers) {\n const targetCommand = guildCommands.cache.find(\n (cmd) => cmd.name === command.data.name,\n );\n\n // <!-- Delete dev command -->\n if (command.options?.deleted) {\n if (!targetCommand) {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Command \"${command.data.name}\" is marked as deleted in ${guildCommands.guild.name}.`,\n ),\n );\n } else {\n await targetCommand.delete().catch((error) => {\n throw new Error(\n colors.red(\n `Failed to delete command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `Deleted command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n );\n }\n\n continue;\n }\n\n // <!-- Edit dev command -->\n if (targetCommand) {\n const commandsAreDifferent = areSlashCommandsDifferent(\n targetCommand,\n command.data,\n );\n\n if (commandsAreDifferent) {\n await targetCommand\n .edit(command.data as Partial<ApplicationCommandData>)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to edit command \"${command.data.name}\" in ${guildCommands.guild.name}.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `Edited command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n );\n\n continue;\n }\n }\n\n // <!-- Register guild command -->\n if (targetCommand) continue;\n\n await guildCommands\n .create(command.data as ApplicationCommandDataResolvable)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to register command \"${command.data.name}\" in ${guildCommands.guild.name}.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `Registered command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n );\n }\n }\n}\n","/**\n * Test if two slash commands are different.\n * @param appCommand - The application command.\n * @param localCommand - The local command.\n * @returns A boolean indicating whether these commands are different\n */\nexport default function areSlashCommandsDifferent(\n appCommand: any,\n localCommand: any,\n) {\n if (!appCommand.options) appCommand.options = [];\n if (!localCommand.options) localCommand.options = [];\n\n if (!appCommand.description) appCommand.description = '';\n if (!localCommand.description) localCommand.description = '';\n\n if (\n localCommand.description !== appCommand.description ||\n localCommand.options.length !== appCommand.options.length\n ) {\n return true;\n }\n}\n","const resetColor = '\\x1b[0m';\n\nexport default {\n reset: (text: string) => `${text}${resetColor}`,\n bright: (text: string) => `\\x1b[1m${text}${resetColor}`,\n dim: (text: string) => `\\x1b[2m${text}${resetColor}`,\n underscore: (text: string) => `\\x1b[4m${text}${resetColor}`,\n blink: (text: string) => `\\x1b[5m${text}${resetColor}`,\n reverse: (text: string) => `\\x1b[7m${text}${resetColor}`,\n hidden: (text: string) => `\\x1b[8m${text}${resetColor}`,\n\n black: (text: string) => `\\x1b[30m${text}${resetColor}`,\n red: (text: string) => `\\x1b[31m${text}${resetColor}`,\n green: (text: string) => `\\x1b[32m${text}${resetColor}`,\n yellow: (text: string) => `\\x1b[33m${text}${resetColor}`,\n blue: (text: string) => `\\x1b[34m${text}${resetColor}`,\n magenta: (text: string) => `\\x1b[35m${text}${resetColor}`,\n cyan: (text: string) => `\\x1b[36m${text}${resetColor}`,\n white: (text: string) => `\\x1b[37m${text}${resetColor}`,\n\n bgBlack: (text: string) => `\\x1b[40m${text}${resetColor}`,\n bgRed: (text: string) => `\\x1b[41m${text}${resetColor}`,\n bgGreen: (text: string) => `\\x1b[42m${text}${resetColor}`,\n bgYellow: (text: string) => `\\x1b[43m${text}${resetColor}`,\n bgBlue: (text: string) => `\\x1b[44m${text}${resetColor}`,\n bgMagenta: (text: string) => `\\x1b[45m${text}${resetColor}`,\n bgCyan: (text: string) => `\\x1b[46m${text}${resetColor}`,\n bgWhite: (text: string) => `\\x1b[47m${text}${resetColor}`,\n};\n"],"mappings":"ouBAAA,wJCMe,SAAR,0BACL,WACA,aACA,CAOA,GANK,WAAW,UAAS,WAAW,QAAU,CAAC,GAC1C,aAAa,UAAS,aAAa,QAAU,CAAC,GAE9C,WAAW,cAAa,WAAW,YAAc,IACjD,aAAa,cAAa,aAAa,YAAc,IAGxD,aAAa,cAAgB,WAAW,aACxC,aAAa,QAAQ,SAAW,WAAW,QAAQ,OAEnD,MAAO,EAEX,CAhBwB,8DCNxB,IAAM,WAAa,UAEZ,eAAQ,CACb,MAAQ,MAAiB,GAAG,IAAI,GAAG,UAAU,GAC7C,OAAS,MAAiB,UAAU,IAAI,GAAG,UAAU,GACrD,IAAM,MAAiB,UAAU,IAAI,GAAG,UAAU,GAClD,WAAa,MAAiB,UAAU,IAAI,GAAG,UAAU,GACzD,MAAQ,MAAiB,UAAU,IAAI,GAAG,UAAU,GACpD,QAAU,MAAiB,UAAU,IAAI,GAAG,UAAU,GACtD,OAAS,MAAiB,UAAU,IAAI,GAAG,UAAU,GAErD,MAAQ,MAAiB,WAAW,IAAI,GAAG,UAAU,GACrD,IAAM,MAAiB,WAAW,IAAI,GAAG,UAAU,GACnD,MAAQ,MAAiB,WAAW,IAAI,GAAG,UAAU,GACrD,OAAS,MAAiB,WAAW,IAAI,GAAG,UAAU,GACtD,KAAO,MAAiB,WAAW,IAAI,GAAG,UAAU,GACpD,QAAU,MAAiB,WAAW,IAAI,GAAG,UAAU,GACvD,KAAO,MAAiB,WAAW,IAAI,GAAG,UAAU,GACpD,MAAQ,MAAiB,WAAW,IAAI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command-handler/functions/registerCommands.ts","../../../../src/handlers/command-handler/utils/areSlashCommandsDifferent.ts","../../../../src/utils/colors.ts"],"sourcesContent":["import type {\n Guild,\n Client,\n ApplicationCommandData,\n GuildApplicationCommandManager,\n ApplicationCommandDataResolvable,\n} from 'discord.js';\nimport type { CommandFileObject, ReloadOptions } from '../../../types';\n\nimport areSlashCommandsDifferent from '../utils/areSlashCommandsDifferent';\n\nimport colors from '../../../utils/colors';\n\ntype RegisterCommandProps = {\n client: Client;\n commands: CommandFileObject[];\n devGuildIds: string[];\n reloading?: boolean;\n type?: ReloadOptions;\n};\n\n/**\n * Register client commands to Discord.\n * @param props\n */\nexport default async function registerCommands(props: RegisterCommandProps) {\n if (props.reloading) {\n if (props.client.isReady()) {\n await handleRegistration(\n props.client,\n props.commands,\n props.devGuildIds,\n props.type,\n );\n } else {\n throw new Error(\n colors.red(`Cannot reload commands when client is not ready.`),\n );\n }\n } else {\n props.client.once('ready', async (c) => {\n await handleRegistration(\n c,\n props.commands,\n props.devGuildIds,\n props.type,\n );\n });\n }\n}\n\nasync function handleRegistration(\n client: Client<true>,\n commands: CommandFileObject[],\n devGuildIds: string[],\n type?: ReloadOptions,\n) {\n const devOnlyCommands = commands.filter((cmd) => cmd.options?.devOnly);\n const globalCommands = commands.filter((cmd) => !cmd.options?.devOnly);\n\n if (type === 'dev') {\n await registerDevCommands(client, devOnlyCommands, devGuildIds);\n } else if (type === 'global') {\n await registerGlobalCommands(client, globalCommands);\n } else {\n await registerDevCommands(client, devOnlyCommands, devGuildIds);\n await registerGlobalCommands(client, globalCommands);\n }\n}\n\nasync function registerGlobalCommands(\n client: Client<true>,\n commands: CommandFileObject[],\n) {\n const appCommandsManager = client.application.commands;\n await appCommandsManager.fetch();\n\n for (const command of commands) {\n const targetCommand = appCommandsManager.cache.find(\n (cmd) => cmd.name === command.data.name,\n );\n\n // <!-- Delete global command -->\n if (command.options?.deleted) {\n if (!targetCommand) {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Command \"${command.data.name}\" is globally marked as deleted.`,\n ),\n );\n } else {\n await targetCommand.delete().catch((error) => {\n throw new Error(\n colors.red(\n `Failed to delete command \"${command.data.name}\" globally.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(`Deleted command \"${command.data.name}\" globally.`),\n );\n }\n\n continue;\n }\n\n // <!-- Edit global command -->\n if (targetCommand) {\n const commandsAreDifferent = areSlashCommandsDifferent(\n targetCommand,\n command.data,\n );\n\n if (commandsAreDifferent) {\n await targetCommand\n .edit(command.data as Partial<ApplicationCommandData>)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to edit command \"${command.data.name}\" globally.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(`Edited command \"${command.data.name}\" globally.`),\n );\n\n continue;\n }\n }\n\n // <!-- Register global command -->\n if (targetCommand) continue;\n\n await appCommandsManager\n .create(command.data as ApplicationCommandDataResolvable)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to register command \"${command.data.name}\" globally.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(`Registered command \"${command.data.name}\" globally.`),\n );\n }\n}\n\nasync function registerDevCommands(\n client: Client<true>,\n commands: CommandFileObject[],\n guildIds: string[],\n) {\n const devGuilds: Guild[] = [];\n\n for (const guildId of guildIds) {\n const guild =\n client.guilds.cache.get(guildId) || (await client.guilds.fetch(guildId));\n\n if (!guild) {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Guild ${guildId} doesn't exist or client isn't part of the guild.`,\n ),\n );\n continue;\n }\n\n devGuilds.push(guild);\n }\n\n const guildCommandsManagers: GuildApplicationCommandManager[] = [];\n\n for (const guild of devGuilds) {\n const guildCommandsManager = guild.commands;\n await guildCommandsManager.fetch();\n\n guildCommandsManagers.push(guildCommandsManager);\n }\n\n for (const command of commands) {\n for (const guildCommands of guildCommandsManagers) {\n const targetCommand = guildCommands.cache.find(\n (cmd) => cmd.name === command.data.name,\n );\n\n // <!-- Delete dev command -->\n if (command.options?.deleted) {\n if (!targetCommand) {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Command \"${command.data.name}\" is marked as deleted in ${guildCommands.guild.name}.`,\n ),\n );\n } else {\n await targetCommand.delete().catch((error) => {\n throw new Error(\n colors.red(\n `Failed to delete command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `Deleted command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n );\n }\n\n continue;\n }\n\n // <!-- Edit dev command -->\n if (targetCommand) {\n const commandsAreDifferent = areSlashCommandsDifferent(\n targetCommand,\n command.data,\n );\n\n if (commandsAreDifferent) {\n await targetCommand\n .edit(command.data as Partial<ApplicationCommandData>)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to edit command \"${command.data.name}\" in ${guildCommands.guild.name}.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `Edited command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n );\n\n continue;\n }\n }\n\n // <!-- Register guild command -->\n if (targetCommand) continue;\n\n await guildCommands\n .create(command.data as ApplicationCommandDataResolvable)\n .catch((error) => {\n throw new Error(\n colors.red(\n `Failed to register command \"${command.data.name}\" in ${guildCommands.guild.name}.\\n`,\n ),\n error,\n );\n });\n\n console.log(\n colors.green(\n `Registered command \"${command.data.name}\" in ${guildCommands.guild.name}.`,\n ),\n );\n }\n }\n}\n","/**\n * Test if two slash commands are different.\n * @param appCommand - The application command.\n * @param localCommand - The local command.\n * @returns A boolean indicating whether these commands are different\n */\nexport default function areSlashCommandsDifferent(\n appCommand: any,\n localCommand: any,\n) {\n if (!appCommand.options) appCommand.options = [];\n if (!localCommand.options) localCommand.options = [];\n\n if (!appCommand.description) appCommand.description = '';\n if (!localCommand.description) localCommand.description = '';\n\n if (\n localCommand.description !== appCommand.description ||\n localCommand.options.length !== appCommand.options.length\n ) {\n return true;\n }\n}\n","const resetColor = '\\x1b[0m';\n\nexport default {\n reset: (text: string) => `${text}${resetColor}`,\n bright: (text: string) => `\\x1b[1m${text}${resetColor}`,\n dim: (text: string) => `\\x1b[2m${text}${resetColor}`,\n underscore: (text: string) => `\\x1b[4m${text}${resetColor}`,\n blink: (text: string) => `\\x1b[5m${text}${resetColor}`,\n reverse: (text: string) => `\\x1b[7m${text}${resetColor}`,\n hidden: (text: string) => `\\x1b[8m${text}${resetColor}`,\n\n black: (text: string) => `\\x1b[30m${text}${resetColor}`,\n red: (text: string) => `\\x1b[31m${text}${resetColor}`,\n green: (text: string) => `\\x1b[32m${text}${resetColor}`,\n yellow: (text: string) => `\\x1b[33m${text}${resetColor}`,\n blue: (text: string) => `\\x1b[34m${text}${resetColor}`,\n magenta: (text: string) => `\\x1b[35m${text}${resetColor}`,\n cyan: (text: string) => `\\x1b[36m${text}${resetColor}`,\n white: (text: string) => `\\x1b[37m${text}${resetColor}`,\n\n bgBlack: (text: string) => `\\x1b[40m${text}${resetColor}`,\n bgRed: (text: string) => `\\x1b[41m${text}${resetColor}`,\n bgGreen: (text: string) => `\\x1b[42m${text}${resetColor}`,\n bgYellow: (text: string) => `\\x1b[43m${text}${resetColor}`,\n bgBlue: (text: string) => `\\x1b[44m${text}${resetColor}`,\n bgMagenta: (text: string) => `\\x1b[45m${text}${resetColor}`,\n bgCyan: (text: string) => `\\x1b[46m${text}${resetColor}`,\n bgWhite: (text: string) => `\\x1b[47m${text}${resetColor}`,\n};\n"],"mappings":"ouBAAA,wJCMe,SAAR,0BACL,WACA,aACA,CAOA,GANK,WAAW,UAAS,WAAW,QAAU,CAAC,GAC1C,aAAa,UAAS,aAAa,QAAU,CAAC,GAE9C,WAAW,cAAa,WAAW,YAAc,IACjD,aAAa,cAAa,aAAa,YAAc,IAGxD,aAAa,cAAgB,WAAW,aACxC,aAAa,QAAQ,SAAW,WAAW,QAAQ,OAEnD,MAAO,EAEX,CAhBwB,8DCNxB,IAAM,WAAa,UAEZ,eAAQ,CACb,MAAO,OAAC,MAAiB,GAAG,IAAI,GA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CACF,CAAC,EAED,QAAQ,IACN,eAAO,MACL,oBAAoB,QAAQ,KAAK,IAAI,QAAQ,cAAc,MAAM,IAAI,GACvE,CACF,GAnBA,QAAQ,YACN,eAAO,OACL,sBAAsB,QAAQ,KAAK,IAAI,6BAA6B,cAAc,MAAM,IAAI,GAC9F,CACF,EAkBF,QACF,CAGA,GAAI,eAC2B,0BAC3B,cACA,QAAQ,IACV,EAE0B,CACxB,MAAM,cACH,KAAK,QAAQ,IAAuC,EACpD,MAAO,OAAU,CAChB,MAAM,IAAI,MACR,eAAO,IACL,2BAA2B,QAAQ,KAAK,IAAI,QAAQ,cAAc,MAAM,IAAI;AAAA,CAC9E,EACA,KACF,CACF,CAAC,EAEH,QAAQ,IACN,eAAO,MACL,mBAAmB,QAAQ,KAAK,IAAI,QAAQ,cAAc,MAAM,IAAI,GACtE,CACF,EAEA,QACF,CAIE,gBAEJ,MAAM,cACH,OAAO,QAAQ,IAAwC,EACvD,MAAO,OAAU,CAChB,MAAM,IAAI,MACR,eAAO,IACL,+BAA+B,QAAQ,KAAK,IAAI,QAAQ,cAAc,MAAM,IAAI;AAAA,CAClF,EACA,KACF,CACF,CAAC,EAEH,QAAQ,IACN,eAAO,MACL,uBAAuB,QAAQ,KAAK,IAAI,QAAQ,cAAc,MAAM,IAAI,GAC1E,CACF,EACF,CAEJ,CApHe","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{registerCommands}from"../../../chunk-
|
|
1
|
+
import{registerCommands}from"../../../chunk-6B4TPFI4.mjs";import"../../../chunk-7YWJADOI.mjs";import"../../../chunk-VHU3SDTR.mjs";import"../../../chunk-6TIBWNPX.mjs";export{registerCommands as default};
|
|
2
2
|
//# sourceMappingURL=registerCommands.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export {
|
|
2
|
+
export { n as BuiltInValidation, B as BuiltInValidationParams, l as CommandHandlerData, k as CommandHandlerOptions, m as CommandKitInteraction } from '../../CommandKit-D84HlsL0.mjs';
|
|
3
3
|
import '../validation-handler/ValidationHandler.mjs';
|
|
4
4
|
import 'async_hooks';
|
|
5
5
|
import '../validation-handler/typings.mjs';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export {
|
|
2
|
+
export { n as BuiltInValidation, B as BuiltInValidationParams, l as CommandHandlerData, k as CommandHandlerOptions, m as CommandKitInteraction } from '../../CommandKit-Co5QNlps.js';
|
|
3
3
|
import '../validation-handler/ValidationHandler.js';
|
|
4
4
|
import 'async_hooks';
|
|
5
5
|
import '../validation-handler/typings.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/handlers/command-handler/typings.ts"],"sourcesContent":["import type {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ContextMenuCommandInteraction,\n} from 'discord.js';\nimport type { CommandKit } from '../../CommandKit';\nimport type { CommandFileObject } from '../../
|
|
1
|
+
{"version":3,"sources":["../../../src/handlers/command-handler/typings.ts"],"sourcesContent":["import type {\n AutocompleteInteraction,\n ChatInputCommandInteraction,\n Client,\n ContextMenuCommandInteraction,\n} from 'discord.js';\nimport type { CommandKit } from '../../CommandKit';\nimport type { CommandFileObject } from '../../types';\nimport type { ValidationHandler } from '../validation-handler/ValidationHandler';\n\n/**\n * Command handler options.\n * Similar to CommandKit options in structure.\n */\nexport interface CommandHandlerOptions {\n /**\n * The client created by the user.\n */\n client: Client;\n\n /**\n * Path to the user's commands.\n */\n commandsPath: string;\n\n /**\n * An array of developer guild IDs.\n */\n devGuildIds: string[];\n\n /**\n * An array of developer user IDs.\n */\n devUserIds: string[];\n\n /**\n * An array of developer role IDs.\n */\n devRoleIds: string[];\n\n /**\n * A validation handler instance to run validations before commands.\n */\n validationHandler?: ValidationHandler;\n\n /**\n * A boolean indicating whether to skip CommandKit's built-in validations (permission checking, etc.)\n */\n skipBuiltInValidations: boolean;\n\n /**\n * The CommandKit handler that instantiated this.\n */\n commandkitInstance: CommandKit;\n\n /**\n * A boolean indicating whether to register all commands in bulk.\n */\n bulkRegister: boolean;\n /**\n * Whether to enable hooks context.\n */\n enableHooks: boolean;\n}\n\n/**\n * Private command handler data.\n */\nexport interface CommandHandlerData extends CommandHandlerOptions {\n /**\n * An array of command file objects.\n */\n commands: CommandFileObject[];\n\n /**\n * An array of built-in validations.\n */\n builtInValidations: BuiltInValidation[];\n\n /**\n * A validation handler instance to run validations before commands.\n */\n validationHandler?: ValidationHandler;\n}\n\n/**\n * Parameters for CommandKit's built-in validations.\n */\nexport interface BuiltInValidationParams {\n /**\n * The target command to validate.\n */\n targetCommand: CommandFileObject;\n\n /**\n * The interaction of the target command.\n */\n interaction: CommandKitInteraction;\n\n /**\n * The command handler's data.\n */\n handlerData: CommandHandlerData;\n}\n\n/**\n * Represents a command interaction.\n */\nexport type CommandKitInteraction =\n | ChatInputCommandInteraction\n | ContextMenuCommandInteraction\n | AutocompleteInteraction;\n\n/**\n * A built in validation. Returns a boolean or void.\n */\nexport type BuiltInValidation = ({}: BuiltInValidationParams) => boolean | void;\n"],"mappings":"sjBAAA","names":[]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{areSlashCommandsDifferent}from"../../../chunk-
|
|
1
|
+
import{areSlashCommandsDifferent}from"../../../chunk-7YWJADOI.mjs";import"../../../chunk-6TIBWNPX.mjs";export{areSlashCommandsDifferent as default};
|
|
2
2
|
//# sourceMappingURL=areSlashCommandsDifferent.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuiltInValidationParams } from '../../../CommandKit
|
|
1
|
+
import { B as BuiltInValidationParams } from '../../../CommandKit-D84HlsL0.mjs';
|
|
2
2
|
import '../../validation-handler/ValidationHandler.mjs';
|
|
3
3
|
import '../../validation-handler/typings.mjs';
|
|
4
4
|
import 'discord.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuiltInValidationParams } from '../../../CommandKit-
|
|
1
|
+
import { B as BuiltInValidationParams } from '../../../CommandKit-Co5QNlps.js';
|
|
2
2
|
import '../../validation-handler/ValidationHandler.js';
|
|
3
3
|
import '../../validation-handler/typings.js';
|
|
4
4
|
import 'discord.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{devOnly_default}from"../../../chunk-
|
|
1
|
+
import{devOnly_default}from"../../../chunk-6J4XVVL4.mjs";import"../../../chunk-6TIBWNPX.mjs";export{devOnly_default as default};
|
|
2
2
|
//# sourceMappingURL=devOnly.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{validations_default}from"../../../chunk-
|
|
1
|
+
import{validations_default}from"../../../chunk-XVIYQWRZ.mjs";import"../../../chunk-6J4XVVL4.mjs";import"../../../chunk-Y7QBWZVQ.mjs";import"../../../chunk-6TIBWNPX.mjs";export{validations_default as default};
|
|
2
2
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuiltInValidationParams } from '../../../CommandKit
|
|
1
|
+
import { B as BuiltInValidationParams } from '../../../CommandKit-D84HlsL0.mjs';
|
|
2
2
|
import '../../validation-handler/ValidationHandler.mjs';
|
|
3
3
|
import '../../validation-handler/typings.mjs';
|
|
4
4
|
import 'discord.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { B as BuiltInValidationParams } from '../../../CommandKit-
|
|
1
|
+
import { B as BuiltInValidationParams } from '../../../CommandKit-Co5QNlps.js';
|
|
2
2
|
import '../../validation-handler/ValidationHandler.js';
|
|
3
3
|
import '../../validation-handler/typings.js';
|
|
4
4
|
import 'discord.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{permissions_default}from"../../../chunk-
|
|
1
|
+
import{permissions_default}from"../../../chunk-Y7QBWZVQ.mjs";import"../../../chunk-6TIBWNPX.mjs";export{permissions_default as default};
|
|
2
2
|
//# sourceMappingURL=permissions.mjs.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var EventHandler_exports={};__export(EventHandler_exports,{EventHandler:()=>EventHandler});module.exports=__toCommonJS(EventHandler_exports);var import_path=__toESM(require("path")),import_promises=__toESM(require("fs/promises"));async function getFilePaths(directory,nesting){let filePaths=[];if(!directory)return filePaths;let files=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let file of files){let filePath=import_path.default.join(directory,file.name);file.isFile()&&filePaths.push(filePath),nesting&&file.isDirectory()&&(filePaths=[...filePaths,...await getFilePaths(filePath,!0)])}return filePaths}__name(getFilePaths,"getFilePaths");async function getFolderPaths(directory,nesting){let folderPaths=[];if(!directory)return folderPaths;let folders=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let folder of folders){let folderPath=import_path.default.join(directory,folder.name);folder.isDirectory()&&(folderPaths.push(folderPath),nesting&&(folderPaths=[...folderPaths,...await getFolderPaths(folderPath,!0)]))}return folderPaths}__name(getFolderPaths,"getFolderPaths");var import_path2=__toESM(require("path"));function toFileURL(filePath){return"file://"+import_path2.default.resolve(filePath).replace(/\\\\|\\/g,"/")}__name(toFileURL,"toFileURL");var import_rfdc=__toESM(require("rfdc")),clone=(0,import_rfdc.default)();var resetColor="\x1B[0m",colors_default={reset:text=>`${text}${resetColor}`,bright:text=>`\x1B[1m${text}${resetColor}`,dim:text=>`\x1B[2m${text}${resetColor}`,underscore:text=>`\x1B[4m${text}${resetColor}`,blink:text=>`\x1B[5m${text}${resetColor}`,reverse:text=>`\x1B[7m${text}${resetColor}`,hidden:text=>`\x1B[8m${text}${resetColor}`,black:text=>`\x1B[30m${text}${resetColor}`,red:text=>`\x1B[31m${text}${resetColor}`,green:text=>`\x1B[32m${text}${resetColor}`,yellow:text=>`\x1B[33m${text}${resetColor}`,blue:text=>`\x1B[34m${text}${resetColor}`,magenta:text=>`\x1B[35m${text}${resetColor}`,cyan:text=>`\x1B[36m${text}${resetColor}`,white:text=>`\x1B[37m${text}${resetColor}`,bgBlack:text=>`\x1B[40m${text}${resetColor}`,bgRed:text=>`\x1B[41m${text}${resetColor}`,bgGreen:text=>`\x1B[42m${text}${resetColor}`,bgYellow:text=>`\x1B[43m${text}${resetColor}`,bgBlue:text=>`\x1B[44m${text}${resetColor}`,bgMagenta:text=>`\x1B[45m${text}${resetColor}`,bgCyan:text=>`\x1B[46m${text}${resetColor}`,bgWhite:text=>`\x1B[47m${text}${resetColor}
|
|
1
|
+
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var EventHandler_exports={};__export(EventHandler_exports,{EventHandler:()=>EventHandler});module.exports=__toCommonJS(EventHandler_exports);var import_path=__toESM(require("path")),import_promises=__toESM(require("fs/promises"));async function getFilePaths(directory,nesting){let filePaths=[];if(!directory)return filePaths;let files=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let file of files){let filePath=import_path.default.join(directory,file.name);file.isFile()&&filePaths.push(filePath),nesting&&file.isDirectory()&&(filePaths=[...filePaths,...await getFilePaths(filePath,!0)])}return filePaths}__name(getFilePaths,"getFilePaths");async function getFolderPaths(directory,nesting){let folderPaths=[];if(!directory)return folderPaths;let folders=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let folder of folders){let folderPath=import_path.default.join(directory,folder.name);folder.isDirectory()&&(folderPaths.push(folderPath),nesting&&(folderPaths=[...folderPaths,...await getFolderPaths(folderPath,!0)]))}return folderPaths}__name(getFolderPaths,"getFolderPaths");var import_path2=__toESM(require("path"));function toFileURL(filePath){return"file://"+import_path2.default.resolve(filePath).replace(/\\\\|\\/g,"/")}__name(toFileURL,"toFileURL");var import_rfdc=__toESM(require("rfdc")),clone=(0,import_rfdc.default)();var resetColor="\x1B[0m",colors_default={reset:__name(text=>`${text}${resetColor}`,"reset"),bright:__name(text=>`\x1B[1m${text}${resetColor}`,"bright"),dim:__name(text=>`\x1B[2m${text}${resetColor}`,"dim"),underscore:__name(text=>`\x1B[4m${text}${resetColor}`,"underscore"),blink:__name(text=>`\x1B[5m${text}${resetColor}`,"blink"),reverse:__name(text=>`\x1B[7m${text}${resetColor}`,"reverse"),hidden:__name(text=>`\x1B[8m${text}${resetColor}`,"hidden"),black:__name(text=>`\x1B[30m${text}${resetColor}`,"black"),red:__name(text=>`\x1B[31m${text}${resetColor}`,"red"),green:__name(text=>`\x1B[32m${text}${resetColor}`,"green"),yellow:__name(text=>`\x1B[33m${text}${resetColor}`,"yellow"),blue:__name(text=>`\x1B[34m${text}${resetColor}`,"blue"),magenta:__name(text=>`\x1B[35m${text}${resetColor}`,"magenta"),cyan:__name(text=>`\x1B[36m${text}${resetColor}`,"cyan"),white:__name(text=>`\x1B[37m${text}${resetColor}`,"white"),bgBlack:__name(text=>`\x1B[40m${text}${resetColor}`,"bgBlack"),bgRed:__name(text=>`\x1B[41m${text}${resetColor}`,"bgRed"),bgGreen:__name(text=>`\x1B[42m${text}${resetColor}`,"bgGreen"),bgYellow:__name(text=>`\x1B[43m${text}${resetColor}`,"bgYellow"),bgBlue:__name(text=>`\x1B[44m${text}${resetColor}`,"bgBlue"),bgMagenta:__name(text=>`\x1B[45m${text}${resetColor}`,"bgMagenta"),bgCyan:__name(text=>`\x1B[46m${text}${resetColor}`,"bgCyan"),bgWhite:__name(text=>`\x1B[47m${text}${resetColor}`,"bgWhite")};var EventHandler=class{static{__name(this,"EventHandler")}#data;constructor({...options}){this.#data={...options,events:[]}}async init(){await this.#buildEvents(),this.#registerEvents()}async#buildEvents(){let eventFolderPaths=await getFolderPaths(this.#data.eventsPath);for(let eventFolderPath of eventFolderPaths){let eventName=eventFolderPath.replace(/\\\\|\\/g,"/").split("/").pop(),allowedExtensions=/\.(js|mjs|cjs|ts)$/i,eventFilePaths=(await getFilePaths(eventFolderPath,!0)).filter(path3=>allowedExtensions.test(path3)),eventObj={name:eventName,functions:[]};this.#data.events.push(eventObj);for(let eventFilePath of eventFilePaths){let importedFunction=(await import(`${toFileURL(eventFilePath)}?t=${Date.now()}`)).default,eventFunction=clone(importedFunction);typeof module<"u"&&typeof require<"u"&&delete require.cache[require.resolve(eventFilePath)],eventFunction?.default&&(eventFunction=eventFunction.default);let compactFilePath=eventFilePath.split(process.cwd())[1]||eventFilePath;if(typeof eventFunction!="function"){process.emitWarning(colors_default.yellow(`Ignoring: Event file ${compactFilePath} does not export a function.`));continue}eventObj.functions.push(eventFunction)}}}#registerEvents(){let client=this.#data.client,handler=this.#data.commandKitInstance;for(let eventObj of this.#data.events)client.on(eventObj.name,async(...params)=>{for(let eventFunction of eventObj.functions)if(await eventFunction(...params,client,handler))break})}get events(){return this.#data.events}async reloadEvents(commandHandler){if(!this.#data.eventsPath)throw new Error(colors_default.red('Cannot reload events as "eventsPath" was not provided when instantiating CommandKit.'));this.#data.events=[],await this.#buildEvents(),this.#data.client.removeAllListeners(),this.#registerEvents(),commandHandler?.handleCommands()}};0&&(module.exports={EventHandler});
|
|
2
2
|
//# sourceMappingURL=EventHandler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/handlers/event-handler/EventHandler.ts","../../../src/utils/get-paths.ts","../../../src/utils/resolve-file-url.ts","../../../src/utils/clone.ts","../../../src/utils/colors.ts"],"sourcesContent":["import type { EventHandlerOptions, EventHandlerData } from './typings';\nimport type { CommandHandler } from '../command-handler/CommandHandler';\nimport { getFilePaths, getFolderPaths } from '../../utils/get-paths';\nimport { toFileURL } from '../../utils/resolve-file-url';\nimport { clone } from '../../utils/clone';\nimport colors from '../../utils/colors';\n\n/**\n * A handler for client events.\n */\nexport class EventHandler {\n #data: EventHandlerData;\n\n constructor({ ...options }: EventHandlerOptions) {\n this.#data = {\n ...options,\n events: [],\n };\n }\n\n async init() {\n await this.#buildEvents();\n this.#registerEvents();\n }\n\n async #buildEvents() {\n const eventFolderPaths = await getFolderPaths(this.#data.eventsPath);\n\n for (const eventFolderPath of eventFolderPaths) {\n const eventName = eventFolderPath\n .replace(/\\\\\\\\|\\\\/g, '/')\n .split('/')\n .pop() as string;\n\n const allowedExtensions = /\\.(js|mjs|cjs|ts)$/i;\n const eventPaths = await getFilePaths(eventFolderPath, true);\n\n const eventFilePaths = eventPaths.filter((path) =>\n allowedExtensions.test(path),\n );\n\n const eventObj = {\n name: eventName,\n functions: [] as Function[],\n };\n\n this.#data.events.push(eventObj);\n\n for (const eventFilePath of eventFilePaths) {\n const modulePath = toFileURL(eventFilePath);\n\n let importedFunction = (await import(`${modulePath}?t=${Date.now()}`))\n .default;\n let eventFunction = clone(importedFunction);\n\n // If it's CommonJS, invalidate the import cache\n if (typeof module !== 'undefined' && typeof require !== 'undefined') {\n delete require.cache[require.resolve(eventFilePath)];\n }\n\n if (eventFunction?.default) {\n eventFunction = eventFunction.default;\n }\n\n const compactFilePath =\n eventFilePath.split(process.cwd())[1] || eventFilePath;\n\n if (typeof eventFunction !== 'function') {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Event file ${compactFilePath} does not export a function.`,\n ),\n );\n continue;\n }\n\n eventObj.functions.push(eventFunction);\n }\n }\n }\n\n #registerEvents() {\n const client = this.#data.client;\n const handler = this.#data.commandKitInstance;\n\n for (const eventObj of this.#data.events) {\n client.on(eventObj.name, async (...params) => {\n for (const eventFunction of eventObj.functions) {\n const stopEventLoop = await eventFunction(...params, client, handler);\n\n if (stopEventLoop) {\n break;\n }\n }\n });\n }\n }\n\n get events() {\n return this.#data.events;\n }\n\n async reloadEvents(commandHandler?: CommandHandler) {\n if (!this.#data.eventsPath) {\n throw new Error(\n colors.red(\n 'Cannot reload events as \"eventsPath\" was not provided when instantiating CommandKit.',\n ),\n );\n }\n\n this.#data.events = [];\n\n await this.#buildEvents();\n\n this.#data.client.removeAllListeners();\n\n this.#registerEvents();\n\n // Re-register \"interactionCreate\" event for application commands.\n commandHandler?.handleCommands();\n }\n}\n","import path from 'path';\nimport fs from 'fs/promises';\n\nexport async function getFilePaths(\n directory: string,\n nesting?: boolean,\n): Promise<string[]> {\n let filePaths: string[] = [];\n\n if (!directory) return filePaths;\n\n const files = await fs.readdir(directory, { withFileTypes: true });\n\n for (const file of files) {\n const filePath = path.join(directory, file.name);\n\n if (file.isFile()) {\n filePaths.push(filePath);\n }\n\n if (nesting && file.isDirectory()) {\n filePaths = [...filePaths, ...(await getFilePaths(filePath, true))];\n }\n }\n\n return filePaths;\n}\n\nexport async function getFolderPaths(\n directory: string,\n nesting?: boolean,\n): Promise<string[]> {\n let folderPaths: string[] = [];\n\n if (!directory) return folderPaths;\n\n const folders = await fs.readdir(directory, { withFileTypes: true });\n\n for (const folder of folders) {\n const folderPath = path.join(directory, folder.name);\n\n if (folder.isDirectory()) {\n folderPaths.push(folderPath);\n\n if (nesting) {\n folderPaths = [\n ...folderPaths,\n ...(await getFolderPaths(folderPath, true)),\n ];\n }\n }\n }\n\n return folderPaths;\n}\n","import path from 'path';\n\n/**\n * Convert a local file path to a file URL.\n * @param filePath - The local file's path.\n * @returns - The converted file URL.\n */\nexport function toFileURL(filePath: string) {\n const resolvedPath = path.resolve(filePath);\n return 'file://' + resolvedPath.replace(/\\\\\\\\|\\\\/g, '/');\n}\n","import rfdc from 'rfdc';\n\nexport const clone = rfdc();\n","const resetColor = '\\x1b[0m';\n\nexport default {\n reset: (text: string) => `${text}${resetColor}`,\n bright: (text: string) => `\\x1b[1m${text}${resetColor}`,\n dim: (text: string) => `\\x1b[2m${text}${resetColor}`,\n underscore: (text: string) => `\\x1b[4m${text}${resetColor}`,\n blink: (text: string) => `\\x1b[5m${text}${resetColor}`,\n reverse: (text: string) => `\\x1b[7m${text}${resetColor}`,\n hidden: (text: string) => `\\x1b[8m${text}${resetColor}`,\n\n black: (text: string) => `\\x1b[30m${text}${resetColor}`,\n red: (text: string) => `\\x1b[31m${text}${resetColor}`,\n green: (text: string) => `\\x1b[32m${text}${resetColor}`,\n yellow: (text: string) => `\\x1b[33m${text}${resetColor}`,\n blue: (text: string) => `\\x1b[34m${text}${resetColor}`,\n magenta: (text: string) => `\\x1b[35m${text}${resetColor}`,\n cyan: (text: string) => `\\x1b[36m${text}${resetColor}`,\n white: (text: string) => `\\x1b[37m${text}${resetColor}`,\n\n bgBlack: (text: string) => `\\x1b[40m${text}${resetColor}`,\n bgRed: (text: string) => `\\x1b[41m${text}${resetColor}`,\n bgGreen: (text: string) => `\\x1b[42m${text}${resetColor}`,\n bgYellow: (text: string) => `\\x1b[43m${text}${resetColor}`,\n bgBlue: (text: string) => `\\x1b[44m${text}${resetColor}`,\n bgMagenta: (text: string) => `\\x1b[45m${text}${resetColor}`,\n bgCyan: (text: string) => `\\x1b[46m${text}${resetColor}`,\n bgWhite: (text: string) => `\\x1b[47m${text}${resetColor}`,\n};\n"],"mappings":"q+BAAA,6ICAA,gBAAiB,yBACjB,gBAAe,gCAEf,eAAsB,aACpB,UACA,QACmB,CACnB,IAAI,UAAsB,CAAC,EAE3B,GAAI,CAAC,UAAW,OAAO,UAEvB,IAAM,MAAQ,MAAM,gBAAAA,QAAG,QAAQ,UAAW,CAAE,cAAe,EAAK,CAAC,EAEjE,QAAW,QAAQ,MAAO,CACxB,IAAM,SAAW,YAAAC,QAAK,KAAK,UAAW,KAAK,IAAI,EAE3C,KAAK,OAAO,GACd,UAAU,KAAK,QAAQ,EAGrB,SAAW,KAAK,YAAY,IAC9B,UAAY,CAAC,GAAG,UAAW,GAAI,MAAM,aAAa,SAAU,EAAI,CAAE,EAEtE,CAEA,OAAO,SACT,CAvBsB,oCAyBtB,eAAsB,eACpB,UACA,QACmB,CACnB,IAAI,YAAwB,CAAC,EAE7B,GAAI,CAAC,UAAW,OAAO,YAEvB,IAAM,QAAU,MAAM,gBAAAD,QAAG,QAAQ,UAAW,CAAE,cAAe,EAAK,CAAC,EAEnE,QAAW,UAAU,QAAS,CAC5B,IAAM,WAAa,YAAAC,QAAK,KAAK,UAAW,OAAO,IAAI,EAE/C,OAAO,YAAY,IACrB,YAAY,KAAK,UAAU,EAEvB,UACF,YAAc,CACZ,GAAG,YACH,GAAI,MAAM,eAAe,WAAY,EAAI,CAC3C,GAGN,CAEA,OAAO,WACT,CA1BsB,wCC5BtB,IAAAC,aAAiB,yBAOV,SAAS,UAAU,SAAkB,CAE1C,MAAO,UADc,aAAAC,QAAK,QAAQ,QAAQ,EACV,QAAQ,WAAY,GAAG,CACzD,CAHgB,8BCPhB,gBAAiB,yBAEJ,SAAQ,YA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AAM,IAAI,MACR,eAAO,IACL,sFACF,CACF,EAGF,KAAK,MAAM,OAAS,CAAC,EAErB,MAAM,KAAK,aAAa,EAExB,KAAK,MAAM,OAAO,mBAAmB,EAErC,KAAK,gBAAgB,EAGrB,gBAAgB,eAAe,CACjC,CACF","names":["fs","path","import_path","path","rfdc","path"]}
|
|
1
|
+
{"version":3,"sources":["../../../src/handlers/event-handler/EventHandler.ts","../../../src/utils/get-paths.ts","../../../src/utils/resolve-file-url.ts","../../../src/utils/clone.ts","../../../src/utils/colors.ts"],"sourcesContent":["import type { EventHandlerOptions, EventHandlerData } from './typings';\nimport type { CommandHandler } from '../command-handler/CommandHandler';\nimport { getFilePaths, getFolderPaths } from '../../utils/get-paths';\nimport { toFileURL } from '../../utils/resolve-file-url';\nimport { clone } from '../../utils/clone';\nimport colors from '../../utils/colors';\n\n/**\n * A handler for client events.\n */\nexport class EventHandler {\n #data: EventHandlerData;\n\n constructor({ ...options }: EventHandlerOptions) {\n this.#data = {\n ...options,\n events: [],\n };\n }\n\n async init() {\n await this.#buildEvents();\n this.#registerEvents();\n }\n\n async #buildEvents() {\n const eventFolderPaths = await getFolderPaths(this.#data.eventsPath);\n\n for (const eventFolderPath of eventFolderPaths) {\n const eventName = eventFolderPath\n .replace(/\\\\\\\\|\\\\/g, '/')\n .split('/')\n .pop() as string;\n\n const allowedExtensions = /\\.(js|mjs|cjs|ts)$/i;\n const eventPaths = await getFilePaths(eventFolderPath, true);\n\n const eventFilePaths = eventPaths.filter((path) =>\n allowedExtensions.test(path),\n );\n\n const eventObj = {\n name: eventName,\n functions: [] as Function[],\n };\n\n this.#data.events.push(eventObj);\n\n for (const eventFilePath of eventFilePaths) {\n const modulePath = toFileURL(eventFilePath);\n\n let importedFunction = (await import(`${modulePath}?t=${Date.now()}`))\n .default;\n let eventFunction = clone(importedFunction);\n\n // If it's CommonJS, invalidate the import cache\n if (typeof module !== 'undefined' && typeof require !== 'undefined') {\n delete require.cache[require.resolve(eventFilePath)];\n }\n\n if (eventFunction?.default) {\n eventFunction = eventFunction.default;\n }\n\n const compactFilePath =\n eventFilePath.split(process.cwd())[1] || eventFilePath;\n\n if (typeof eventFunction !== 'function') {\n process.emitWarning(\n colors.yellow(\n `Ignoring: Event file ${compactFilePath} does not export a function.`,\n ),\n );\n continue;\n }\n\n eventObj.functions.push(eventFunction);\n }\n }\n }\n\n #registerEvents() {\n const client = this.#data.client;\n const handler = this.#data.commandKitInstance;\n\n for (const eventObj of this.#data.events) {\n client.on(eventObj.name, async (...params) => {\n for (const eventFunction of eventObj.functions) {\n const stopEventLoop = await eventFunction(...params, client, handler);\n\n if (stopEventLoop) {\n break;\n }\n }\n });\n }\n }\n\n get events() {\n return this.#data.events;\n }\n\n async reloadEvents(commandHandler?: CommandHandler) {\n if (!this.#data.eventsPath) {\n throw new Error(\n colors.red(\n 'Cannot reload events as \"eventsPath\" was not provided when instantiating CommandKit.',\n ),\n );\n }\n\n this.#data.events = [];\n\n await this.#buildEvents();\n\n this.#data.client.removeAllListeners();\n\n this.#registerEvents();\n\n // Re-register \"interactionCreate\" event for application commands.\n commandHandler?.handleCommands();\n }\n}\n","import path from 'path';\nimport fs from 'fs/promises';\n\nexport async function getFilePaths(\n directory: string,\n nesting?: boolean,\n): Promise<string[]> {\n let filePaths: string[] = [];\n\n if (!directory) return filePaths;\n\n const files = await fs.readdir(directory, { withFileTypes: true });\n\n for (const file of files) {\n const filePath = path.join(directory, file.name);\n\n if (file.isFile()) {\n filePaths.push(filePath);\n }\n\n if (nesting && file.isDirectory()) {\n filePaths = [...filePaths, ...(await getFilePaths(filePath, true))];\n }\n }\n\n return filePaths;\n}\n\nexport async function getFolderPaths(\n directory: string,\n nesting?: boolean,\n): Promise<string[]> {\n let folderPaths: string[] = [];\n\n if (!directory) return folderPaths;\n\n const folders = await fs.readdir(directory, { withFileTypes: true });\n\n for (const folder of folders) {\n const folderPath = path.join(directory, folder.name);\n\n if (folder.isDirectory()) {\n folderPaths.push(folderPath);\n\n if (nesting) {\n folderPaths = [\n ...folderPaths,\n ...(await getFolderPaths(folderPath, true)),\n ];\n }\n }\n }\n\n return folderPaths;\n}\n","import path from 'path';\n\n/**\n * Convert a local file path to a file URL.\n * @param filePath - The local file's path.\n * @returns - The converted file URL.\n */\nexport function toFileURL(filePath: string) {\n const resolvedPath = path.resolve(filePath);\n return 'file://' + resolvedPath.replace(/\\\\\\\\|\\\\/g, '/');\n}\n","import rfdc from 'rfdc';\n\nexport const clone = rfdc();\n","const resetColor = '\\x1b[0m';\n\nexport default {\n reset: (text: string) => `${text}${resetColor}`,\n bright: (text: string) => `\\x1b[1m${text}${resetColor}`,\n dim: (text: string) => `\\x1b[2m${text}${resetColor}`,\n underscore: (text: string) => `\\x1b[4m${text}${resetColor}`,\n blink: (text: string) => `\\x1b[5m${text}${resetColor}`,\n reverse: (text: string) => `\\x1b[7m${text}${resetColor}`,\n hidden: (text: string) => `\\x1b[8m${text}${resetColor}`,\n\n black: (text: string) => `\\x1b[30m${text}${resetColor}`,\n red: (text: string) => `\\x1b[31m${text}${resetColor}`,\n green: (text: string) => `\\x1b[32m${text}${resetColor}`,\n yellow: (text: string) => `\\x1b[33m${text}${resetColor}`,\n blue: (text: string) => `\\x1b[34m${text}${resetColor}`,\n magenta: (text: string) => `\\x1b[35m${text}${resetColor}`,\n cyan: (text: string) => `\\x1b[36m${text}${resetColor}`,\n white: (text: string) => `\\x1b[37m${text}${resetColor}`,\n\n bgBlack: (text: string) => `\\x1b[40m${text}${resetColor}`,\n bgRed: (text: string) => `\\x1b[41m${text}${resetColor}`,\n bgGreen: (text: string) => `\\x1b[42m${text}${resetColor}`,\n bgYellow: (text: string) => `\\x1b[43m${text}${resetColor}`,\n bgBlue: (text: string) => `\\x1b[44m${text}${resetColor}`,\n bgMagenta: (text: string) => `\\x1b[45m${text}${resetColor}`,\n bgCyan: (text: string) => `\\x1b[46m${text}${resetColor}`,\n bgWhite: (text: string) => `\\x1b[47m${text}${resetColor}`,\n};\n"],"mappings":"q+BA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EA,MAAM,aAAa,eAAiC,CAClD,GAAI,CAAC,KAAK,MAAM,WACd,MAAM,IAAI,MACR,eAAO,IACL,sFACF,CACF,EAGF,KAAK,MAAM,OAAS,CAAC,EAErB,MAAM,KAAK,aAAa,EAExB,KAAK,MAAM,OAAO,mBAAmB,EAErC,KAAK,gBAAgB,EAGrB,gBAAgB,eAAe,CACjC,CACF","names":["fs","path","import_path","path","rfdc","path"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{EventHandler}from"../../chunk-
|
|
1
|
+
import{EventHandler}from"../../chunk-KR3OAQKX.mjs";import"../../chunk-VHU3SDTR.mjs";import"../../chunk-PXNT5WYC.mjs";import"../../chunk-EQ62HPWY.mjs";import"../../chunk-VURGPMLB.mjs";import"../../chunk-6TIBWNPX.mjs";export{EventHandler};
|
|
2
2
|
//# sourceMappingURL=EventHandler.mjs.map
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export {
|
|
2
|
+
export { q as EventHandlerData, E as EventHandlerOptions } from '../../CommandKit-D84HlsL0.mjs';
|
|
3
3
|
import '../validation-handler/ValidationHandler.mjs';
|
|
4
4
|
import '../validation-handler/typings.mjs';
|
|
5
5
|
import 'async_hooks';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'discord.js';
|
|
2
|
-
export {
|
|
2
|
+
export { q as EventHandlerData, E as EventHandlerOptions } from '../../CommandKit-Co5QNlps.js';
|
|
3
3
|
import '../validation-handler/ValidationHandler.js';
|
|
4
4
|
import '../validation-handler/typings.js';
|
|
5
5
|
import 'async_hooks';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { p as CommandHandler, r as EventHandler, o as hCommandContext } from '../CommandKit-D84HlsL0.mjs';
|
|
2
2
|
export { ValidationHandler } from './validation-handler/ValidationHandler.mjs';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
import 'async_hooks';
|
package/dist/handlers/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { p as CommandHandler, r as EventHandler, o as hCommandContext } from '../CommandKit-Co5QNlps.js';
|
|
2
2
|
export { ValidationHandler } from './validation-handler/ValidationHandler.js';
|
|
3
3
|
import 'discord.js';
|
|
4
4
|
import 'async_hooks';
|
package/dist/handlers/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var handlers_exports={};__export(handlers_exports,{CommandHandler:()=>CommandHandler,EventHandler:()=>EventHandler,ValidationHandler:()=>ValidationHandler});module.exports=__toCommonJS(handlers_exports);var import_path=__toESM(require("path"));function toFileURL(filePath){return"file://"+import_path.default.resolve(filePath).replace(/\\\\|\\/g,"/")}__name(toFileURL,"toFileURL");var import_path2=__toESM(require("path")),import_promises=__toESM(require("fs/promises"));async function getFilePaths(directory,nesting){let filePaths=[];if(!directory)return filePaths;let files=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let file of files){let filePath=import_path2.default.join(directory,file.name);file.isFile()&&filePaths.push(filePath),nesting&&file.isDirectory()&&(filePaths=[...filePaths,...await getFilePaths(filePath,!0)])}return filePaths}__name(getFilePaths,"getFilePaths");async function getFolderPaths(directory,nesting){let folderPaths=[];if(!directory)return folderPaths;let folders=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let folder of folders){let folderPath=import_path2.default.join(directory,folder.name);folder.isDirectory()&&(folderPaths.push(folderPath),nesting&&(folderPaths=[...folderPaths,...await getFolderPaths(folderPath,!0)]))}return folderPaths}__name(getFolderPaths,"getFolderPaths");var import_rfdc=__toESM(require("rfdc")),clone=(0,import_rfdc.default)();var resetColor="\x1B[0m",colors_default={reset:text=>`${text}${resetColor}`,bright:text=>`\x1B[1m${text}${resetColor}`,dim:text=>`\x1B[2m${text}${resetColor}`,underscore:text=>`\x1B[4m${text}${resetColor}`,blink:text=>`\x1B[5m${text}${resetColor}`,reverse:text=>`\x1B[7m${text}${resetColor}`,hidden:text=>`\x1B[8m${text}${resetColor}`,black:text=>`\x1B[30m${text}${resetColor}`,red:text=>`\x1B[31m${text}${resetColor}`,green:text=>`\x1B[32m${text}${resetColor}`,yellow:text=>`\x1B[33m${text}${resetColor}`,blue:text=>`\x1B[34m${text}${resetColor}`,magenta:text=>`\x1B[35m${text}${resetColor}`,cyan:text=>`\x1B[36m${text}${resetColor}`,white:text=>`\x1B[37m${text}${resetColor}`,bgBlack:text=>`\x1B[40m${text}${resetColor}`,bgRed:text=>`\x1B[41m${text}${resetColor}`,bgGreen:text=>`\x1B[42m${text}${resetColor}`,bgYellow:text=>`\x1B[43m${text}${resetColor}`,bgBlue:text=>`\x1B[44m${text}${resetColor}`,bgMagenta:text=>`\x1B[45m${text}${resetColor}`,bgCyan:text=>`\x1B[46m${text}${resetColor}`,bgWhite:text=>`\x1B[47m${text}${resetColor}
|
|
1
|
+
"use strict";var __create=Object.create;var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __getProtoOf=Object.getPrototypeOf,__hasOwnProp=Object.prototype.hasOwnProperty;var __name=(target,value)=>__defProp(target,"name",{value,configurable:!0});var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toESM=(mod,isNodeMode,target)=>(target=mod!=null?__create(__getProtoOf(mod)):{},__copyProps(isNodeMode||!mod||!mod.__esModule?__defProp(target,"default",{value:mod,enumerable:!0}):target,mod)),__toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var handlers_exports={};__export(handlers_exports,{CommandHandler:()=>CommandHandler,EventHandler:()=>EventHandler,ValidationHandler:()=>ValidationHandler});module.exports=__toCommonJS(handlers_exports);var import_path=__toESM(require("path"));function toFileURL(filePath){return"file://"+import_path.default.resolve(filePath).replace(/\\\\|\\/g,"/")}__name(toFileURL,"toFileURL");var import_path2=__toESM(require("path")),import_promises=__toESM(require("fs/promises"));async function getFilePaths(directory,nesting){let filePaths=[];if(!directory)return filePaths;let files=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let file of files){let filePath=import_path2.default.join(directory,file.name);file.isFile()&&filePaths.push(filePath),nesting&&file.isDirectory()&&(filePaths=[...filePaths,...await getFilePaths(filePath,!0)])}return filePaths}__name(getFilePaths,"getFilePaths");async function getFolderPaths(directory,nesting){let folderPaths=[];if(!directory)return folderPaths;let folders=await import_promises.default.readdir(directory,{withFileTypes:!0});for(let folder of folders){let folderPath=import_path2.default.join(directory,folder.name);folder.isDirectory()&&(folderPaths.push(folderPath),nesting&&(folderPaths=[...folderPaths,...await getFolderPaths(folderPath,!0)]))}return folderPaths}__name(getFolderPaths,"getFolderPaths");var import_rfdc=__toESM(require("rfdc")),clone=(0,import_rfdc.default)();var resetColor="\x1B[0m",colors_default={reset:__name(text=>`${text}${resetColor}`,"reset"),bright:__name(text=>`\x1B[1m${text}${resetColor}`,"bright"),dim:__name(text=>`\x1B[2m${text}${resetColor}`,"dim"),underscore:__name(text=>`\x1B[4m${text}${resetColor}`,"underscore"),blink:__name(text=>`\x1B[5m${text}${resetColor}`,"blink"),reverse:__name(text=>`\x1B[7m${text}${resetColor}`,"reverse"),hidden:__name(text=>`\x1B[8m${text}${resetColor}`,"hidden"),black:__name(text=>`\x1B[30m${text}${resetColor}`,"black"),red:__name(text=>`\x1B[31m${text}${resetColor}`,"red"),green:__name(text=>`\x1B[32m${text}${resetColor}`,"green"),yellow:__name(text=>`\x1B[33m${text}${resetColor}`,"yellow"),blue:__name(text=>`\x1B[34m${text}${resetColor}`,"blue"),magenta:__name(text=>`\x1B[35m${text}${resetColor}`,"magenta"),cyan:__name(text=>`\x1B[36m${text}${resetColor}`,"cyan"),white:__name(text=>`\x1B[37m${text}${resetColor}`,"white"),bgBlack:__name(text=>`\x1B[40m${text}${resetColor}`,"bgBlack"),bgRed:__name(text=>`\x1B[41m${text}${resetColor}`,"bgRed"),bgGreen:__name(text=>`\x1B[42m${text}${resetColor}`,"bgGreen"),bgYellow:__name(text=>`\x1B[43m${text}${resetColor}`,"bgYellow"),bgBlue:__name(text=>`\x1B[44m${text}${resetColor}`,"bgBlue"),bgMagenta:__name(text=>`\x1B[45m${text}${resetColor}`,"bgMagenta"),bgCyan:__name(text=>`\x1B[46m${text}${resetColor}`,"bgCyan"),bgWhite:__name(text=>`\x1B[47m${text}${resetColor}`,"bgWhite")};async function loadCommandsWithRest(props){if(props.reloading)if(props.client.isReady())await handleLoading(props.client,props.commands,props.devGuildIds,props.reloading,props.type);else throw new Error(colors_default.red("Cannot reload commands when client is not ready."));else props.client.once("ready",async c=>{await handleLoading(c,props.commands,props.devGuildIds,props.reloading,props.type)})}__name(loadCommandsWithRest,"loadCommandsWithRest");async function handleLoading(client,commands,devGuildIds,reloading,type){commands=commands.filter(cmd=>!cmd.options?.deleted);let devOnlyCommands=commands.filter(cmd=>cmd.options?.devOnly),globalCommands=commands.filter(cmd=>!cmd.options?.devOnly);type==="dev"?await loadDevCommands(client,devOnlyCommands,devGuildIds,reloading):type==="global"?await loadGlobalCommands(client,globalCommands,reloading):(await loadDevCommands(client,devOnlyCommands,devGuildIds,reloading),await loadGlobalCommands(client,globalCommands,reloading))}__name(handleLoading,"handleLoading");async function loadGlobalCommands(client,commands,reloading){let requestBody=commands.map(cmd=>cmd.data);await client.application.commands.set(requestBody).catch(error=>{throw new Error(colors_default.red(`Error ${reloading?"reloading":"loading"} global application commands.
|
|
2
2
|
`),error)}),console.log(colors_default.green(`${reloading?"Reloaded":"Loaded"} ${requestBody.length} global commands.`))}__name(loadGlobalCommands,"loadGlobalCommands");async function loadDevCommands(client,commands,guildIds,reloading){let requestBody=commands.map(cmd=>cmd.data);for(let guildId of guildIds){let targetGuild=client.guilds.cache.get(guildId)||await client.guilds.fetch(guildId);if(!targetGuild){process.emitWarning(`Cannot ${reloading?"reload":"load"} commands in guild "${guildId}" - guild doesn't exist or client isn't part of the guild.`);continue}await targetGuild.commands.set(requestBody).catch(error=>{throw new Error(colors_default.red(`Error ${reloading?"reloading":"loading"} developer application commands in guild "${targetGuild?.name||guildId}".
|
|
3
3
|
`),error)}),console.log(colors_default.green(`${reloading?"Reloaded":"Loaded"} ${requestBody.length} developer commands in guild "${targetGuild.name}".`))}}__name(loadDevCommands,"loadDevCommands");function areSlashCommandsDifferent(appCommand,localCommand){if(appCommand.options||(appCommand.options=[]),localCommand.options||(localCommand.options=[]),appCommand.description||(appCommand.description=""),localCommand.description||(localCommand.description=""),localCommand.description!==appCommand.description||localCommand.options.length!==appCommand.options.length)return!0}__name(areSlashCommandsDifferent,"areSlashCommandsDifferent");async function registerCommands(props){if(props.reloading)if(props.client.isReady())await handleRegistration(props.client,props.commands,props.devGuildIds,props.type);else throw new Error(colors_default.red("Cannot reload commands when client is not ready."));else props.client.once("ready",async c=>{await handleRegistration(c,props.commands,props.devGuildIds,props.type)})}__name(registerCommands,"registerCommands");async function handleRegistration(client,commands,devGuildIds,type){let devOnlyCommands=commands.filter(cmd=>cmd.options?.devOnly),globalCommands=commands.filter(cmd=>!cmd.options?.devOnly);type==="dev"?await registerDevCommands(client,devOnlyCommands,devGuildIds):type==="global"?await registerGlobalCommands(client,globalCommands):(await registerDevCommands(client,devOnlyCommands,devGuildIds),await registerGlobalCommands(client,globalCommands))}__name(handleRegistration,"handleRegistration");async function registerGlobalCommands(client,commands){let appCommandsManager=client.application.commands;await appCommandsManager.fetch();for(let command of commands){let targetCommand=appCommandsManager.cache.find(cmd=>cmd.name===command.data.name);if(command.options?.deleted){targetCommand?(await targetCommand.delete().catch(error=>{throw new Error(colors_default.red(`Failed to delete command "${command.data.name}" globally.
|
|
4
4
|
`),error)}),console.log(colors_default.green(`Deleted command "${command.data.name}" globally.`))):process.emitWarning(colors_default.yellow(`Ignoring: Command "${command.data.name}" is globally marked as deleted.`));continue}if(targetCommand&&areSlashCommandsDifferent(targetCommand,command.data)){await targetCommand.edit(command.data).catch(error=>{throw new Error(colors_default.red(`Failed to edit command "${command.data.name}" globally.
|