reciple 9.9.0 → 10.0.1-dev.0
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/LICENSE +155 -674
- package/assets/config/reciple.config.js +87 -0
- package/assets/config/reciple.config.ts +80 -0
- package/assets/global/README.md +1 -0
- package/assets/global/gitignore +121 -0
- package/assets/global/nodemon.json +13 -0
- package/assets/modules/javascript/Base.js +21 -0
- package/assets/modules/javascript/ClientEvent.js +14 -0
- package/assets/modules/javascript/ContextMenuCommand.js +17 -0
- package/assets/modules/javascript/Event.js +17 -0
- package/assets/modules/javascript/MessageCommand.js +16 -0
- package/assets/modules/javascript/RESTEvent.js +14 -0
- package/assets/modules/javascript/SlashCommand.js +16 -0
- package/assets/modules/typescript/Base.ts +17 -0
- package/assets/modules/typescript/ClientEvent.ts +15 -0
- package/assets/modules/typescript/ContextMenuCommand.ts +15 -0
- package/assets/modules/typescript/Event.ts +16 -0
- package/assets/modules/typescript/MessageCommand.ts +14 -0
- package/assets/modules/typescript/RESTEvent.ts +15 -0
- package/assets/modules/typescript/SlashCommand.ts +14 -0
- package/assets/templates/javascript/jsconfig.json +17 -0
- package/assets/templates/typescript/tsconfig.json +17 -0
- package/dist/_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs +10 -0
- package/dist/bin/commands/build.d.mts +16 -0
- package/dist/bin/commands/build.mjs +24 -0
- package/dist/bin/commands/build.mjs.map +1 -0
- package/dist/bin/commands/create.d.mts +23 -0
- package/dist/bin/commands/create.mjs +48 -0
- package/dist/bin/commands/create.mjs.map +1 -0
- package/dist/bin/commands/createModule.d.mts +21 -0
- package/dist/bin/commands/createModule.mjs +40 -0
- package/dist/bin/commands/createModule.mjs.map +1 -0
- package/dist/bin/commands/start.d.mts +18 -0
- package/dist/bin/commands/start.mjs +104 -0
- package/dist/bin/commands/start.mjs.map +1 -0
- package/dist/bin/reciple.d.mts +1 -0
- package/dist/bin/reciple.mjs +9 -0
- package/dist/bin/reciple.mjs.map +1 -0
- package/dist/classes/NotAnError.d.mts +7 -0
- package/dist/classes/NotAnError.mjs +11 -0
- package/dist/classes/NotAnError.mjs.map +1 -0
- package/dist/classes/cli/CLI.d.mts +54 -0
- package/dist/classes/cli/CLI.mjs +156 -0
- package/dist/classes/cli/CLI.mjs.map +1 -0
- package/dist/classes/cli/CLISubcommand.d.mts +27 -0
- package/dist/classes/cli/CLISubcommand.mjs +23 -0
- package/dist/classes/cli/CLISubcommand.mjs.map +1 -0
- package/dist/classes/cli/ConfigReader.d.mts +81 -0
- package/dist/classes/cli/ConfigReader.mjs +141 -0
- package/dist/classes/cli/ConfigReader.mjs.map +1 -0
- package/dist/classes/cli/RuntimeEnvironment.d.mts +14 -0
- package/dist/classes/cli/RuntimeEnvironment.mjs +36 -0
- package/dist/classes/cli/RuntimeEnvironment.mjs.map +1 -0
- package/dist/classes/client/EventListeners.d.mts +26 -0
- package/dist/classes/client/EventListeners.mjs +103 -0
- package/dist/classes/client/EventListeners.mjs.map +1 -0
- package/dist/classes/client/ModuleLoader.d.mts +55 -0
- package/dist/classes/client/ModuleLoader.mjs +152 -0
- package/dist/classes/client/ModuleLoader.mjs.map +1 -0
- package/dist/classes/managers/ModuleManager.d.mts +55 -0
- package/dist/classes/managers/ModuleManager.mjs +107 -0
- package/dist/classes/managers/ModuleManager.mjs.map +1 -0
- package/dist/classes/modules/BaseModule.d.mts +34 -0
- package/dist/classes/modules/BaseModule.mjs +33 -0
- package/dist/classes/modules/BaseModule.mjs.map +1 -0
- package/dist/classes/modules/PostconditionModule.d.mts +20 -0
- package/dist/classes/modules/PostconditionModule.mjs +24 -0
- package/dist/classes/modules/PostconditionModule.mjs.map +1 -0
- package/dist/classes/modules/PreconditionModule.d.mts +20 -0
- package/dist/classes/modules/PreconditionModule.mjs +24 -0
- package/dist/classes/modules/PreconditionModule.mjs.map +1 -0
- package/dist/classes/modules/commands/ContextMenuCommandModule.d.mts +24 -0
- package/dist/classes/modules/commands/ContextMenuCommandModule.mjs +27 -0
- package/dist/classes/modules/commands/ContextMenuCommandModule.mjs.map +1 -0
- package/dist/classes/modules/commands/MessageCommandModule.d.mts +24 -0
- package/dist/classes/modules/commands/MessageCommandModule.mjs +27 -0
- package/dist/classes/modules/commands/MessageCommandModule.mjs.map +1 -0
- package/dist/classes/modules/commands/SlashCommandModule.d.mts +24 -0
- package/dist/classes/modules/commands/SlashCommandModule.mjs +27 -0
- package/dist/classes/modules/commands/SlashCommandModule.mjs.map +1 -0
- package/dist/classes/modules/events/ClientEventModule.d.mts +11 -0
- package/dist/classes/modules/events/ClientEventModule.mjs +10 -0
- package/dist/classes/modules/events/ClientEventModule.mjs.map +1 -0
- package/dist/classes/modules/events/EventModule.d.mts +29 -0
- package/dist/classes/modules/events/EventModule.mjs +26 -0
- package/dist/classes/modules/events/EventModule.mjs.map +1 -0
- package/dist/classes/modules/events/RESTEventModule.d.mts +11 -0
- package/dist/classes/modules/events/RESTEventModule.mjs +10 -0
- package/dist/classes/modules/events/RESTEventModule.mjs.map +1 -0
- package/dist/classes/templates/ModuleTemplateBuilder.d.mts +84 -0
- package/dist/classes/templates/ModuleTemplateBuilder.mjs +288 -0
- package/dist/classes/templates/ModuleTemplateBuilder.mjs.map +1 -0
- package/dist/classes/templates/TemplateBuilder.d.mts +78 -0
- package/dist/classes/templates/TemplateBuilder.mjs +351 -0
- package/dist/classes/templates/TemplateBuilder.mjs.map +1 -0
- package/dist/classes/validation/BaseModuleValidator.d.mts +44 -0
- package/dist/classes/validation/BaseModuleValidator.mjs +46 -0
- package/dist/classes/validation/BaseModuleValidator.mjs.map +1 -0
- package/dist/classes/validation/CommandModuleValidator.d.mts +117 -0
- package/dist/classes/validation/CommandModuleValidator.mjs +16 -0
- package/dist/classes/validation/CommandModuleValidator.mjs.map +1 -0
- package/dist/classes/validation/EventModuleValidator.d.mts +59 -0
- package/dist/classes/validation/EventModuleValidator.mjs +42 -0
- package/dist/classes/validation/EventModuleValidator.mjs.map +1 -0
- package/dist/classes/validation/PostconditionModule.d.mts +30 -0
- package/dist/classes/validation/PostconditionModule.mjs +34 -0
- package/dist/classes/validation/PostconditionModule.mjs.map +1 -0
- package/dist/classes/validation/PreconditionModule.d.mts +28 -0
- package/dist/classes/validation/PreconditionModule.mjs +29 -0
- package/dist/classes/validation/PreconditionModule.mjs.map +1 -0
- package/dist/helpers/constants.d.mts +20 -0
- package/dist/helpers/constants.mjs +28 -0
- package/dist/helpers/constants.mjs.map +1 -0
- package/dist/helpers/types.d.mts +20 -0
- package/dist/helpers/types.mjs +1 -0
- package/dist/index.d.mts +39 -0
- package/dist/index.mjs +39 -0
- package/dist/index.mjs.map +1 -0
- package/dist/package.mjs +80 -0
- package/dist/package.mjs.map +1 -0
- package/package.json +61 -46
- package/README.md +0 -206
- package/dist/bin.d.ts +0 -2
- package/dist/bin.js +0 -4
- package/dist/bin.js.map +0 -1
- package/dist/classes/CLI.d.ts +0 -55
- package/dist/classes/CLI.js +0 -191
- package/dist/classes/CLI.js.map +0 -1
- package/dist/classes/Config.d.ts +0 -26
- package/dist/classes/Config.js +0 -73
- package/dist/classes/Config.js.map +0 -1
- package/dist/classes/EventHandlers.d.ts +0 -9
- package/dist/classes/EventHandlers.js +0 -71
- package/dist/classes/EventHandlers.js.map +0 -1
- package/dist/classes/ModuleLoader.d.ts +0 -25
- package/dist/classes/ModuleLoader.js +0 -91
- package/dist/classes/ModuleLoader.js.map +0 -1
- package/dist/commands/init.d.ts +0 -7
- package/dist/commands/init.js +0 -10
- package/dist/commands/init.js.map +0 -1
- package/dist/commands/modules.d.ts +0 -9
- package/dist/commands/modules.js +0 -33
- package/dist/commands/modules.js.map +0 -1
- package/dist/commands/shard.d.ts +0 -9
- package/dist/commands/shard.js +0 -102
- package/dist/commands/shard.js.map +0 -1
- package/dist/commands/start.d.ts +0 -9
- package/dist/commands/start.js +0 -95
- package/dist/commands/start.js.map +0 -1
- package/dist/exports.d.ts +0 -6
- package/dist/exports.js +0 -7
- package/dist/exports.js.map +0 -1
- package/dist/index.d.ts +0 -15
- package/dist/index.js +0 -8
- package/dist/index.js.map +0 -1
- package/dist/types/constants.d.ts +0 -6
- package/dist/types/constants.js +0 -29
- package/dist/types/constants.js.map +0 -1
- package/dist/types/structures.d.ts +0 -36
- package/dist/types/structures.js +0 -2
- package/dist/types/structures.js.map +0 -1
- package/static/config.d.mts +0 -5
- package/static/config.mjs +0 -105
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleLoader.mjs","names":["client: Client","modules: AnyModule[]","path","scanned: string[]","directories: string[]","modules: string[]","globby: typeof import('globby')|null","globby"],"sources":["../../../src/classes/client/ModuleLoader.ts"],"sourcesContent":["import { type Awaitable } from 'discord.js';\nimport path from 'node:path';\nimport { mkdir, readdir, stat } from 'node:fs/promises';\nimport micromatch from 'micromatch';\nimport { globby, isDynamicPattern } from 'globby';\nimport { CommandType, RecipleError, type Client } from '@reciple/core';\nimport type { AnyModule, AnyModuleData } from '../../helpers/types.js';\nimport { colors, recursiveDefaults } from '@reciple/utils';\nimport { BaseModule } from '../modules/BaseModule.js';\nimport { BaseModuleValidator } from '../validation/BaseModuleValidator.js';\nimport { ModuleType } from '../../helpers/constants.js';\nimport { PostconditionModule } from '../modules/PostconditionModule.js';\nimport { PreconditionModule } from '../modules/PreconditionModule.js';\nimport { EventModule } from '../modules/events/EventModule.js';\nimport { MessageCommandModule } from '../modules/commands/MessageCommandModule.js';\nimport { SlashCommandModule } from '../modules/commands/SlashCommandModule.js';\nimport { ContextMenuCommandModule } from '../modules/commands/ContextMenuCommandModule.js';\nimport { CommandModuleValidator } from '../validation/CommandModuleValidator.js';\nimport { EventModuleValidator } from '../validation/EventModuleValidator.js';\nimport { PreconditionModuleValidator } from '../validation/PreconditionModule.js';\nimport { PostconditionModuleValidator } from '../validation/PostconditionModule.js';\nimport type { Logger } from 'prtyprnt';\nimport { EventEmitter } from 'node:events';\n\nexport class ModuleLoader extends EventEmitter<ModuleLoader.Events> {\n public readonly logger: Logger;\n\n constructor(public readonly client: Client) {\n super();\n\n this.logger = this.client.logger.clone({\n label: 'ModuleLoader'\n });\n }\n\n public async findModules(ignoreErrors: boolean = false): Promise<AnyModule[]> {\n const modulePaths = await ModuleLoader.scanForModules(this.client.config?.modules);\n const modules: AnyModule[] = [];\n\n this.emit('modulesResolving', modulePaths);\n\n for (const path of modulePaths) {\n try {\n this.emit('moduleResolving', path);\n const resolved = await ModuleLoader.resolveModulePath(path);\n\n Object.assign(resolved, { client: this.client, __$filepath: path });\n modules.push(resolved);\n\n this.emit('moduleResolved', resolved);\n } catch (error) {\n if (ignoreErrors) continue;\n\n this.emitOrThrow('moduleResolveError', new RecipleError({\n message: `Failed to load module: ${colors.cyan(path)}`,\n cause: error\n }));\n }\n }\n\n this.emit('modulesResolved', modules);\n return modules;\n }\n\n public static async scanForDirectories(config?: Pick<ModuleLoader.Config, 'directories'|'ignore'> & { cwd?: string; createDirectories?: boolean; }) {\n const cwd = config?.cwd ?? process.cwd();\n\n let scanned: string[] = [];\n let directories: string[] = [];\n\n for (const directory of config?.directories ?? []) {\n if (isDynamicPattern(directory, { cwd })) {\n const matches = await globby(directory, {\n cwd,\n ignore: config?.ignore,\n onlyDirectories: true,\n baseNameMatch: true,\n absolute: true\n });\n\n scanned.push(...matches);\n continue;\n }\n\n scanned.push(path.join(cwd, directory));\n }\n\n for (const directory of scanned) {\n const stats = await stat(directory).catch(() => undefined);\n\n if (!stats && config?.createDirectories !== false) {\n await mkdir(directory, { recursive: true });\n }\n\n directories.push(directory);\n }\n\n return directories;\n }\n\n public static async scanForModules(config?: ModuleLoader.Config & { cwd?: string; createDirectories?: boolean; }): Promise<string[]> {\n const directories = await ModuleLoader.scanForDirectories(config);\n\n let modules: string[] = [];\n\n for (const directory of directories) {\n let files = await readdir(directory);\n\n if (config?.ignore?.length) {\n files = micromatch.not(files, config.ignore, {\n cwd: directory,\n matchBase: true,\n dot: true\n });\n }\n\n files = files.map(f => path.join(directory, f));\n\n for (const file of files) {\n if (config?.filter ? !(await config?.filter(file)) : ModuleLoader.fileTypes.every(type => !file.endsWith(`.${type}`))) continue;\n modules.push(file);\n }\n }\n\n if (config?.sort) modules.sort(config.sort);\n\n return modules;\n }\n\n public static async resolveModulePath(filepath: string, options?: { cwd?: string; }): Promise<AnyModule> {\n const stats = await stat(filepath).catch(() => undefined);\n if (!stats) throw new RecipleError(`Module not found: ${filepath}`);\n\n const data = recursiveDefaults<AnyModule|AnyModuleData|undefined>(await import(`file://${path.resolve(options?.cwd ?? process.cwd(), filepath)}`));\n if (BaseModule.isModule(data)) return data;\n\n switch (data?.moduleType) {\n case ModuleType.Command:\n CommandModuleValidator.isValid(data);\n switch (data.type) {\n case CommandType.Message: return MessageCommandModule.from(data);\n case CommandType.Slash: return SlashCommandModule.from(data);\n case CommandType.ContextMenu: return ContextMenuCommandModule.from(data);\n default: throw new RecipleError(`Unknown command type from module: ${colors.cyan(filepath)}`);\n }\n case ModuleType.Event:\n EventModuleValidator.isValid(data);\n return EventModule.from(data);\n case ModuleType.Precondition:\n PreconditionModuleValidator.isValid(data);\n return PreconditionModule.from(data);\n case ModuleType.Postcondition:\n PostconditionModuleValidator.isValid(data);\n return PostconditionModule.from(data);\n case ModuleType.Base:\n default:\n BaseModuleValidator.isValid(data);\n return BaseModule.from(data);\n }\n }\n\n public static async resolveSourceDirectories(options: ModuleLoader.ResolveSourceDirectoryOptions): Promise<string[]> {\n const dir = path.isAbsolute(options.baseUrl) ? options.baseUrl : path.resolve(path.join(options.cwd ?? process.cwd(), options.baseUrl));\n\n const root = path.resolve(path.join(dir, options.rootDir));\n const out = path.resolve(path.join(dir, options.outDir));\n\n return options.directories.map(directory => path.resolve(directory).replace(out, root));\n }\n\n private emitOrThrow<K extends keyof Pick<ModuleLoader.Events, 'moduleResolveError'>>(event: K, error: RecipleError) {\n if (this.client.listenerCount(event) > 0) {\n // @ts-expect-error\n return this.emit(event, error);\n }\n\n throw error;\n }\n}\n\nexport namespace ModuleLoader {\n export let globby: typeof import('globby')|null = null;\n\n export const fileTypes = [\n 'js',\n 'mjs',\n 'jsx'\n ];\n\n export interface Config {\n directories?: string[];\n ignore?: string[];\n filter?: (filepath: string) => Awaitable<boolean>;\n sort?: (a: string, b: string) => number;\n }\n\n export interface Events {\n moduleResolveError: [error: RecipleError];\n moduleResolved: [module: AnyModule];\n moduleResolving: [filepath: string];\n modulesResolved: [modules: AnyModule[]];\n modulesResolving: [files: string[]];\n }\n\n export interface ResolveSourceDirectoryOptions {\n directories: string[];\n baseUrl: string;\n rootDir: string;\n outDir: string;\n cwd?: string;\n }\n\n export async function getGlobby(): Promise<typeof import('globby')> {\n if (globby) return globby;\n\n return globby = await import('globby');\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { BaseModule } from "../modules/BaseModule.mjs";
|
|
2
|
+
import { AnyModule } from "../../helpers/types.mjs";
|
|
3
|
+
import { BaseManager, Client } from "@reciple/core";
|
|
4
|
+
import { EventEmitter } from "node:events";
|
|
5
|
+
|
|
6
|
+
//#region src/classes/managers/ModuleManager.d.ts
|
|
7
|
+
interface ModuleManager extends BaseManager<string, AnyModule, BaseModule.Resolvable>, EventEmitter<ModuleManager.Events> {}
|
|
8
|
+
declare class ModuleManager {
|
|
9
|
+
readonly client: Client;
|
|
10
|
+
readonly holds: typeof BaseModule;
|
|
11
|
+
constructor(client: Client);
|
|
12
|
+
enableModules({
|
|
13
|
+
modules,
|
|
14
|
+
removeFromCacheOnError
|
|
15
|
+
}?: ModuleManager.EventExecuteData & {
|
|
16
|
+
removeFromCacheOnError?: boolean;
|
|
17
|
+
}): Promise<AnyModule[]>;
|
|
18
|
+
readyModules({
|
|
19
|
+
modules,
|
|
20
|
+
removeFromCacheOnError
|
|
21
|
+
}?: ModuleManager.EventExecuteData & {
|
|
22
|
+
removeFromCacheOnError?: boolean;
|
|
23
|
+
}): Promise<AnyModule[]>;
|
|
24
|
+
disableModules({
|
|
25
|
+
modules,
|
|
26
|
+
removeFromCache
|
|
27
|
+
}?: ModuleManager.EventExecuteData & {
|
|
28
|
+
removeFromCache?: boolean;
|
|
29
|
+
}): Promise<AnyModule[]>;
|
|
30
|
+
add(module: AnyModule): void;
|
|
31
|
+
remove(module: AnyModule): void;
|
|
32
|
+
private emitOrThrow;
|
|
33
|
+
}
|
|
34
|
+
declare namespace ModuleManager {
|
|
35
|
+
interface Events {
|
|
36
|
+
modulePreEnable: [module: AnyModule];
|
|
37
|
+
moduleEnable: [module: AnyModule];
|
|
38
|
+
moduleEnableError: [module: AnyModule, error: Error];
|
|
39
|
+
enabledModules: [modules: AnyModule[]];
|
|
40
|
+
modulePreReady: [module: AnyModule];
|
|
41
|
+
moduleReady: [module: AnyModule];
|
|
42
|
+
moduleReadyError: [module: AnyModule, error: Error];
|
|
43
|
+
readyModules: [modules: AnyModule[]];
|
|
44
|
+
modulePreDisable: [module: AnyModule];
|
|
45
|
+
moduleDisable: [module: AnyModule];
|
|
46
|
+
moduleDisableError: [module: AnyModule, error: Error];
|
|
47
|
+
disabledModules: [modules: AnyModule[]];
|
|
48
|
+
}
|
|
49
|
+
interface EventExecuteData {
|
|
50
|
+
modules?: AnyModule[];
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
export { ModuleManager };
|
|
55
|
+
//# sourceMappingURL=ModuleManager.d.mts.map
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "../modules/BaseModule.mjs";
|
|
3
|
+
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
|
+
import { BaseManager, RecipleError } from "@reciple/core";
|
|
5
|
+
import { mix } from "ts-mixer";
|
|
6
|
+
import { EventEmitter } from "node:events";
|
|
7
|
+
|
|
8
|
+
//#region src/classes/managers/ModuleManager.ts
|
|
9
|
+
let ModuleManager = class ModuleManager$1 {
|
|
10
|
+
holds = BaseModule;
|
|
11
|
+
constructor(client) {
|
|
12
|
+
this.client = client;
|
|
13
|
+
}
|
|
14
|
+
async enableModules({ modules, removeFromCacheOnError } = { modules: Array.from(this.cache.values()) }) {
|
|
15
|
+
const enabledModules = [];
|
|
16
|
+
for (const module of modules ?? []) {
|
|
17
|
+
this.emit("modulePreEnable", module);
|
|
18
|
+
await module.onEnable({ client: this.client }).catch((e) => {
|
|
19
|
+
if (removeFromCacheOnError) this.cache.delete(module.id);
|
|
20
|
+
this.emitOrThrow("moduleEnableError", module, e);
|
|
21
|
+
});
|
|
22
|
+
this.emit("moduleEnable", module);
|
|
23
|
+
this.add(module);
|
|
24
|
+
enabledModules.push(module);
|
|
25
|
+
}
|
|
26
|
+
this.emit("enabledModules", enabledModules);
|
|
27
|
+
return enabledModules;
|
|
28
|
+
}
|
|
29
|
+
async readyModules({ modules, removeFromCacheOnError } = { modules: Array.from(this.cache.values()) }) {
|
|
30
|
+
const readyModules = [];
|
|
31
|
+
if (!this.client.isReady()) throw new RecipleError(RecipleError.Code.ClientNotReady());
|
|
32
|
+
for (const module of modules ?? []) {
|
|
33
|
+
this.emit("modulePreReady", module);
|
|
34
|
+
await module.onReady({ client: this.client }).catch((e) => {
|
|
35
|
+
if (removeFromCacheOnError !== false) this.remove(module);
|
|
36
|
+
this.emitOrThrow("moduleReadyError", module, e);
|
|
37
|
+
});
|
|
38
|
+
this.emit("moduleReady", module);
|
|
39
|
+
this.cache.set(module.id, module);
|
|
40
|
+
readyModules.push(module);
|
|
41
|
+
}
|
|
42
|
+
this.emit("readyModules", readyModules);
|
|
43
|
+
return readyModules;
|
|
44
|
+
}
|
|
45
|
+
async disableModules({ modules, removeFromCache } = { modules: Array.from(this.cache.values()) }) {
|
|
46
|
+
const disabledModules = [];
|
|
47
|
+
for (const module of modules ?? []) {
|
|
48
|
+
this.emit("modulePreDisable", module);
|
|
49
|
+
await module.onDisable({ client: this.client }).catch((e) => {
|
|
50
|
+
if (removeFromCache !== false) this.remove(module);
|
|
51
|
+
this.emitOrThrow("moduleDisableError", module, e);
|
|
52
|
+
});
|
|
53
|
+
this.emit("moduleDisable", module);
|
|
54
|
+
if (removeFromCache !== false) this.remove(module);
|
|
55
|
+
disabledModules.push(module);
|
|
56
|
+
}
|
|
57
|
+
this.emit("disabledModules", disabledModules);
|
|
58
|
+
return disabledModules;
|
|
59
|
+
}
|
|
60
|
+
add(module) {
|
|
61
|
+
this.cache.set(module.id, module);
|
|
62
|
+
switch (module.moduleType) {
|
|
63
|
+
case ModuleType.Command:
|
|
64
|
+
this.client.commands?.add(module);
|
|
65
|
+
break;
|
|
66
|
+
case ModuleType.Event:
|
|
67
|
+
this.client.eventListeners.register(module);
|
|
68
|
+
break;
|
|
69
|
+
case ModuleType.Precondition:
|
|
70
|
+
this.client.preconditions?.cache.set(module.id, module);
|
|
71
|
+
break;
|
|
72
|
+
case ModuleType.Postcondition:
|
|
73
|
+
this.client.postconditions?.cache.set(module.id, module);
|
|
74
|
+
break;
|
|
75
|
+
case ModuleType.Base:
|
|
76
|
+
default: break;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
remove(module) {
|
|
80
|
+
this.cache.delete(module.id);
|
|
81
|
+
switch (module.moduleType) {
|
|
82
|
+
case ModuleType.Command:
|
|
83
|
+
this.client.commands?.cache.delete(module.id);
|
|
84
|
+
break;
|
|
85
|
+
case ModuleType.Event:
|
|
86
|
+
this.client.eventListeners.unregister(module);
|
|
87
|
+
break;
|
|
88
|
+
case ModuleType.Precondition:
|
|
89
|
+
this.client.preconditions?.cache.delete(module.id);
|
|
90
|
+
break;
|
|
91
|
+
case ModuleType.Postcondition:
|
|
92
|
+
this.client.postconditions?.cache.delete(module.id);
|
|
93
|
+
break;
|
|
94
|
+
case ModuleType.Base:
|
|
95
|
+
default: break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
emitOrThrow(event, ...args) {
|
|
99
|
+
if (this.client.listenerCount(event) > 0) return this.emit(event, ...args);
|
|
100
|
+
throw args[1];
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
ModuleManager = __decorate([mix(BaseManager, EventEmitter)], ModuleManager);
|
|
104
|
+
|
|
105
|
+
//#endregion
|
|
106
|
+
export { ModuleManager };
|
|
107
|
+
//# sourceMappingURL=ModuleManager.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ModuleManager.mjs","names":["ModuleManager","client: Client","enabledModules: AnyModule[]","readyModules: AnyModule[]","disabledModules: AnyModule[]"],"sources":["../../../src/classes/managers/ModuleManager.ts"],"sourcesContent":["import { mix } from 'ts-mixer';\nimport { BaseModule } from '../modules/BaseModule.js';\nimport { BaseManager, RecipleError, type Client } from '@reciple/core';\nimport { EventEmitter } from 'node:events';\nimport type { AnyModule } from '../../helpers/types.js';\nimport { ModuleType } from '../../helpers/constants.js';\n\nexport interface ModuleManager extends BaseManager<string, AnyModule, BaseModule.Resolvable>, EventEmitter<ModuleManager.Events> {}\n\n@mix(BaseManager, EventEmitter)\nexport class ModuleManager {\n public readonly holds = BaseModule;\n\n constructor(public readonly client: Client) {}\n\n public async enableModules({ modules, removeFromCacheOnError }: ModuleManager.EventExecuteData & { removeFromCacheOnError?: boolean; } = { modules: Array.from(this.cache.values()) }): Promise<AnyModule[]> {\n const enabledModules: AnyModule[] = [];\n\n for (const module of modules ?? []) {\n this.emit('modulePreEnable', module);\n\n await module.onEnable({ client: this.client }).catch(e => {\n if (removeFromCacheOnError) this.cache.delete(module.id);\n this.emitOrThrow('moduleEnableError', module, e);\n });\n\n this.emit('moduleEnable', module);\n this.add(module);\n enabledModules.push(module);\n }\n\n this.emit('enabledModules', enabledModules);\n return enabledModules;\n }\n\n public async readyModules({ modules, removeFromCacheOnError }: ModuleManager.EventExecuteData & { removeFromCacheOnError?: boolean; } = { modules: Array.from(this.cache.values()) }): Promise<AnyModule[]> {\n const readyModules: AnyModule[] = [];\n\n if (!this.client.isReady()) throw new RecipleError(RecipleError.Code.ClientNotReady());\n\n for (const module of modules ?? []) {\n this.emit('modulePreReady', module);\n\n await module.onReady({ client: this.client }).catch(e => {\n if (removeFromCacheOnError !== false) this.remove(module);\n this.emitOrThrow('moduleReadyError', module, e);\n });\n\n this.emit('moduleReady', module);\n this.cache.set(module.id, module);\n readyModules.push(module);\n }\n\n this.emit('readyModules', readyModules);\n return readyModules;\n }\n\n public async disableModules({ modules, removeFromCache }: ModuleManager.EventExecuteData & { removeFromCache?: boolean; } = { modules: Array.from(this.cache.values()) }): Promise<AnyModule[]> {\n const disabledModules: AnyModule[] = [];\n\n for (const module of modules ?? []) {\n this.emit('modulePreDisable', module);\n\n await module.onDisable({ client: this.client }).catch(e => {\n if (removeFromCache !== false) this.remove(module);\n this.emitOrThrow('moduleDisableError', module, e);\n });\n\n this.emit('moduleDisable', module);\n if (removeFromCache !== false) this.remove(module);\n disabledModules.push(module);\n }\n\n this.emit('disabledModules', disabledModules);\n return disabledModules;\n }\n\n public add(module: AnyModule): void {\n this.cache.set(module.id, module);\n switch (module.moduleType) {\n case ModuleType.Command:\n this.client.commands?.add(module);\n break;\n case ModuleType.Event:\n this.client.eventListeners.register(module);\n break;\n case ModuleType.Precondition:\n this.client.preconditions?.cache.set(module.id, module);\n break;\n case ModuleType.Postcondition:\n this.client.postconditions?.cache.set(module.id, module);\n break;\n case ModuleType.Base:\n default:\n break;\n }\n }\n\n public remove(module: AnyModule): void {\n this.cache.delete(module.id);\n switch (module.moduleType) {\n case ModuleType.Command:\n this.client.commands?.cache.delete(module.id);\n break;\n case ModuleType.Event:\n this.client.eventListeners.unregister(module);\n break;\n case ModuleType.Precondition:\n this.client.preconditions?.cache.delete(module.id);\n break;\n case ModuleType.Postcondition:\n this.client.postconditions?.cache.delete(module.id);\n break;\n case ModuleType.Base:\n default:\n break;\n }\n }\n\n private emitOrThrow<K extends keyof Pick<ModuleManager.Events, 'moduleDisableError'|'moduleEnableError'|'moduleReadyError'>>(event: K, ...args: ModuleManager.Events[K]) {\n if (this.client.listenerCount(event) > 0) {\n return this.emit(event, ...(args as never));\n }\n\n throw args[1];\n }\n}\n\nexport namespace ModuleManager {\n export interface Events {\n modulePreEnable: [module: AnyModule];\n moduleEnable: [module: AnyModule];\n moduleEnableError: [module: AnyModule, error: Error];\n enabledModules: [modules: AnyModule[]];\n\n modulePreReady: [module: AnyModule];\n moduleReady: [module: AnyModule];\n moduleReadyError: [module: AnyModule, error: Error];\n readyModules: [modules: AnyModule[]];\n\n modulePreDisable: [module: AnyModule];\n moduleDisable: [module: AnyModule];\n moduleDisableError: [module: AnyModule, error: Error];\n disabledModules: [modules: AnyModule[]];\n }\n\n export interface EventExecuteData {\n modules?: AnyModule[];\n }\n}\n"],"mappings":";;;;;;;;AAUO,0BAAMA,gBAAc;CACvB,AAAgB,QAAQ;CAExB,YAAY,AAAgBC,QAAgB;EAAhB;;CAE5B,MAAa,cAAc,EAAE,SAAS,2BAAmG,EAAE,SAAS,MAAM,KAAK,KAAK,MAAM,QAAQ,CAAC,EAAE,EAAwB;EACzM,MAAMC,iBAA8B,EAAE;AAEtC,OAAK,MAAM,UAAU,WAAW,EAAE,EAAE;AAChC,QAAK,KAAK,mBAAmB,OAAO;AAEpC,SAAM,OAAO,SAAS,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,OAAM,MAAK;AACtD,QAAI,uBAAwB,MAAK,MAAM,OAAO,OAAO,GAAG;AACxD,SAAK,YAAY,qBAAqB,QAAQ,EAAE;KAClD;AAEF,QAAK,KAAK,gBAAgB,OAAO;AACjC,QAAK,IAAI,OAAO;AAChB,kBAAe,KAAK,OAAO;;AAG/B,OAAK,KAAK,kBAAkB,eAAe;AAC3C,SAAO;;CAGX,MAAa,aAAa,EAAE,SAAS,2BAAmG,EAAE,SAAS,MAAM,KAAK,KAAK,MAAM,QAAQ,CAAC,EAAE,EAAwB;EACxM,MAAMC,eAA4B,EAAE;AAEpC,MAAI,CAAC,KAAK,OAAO,SAAS,CAAE,OAAM,IAAI,aAAa,aAAa,KAAK,gBAAgB,CAAC;AAEtF,OAAK,MAAM,UAAU,WAAW,EAAE,EAAE;AAChC,QAAK,KAAK,kBAAkB,OAAO;AAEnC,SAAM,OAAO,QAAQ,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,OAAM,MAAK;AACrD,QAAI,2BAA2B,MAAO,MAAK,OAAO,OAAO;AACzD,SAAK,YAAY,oBAAoB,QAAQ,EAAE;KACjD;AAEF,QAAK,KAAK,eAAe,OAAO;AAChC,QAAK,MAAM,IAAI,OAAO,IAAI,OAAO;AACjC,gBAAa,KAAK,OAAO;;AAG7B,OAAK,KAAK,gBAAgB,aAAa;AACvC,SAAO;;CAGX,MAAa,eAAe,EAAE,SAAS,oBAAqF,EAAE,SAAS,MAAM,KAAK,KAAK,MAAM,QAAQ,CAAC,EAAE,EAAwB;EAC5L,MAAMC,kBAA+B,EAAE;AAEvC,OAAK,MAAM,UAAU,WAAW,EAAE,EAAE;AAChC,QAAK,KAAK,oBAAoB,OAAO;AAErC,SAAM,OAAO,UAAU,EAAE,QAAQ,KAAK,QAAQ,CAAC,CAAC,OAAM,MAAK;AACvD,QAAI,oBAAoB,MAAO,MAAK,OAAO,OAAO;AAClD,SAAK,YAAY,sBAAsB,QAAQ,EAAE;KACnD;AAEF,QAAK,KAAK,iBAAiB,OAAO;AAClC,OAAI,oBAAoB,MAAO,MAAK,OAAO,OAAO;AAClD,mBAAgB,KAAK,OAAO;;AAGhC,OAAK,KAAK,mBAAmB,gBAAgB;AAC7C,SAAO;;CAGX,AAAO,IAAI,QAAyB;AAChC,OAAK,MAAM,IAAI,OAAO,IAAI,OAAO;AACjC,UAAQ,OAAO,YAAf;GACI,KAAK,WAAW;AACZ,SAAK,OAAO,UAAU,IAAI,OAAO;AACjC;GACJ,KAAK,WAAW;AACZ,SAAK,OAAO,eAAe,SAAS,OAAO;AAC3C;GACJ,KAAK,WAAW;AACZ,SAAK,OAAO,eAAe,MAAM,IAAI,OAAO,IAAI,OAAO;AACvD;GACJ,KAAK,WAAW;AACZ,SAAK,OAAO,gBAAgB,MAAM,IAAI,OAAO,IAAI,OAAO;AACxD;GACJ,KAAK,WAAW;GAChB,QACI;;;CAIZ,AAAO,OAAO,QAAyB;AACnC,OAAK,MAAM,OAAO,OAAO,GAAG;AAC5B,UAAQ,OAAO,YAAf;GACI,KAAK,WAAW;AACZ,SAAK,OAAO,UAAU,MAAM,OAAO,OAAO,GAAG;AAC7C;GACJ,KAAK,WAAW;AACZ,SAAK,OAAO,eAAe,WAAW,OAAO;AAC7C;GACJ,KAAK,WAAW;AACZ,SAAK,OAAO,eAAe,MAAM,OAAO,OAAO,GAAG;AAClD;GACJ,KAAK,WAAW;AACZ,SAAK,OAAO,gBAAgB,MAAM,OAAO,OAAO,GAAG;AACnD;GACJ,KAAK,WAAW;GAChB,QACI;;;CAIZ,AAAQ,YAAqH,OAAU,GAAG,MAA+B;AACrK,MAAI,KAAK,OAAO,cAAc,MAAM,GAAG,EACnC,QAAO,KAAK,KAAK,OAAO,GAAI,KAAe;AAG/C,QAAM,KAAK;;;4BAnHlB,IAAI,aAAa,aAAa"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
|
+
import { AnyModule } from "../../helpers/types.mjs";
|
|
3
|
+
import { Client } from "@reciple/core";
|
|
4
|
+
|
|
5
|
+
//#region src/classes/modules/BaseModule.d.ts
|
|
6
|
+
declare class BaseModule implements BaseModule.Data {
|
|
7
|
+
private readonly __$filepath;
|
|
8
|
+
readonly id: string;
|
|
9
|
+
readonly moduleType: ModuleType.Base;
|
|
10
|
+
client: Client;
|
|
11
|
+
onEnable(data: BaseModule.EventData<boolean>): Promise<void>;
|
|
12
|
+
onReady(data: BaseModule.EventData<true>): Promise<void>;
|
|
13
|
+
onDisable(data: BaseModule.EventData<boolean>): Promise<void>;
|
|
14
|
+
static isModule(data: unknown): data is AnyModule;
|
|
15
|
+
static from(data: BaseModule.Resolvable): BaseModule;
|
|
16
|
+
static getFilepath(module: AnyModule): string;
|
|
17
|
+
}
|
|
18
|
+
declare namespace BaseModule {
|
|
19
|
+
type Resolvable = BaseModule | Data;
|
|
20
|
+
const constructor: typeof BaseModule;
|
|
21
|
+
interface Data {
|
|
22
|
+
id?: string;
|
|
23
|
+
moduleType?: ModuleType.Base;
|
|
24
|
+
onEnable?(data: BaseModule.EventData<false>): Promise<void>;
|
|
25
|
+
onReady?(data: BaseModule.EventData<true>): Promise<void>;
|
|
26
|
+
onDisable?(data: BaseModule.EventData<boolean>): Promise<void>;
|
|
27
|
+
}
|
|
28
|
+
interface EventData<Ready extends boolean = boolean> {
|
|
29
|
+
client: Client<Ready>;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
//#endregion
|
|
33
|
+
export { BaseModule };
|
|
34
|
+
//# sourceMappingURL=BaseModule.d.mts.map
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
|
+
import { DiscordSnowflake } from "@sapphire/snowflake";
|
|
3
|
+
import { hasMixin } from "ts-mixer";
|
|
4
|
+
|
|
5
|
+
//#region src/classes/modules/BaseModule.ts
|
|
6
|
+
var BaseModule = class BaseModule {
|
|
7
|
+
__$filepath = "";
|
|
8
|
+
id = DiscordSnowflake.generate().toString();
|
|
9
|
+
moduleType = ModuleType.Base;
|
|
10
|
+
client;
|
|
11
|
+
async onEnable(data) {}
|
|
12
|
+
async onReady(data) {}
|
|
13
|
+
async onDisable(data) {}
|
|
14
|
+
static isModule(data) {
|
|
15
|
+
return data instanceof BaseModule || hasMixin(data, BaseModule);
|
|
16
|
+
}
|
|
17
|
+
static from(data) {
|
|
18
|
+
if (data instanceof BaseModule || hasMixin(data, BaseModule)) return data;
|
|
19
|
+
const ModuleInstance = class extends BaseModule {};
|
|
20
|
+
Object.assign(ModuleInstance.prototype, data);
|
|
21
|
+
return new ModuleInstance();
|
|
22
|
+
}
|
|
23
|
+
static getFilepath(module) {
|
|
24
|
+
return module.__$filepath || "";
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
(function(_BaseModule) {
|
|
28
|
+
_BaseModule.constructor = BaseModule;
|
|
29
|
+
})(BaseModule || (BaseModule = {}));
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
export { BaseModule };
|
|
33
|
+
//# sourceMappingURL=BaseModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseModule.mjs","names":[],"sources":["../../../src/classes/modules/BaseModule.ts"],"sourcesContent":["import type { Client } from '@reciple/core';\nimport { DiscordSnowflake } from '@sapphire/snowflake';\nimport { ModuleType } from '../../helpers/constants.js';\nimport { hasMixin } from 'ts-mixer';\nimport type { AnyModule } from '../../helpers/types.js';\n\nexport class BaseModule implements BaseModule.Data {\n private readonly __$filepath: string = '';\n\n public readonly id: string = DiscordSnowflake.generate().toString();\n public readonly moduleType: ModuleType.Base = ModuleType.Base;\n\n public client!: Client;\n\n public async onEnable(data: BaseModule.EventData<boolean>): Promise<void> {}\n\n public async onReady(data: BaseModule.EventData<true>): Promise<void> {}\n\n public async onDisable(data: BaseModule.EventData<boolean>): Promise<void> {}\n\n public static isModule(data: unknown): data is AnyModule {\n return data instanceof BaseModule || hasMixin(data, BaseModule);\n }\n\n public static from(data: BaseModule.Resolvable): BaseModule {\n if (data instanceof BaseModule || hasMixin(data, BaseModule)) return data;\n\n const ModuleInstance = class extends BaseModule {};\n Object.assign(ModuleInstance.prototype, data);\n return new ModuleInstance();\n }\n\n public static getFilepath(module: AnyModule): string {\n return (module as BaseModule).__$filepath || '';\n }\n}\n\nexport namespace BaseModule {\n export type Resolvable = BaseModule|Data;\n\n export const constructor = BaseModule;\n\n export interface Data {\n id?: string;\n moduleType?: ModuleType.Base;\n onEnable?(data: BaseModule.EventData<false>): Promise<void>;\n onReady?(data: BaseModule.EventData<true>): Promise<void>;\n onDisable?(data: BaseModule.EventData<boolean>): Promise<void>;\n }\n\n export interface EventData<Ready extends boolean = boolean> {\n client: Client<Ready>;\n }\n}\n"],"mappings":";;;;;AAMA,IAAa,aAAb,MAAa,WAAsC;CAC/C,AAAiB,cAAsB;CAEvC,AAAgB,KAAa,iBAAiB,UAAU,CAAC,UAAU;CACnE,AAAgB,aAA8B,WAAW;CAEzD,AAAO;CAEP,MAAa,SAAS,MAAoD;CAE1E,MAAa,QAAQ,MAAiD;CAEtE,MAAa,UAAU,MAAoD;CAE3E,OAAc,SAAS,MAAkC;AACrD,SAAO,gBAAgB,cAAc,SAAS,MAAM,WAAW;;CAGnE,OAAc,KAAK,MAAyC;AACxD,MAAI,gBAAgB,cAAc,SAAS,MAAM,WAAW,CAAE,QAAO;EAErE,MAAM,iBAAiB,cAAc,WAAW;AAChD,SAAO,OAAO,eAAe,WAAW,KAAK;AAC7C,SAAO,IAAI,gBAAgB;;CAG/B,OAAc,YAAY,QAA2B;AACjD,SAAQ,OAAsB,eAAe;;;;2BAOtB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "./BaseModule.mjs";
|
|
3
|
+
import { CommandPostcondition, CommandPrecondition, CommandType } from "@reciple/core";
|
|
4
|
+
|
|
5
|
+
//#region src/classes/modules/PostconditionModule.d.ts
|
|
6
|
+
interface PostconditionModule<D = any> extends Omit<BaseModule, 'moduleType'>, CommandPostcondition<D> {}
|
|
7
|
+
declare abstract class PostconditionModule<D = any> implements PostconditionModule<D> {
|
|
8
|
+
moduleType: ModuleType.Postcondition;
|
|
9
|
+
abstract execute<T extends CommandType>(data: CommandPostcondition.ExecuteData<T>, preconditionTrigger?: CommandPrecondition.ResultData<T, any>): Promise<CommandPostcondition.ResultDataResolvable<T, D>>;
|
|
10
|
+
static from<D = any>(data: PostconditionModule.Resolvable<D>): PostconditionModule<D>;
|
|
11
|
+
}
|
|
12
|
+
declare namespace PostconditionModule {
|
|
13
|
+
type Resolvable<D = any> = PostconditionModule<D> | PostconditionModule.Data<D>;
|
|
14
|
+
interface Data<D = any> extends Omit<BaseModule.Data, 'moduleType'>, Omit<CommandPostcondition.Data<D>, 'id'> {
|
|
15
|
+
moduleType: ModuleType.Postcondition;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { PostconditionModule };
|
|
20
|
+
//# sourceMappingURL=PostconditionModule.d.mts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "./BaseModule.mjs";
|
|
3
|
+
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
|
+
import { CommandPostcondition } from "@reciple/core";
|
|
5
|
+
import { hasMixin, mix } from "ts-mixer";
|
|
6
|
+
|
|
7
|
+
//#region src/classes/modules/PostconditionModule.ts
|
|
8
|
+
var _PostconditionModule;
|
|
9
|
+
let PostconditionModule = _PostconditionModule = class PostconditionModule$1 {
|
|
10
|
+
moduleType = ModuleType.Postcondition;
|
|
11
|
+
static from(data) {
|
|
12
|
+
if (data instanceof _PostconditionModule || hasMixin(data, _PostconditionModule)) return data;
|
|
13
|
+
const ModuleInstance = class extends _PostconditionModule {
|
|
14
|
+
execute = data.execute;
|
|
15
|
+
};
|
|
16
|
+
Object.assign(ModuleInstance.prototype, data);
|
|
17
|
+
return new ModuleInstance();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
PostconditionModule = _PostconditionModule = __decorate([mix(BaseModule, CommandPostcondition)], PostconditionModule);
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { PostconditionModule };
|
|
24
|
+
//# sourceMappingURL=PostconditionModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PostconditionModule.mjs","names":["PostconditionModule"],"sources":["../../../src/classes/modules/PostconditionModule.ts"],"sourcesContent":["import { CommandPostcondition, type CommandPrecondition, type CommandType } from '@reciple/core';\nimport { BaseModule } from './BaseModule.js';\nimport { hasMixin, mix } from 'ts-mixer';\nimport { ModuleType } from '../../helpers/constants.js';\n\nexport interface PostconditionModule<D = any> extends Omit<BaseModule, 'moduleType'>, CommandPostcondition<D> {}\n\n@mix(BaseModule, CommandPostcondition)\nexport abstract class PostconditionModule<D = any> implements PostconditionModule<D> {\n public moduleType: ModuleType.Postcondition = ModuleType.Postcondition;\n\n public abstract execute<T extends CommandType>(data: CommandPostcondition.ExecuteData<T>, preconditionTrigger?: CommandPrecondition.ResultData<T, any>): Promise<CommandPostcondition.ResultDataResolvable<T, D>>;\n\n public static from<D = any>(data: PostconditionModule.Resolvable<D>): PostconditionModule<D> {\n if (data instanceof PostconditionModule || hasMixin(data, PostconditionModule)) return data;\n\n const ModuleInstance = class extends PostconditionModule { execute = data.execute; };\n Object.assign(ModuleInstance.prototype, data);\n return new ModuleInstance();\n }\n}\n\nexport namespace PostconditionModule {\n export type Resolvable<D = any> = PostconditionModule<D>|PostconditionModule.Data<D>;\n\n export interface Data<D = any> extends Omit<BaseModule.Data, 'moduleType'>, Omit<CommandPostcondition.Data<D>, 'id'> {\n moduleType: ModuleType.Postcondition;\n }\n}\n"],"mappings":";;;;;;;;AAQO,uDAAeA,sBAA+D;CACjF,AAAO,aAAuC,WAAW;CAIzD,OAAc,KAAc,MAAiE;AACzF,MAAI,wCAAuC,SAAS,2BAA0B,CAAE,QAAO;EAEvF,MAAM,iBAAiB,mCAAkC;GAAE,UAAU,KAAK;;AAC1E,SAAO,OAAO,eAAe,WAAW,KAAK;AAC7C,SAAO,IAAI,gBAAgB;;;yDAXlC,IAAI,YAAY,qBAAqB"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "./BaseModule.mjs";
|
|
3
|
+
import { AnyCommandExecuteData, CommandPrecondition, CommandType } from "@reciple/core";
|
|
4
|
+
|
|
5
|
+
//#region src/classes/modules/PreconditionModule.d.ts
|
|
6
|
+
interface PreconditionModule<D = any> extends Omit<BaseModule, 'moduleType'>, CommandPrecondition<D> {}
|
|
7
|
+
declare abstract class PreconditionModule<D = any> implements PreconditionModule<D> {
|
|
8
|
+
moduleType: ModuleType.Precondition;
|
|
9
|
+
abstract execute<T extends CommandType>(data: AnyCommandExecuteData<T>): Promise<CommandPrecondition.ResultDataResolvable<T, D>>;
|
|
10
|
+
static from<D>(data: PreconditionModule.Resolvable<D>): PreconditionModule<D>;
|
|
11
|
+
}
|
|
12
|
+
declare namespace PreconditionModule {
|
|
13
|
+
type Resolvable<D = any> = PreconditionModule<D> | PreconditionModule.Data<D>;
|
|
14
|
+
interface Data<D = any> extends Omit<BaseModule.Data, 'moduleType'>, Omit<CommandPrecondition.Data<D>, 'id'> {
|
|
15
|
+
moduleType: ModuleType.Precondition;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
//#endregion
|
|
19
|
+
export { PreconditionModule };
|
|
20
|
+
//# sourceMappingURL=PreconditionModule.d.mts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleType } from "../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "./BaseModule.mjs";
|
|
3
|
+
import { __decorate } from "../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
|
+
import { CommandPrecondition } from "@reciple/core";
|
|
5
|
+
import { hasMixin, mix } from "ts-mixer";
|
|
6
|
+
|
|
7
|
+
//#region src/classes/modules/PreconditionModule.ts
|
|
8
|
+
var _PreconditionModule;
|
|
9
|
+
let PreconditionModule = _PreconditionModule = class PreconditionModule$1 {
|
|
10
|
+
moduleType = ModuleType.Precondition;
|
|
11
|
+
static from(data) {
|
|
12
|
+
if (data instanceof _PreconditionModule || hasMixin(data, _PreconditionModule)) return data;
|
|
13
|
+
const ModuleInstance = class extends _PreconditionModule {
|
|
14
|
+
execute = data.execute;
|
|
15
|
+
};
|
|
16
|
+
Object.assign(ModuleInstance.prototype, data);
|
|
17
|
+
return new ModuleInstance();
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
PreconditionModule = _PreconditionModule = __decorate([mix(BaseModule, CommandPrecondition)], PreconditionModule);
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { PreconditionModule };
|
|
24
|
+
//# sourceMappingURL=PreconditionModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PreconditionModule.mjs","names":["PreconditionModule"],"sources":["../../../src/classes/modules/PreconditionModule.ts"],"sourcesContent":["import { CommandPrecondition, type AnyCommandExecuteData, type CommandType } from '@reciple/core';\nimport { BaseModule } from './BaseModule.js';\nimport { hasMixin, mix } from 'ts-mixer';\nimport { ModuleType } from '../../helpers/constants.js';\n\nexport interface PreconditionModule<D = any> extends Omit<BaseModule, 'moduleType'>, CommandPrecondition<D> {}\n\n@mix(BaseModule, CommandPrecondition)\nexport abstract class PreconditionModule<D = any> implements PreconditionModule<D> {\n public moduleType: ModuleType.Precondition = ModuleType.Precondition;\n\n public abstract execute<T extends CommandType>(data: AnyCommandExecuteData<T>): Promise<CommandPrecondition.ResultDataResolvable<T, D>>;\n\n public static from<D>(data: PreconditionModule.Resolvable<D>): PreconditionModule<D> {\n if (data instanceof PreconditionModule || hasMixin(data, PreconditionModule)) return data;\n\n const ModuleInstance = class extends PreconditionModule { execute = data.execute; };\n Object.assign(ModuleInstance.prototype, data);\n return new ModuleInstance();\n }\n}\n\nexport namespace PreconditionModule {\n export type Resolvable<D = any> = PreconditionModule<D>|PreconditionModule.Data<D>;\n\n export interface Data<D = any> extends Omit<BaseModule.Data, 'moduleType'>, Omit<CommandPrecondition.Data<D>, 'id'> {\n moduleType: ModuleType.Precondition;\n }\n}\n"],"mappings":";;;;;;;;AAQO,qDAAeA,qBAA6D;CAC/E,AAAO,aAAsC,WAAW;CAIxD,OAAc,KAAQ,MAA+D;AACjF,MAAI,uCAAsC,SAAS,0BAAyB,CAAE,QAAO;EAErF,MAAM,iBAAiB,kCAAiC;GAAE,UAAU,KAAK;;AACzE,SAAO,OAAO,eAAe,WAAW,KAAK;AAC7C,SAAO,IAAI,gBAAgB;;;uDAXlC,IAAI,YAAY,oBAAoB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleType } from "../../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "../BaseModule.mjs";
|
|
3
|
+
import { AnyCommandBuilderMethods } from "../../../helpers/types.mjs";
|
|
4
|
+
import { ContextMenuCommand, ContextMenuCommandBuilder } from "@reciple/core";
|
|
5
|
+
|
|
6
|
+
//#region src/classes/modules/commands/ContextMenuCommandModule.d.ts
|
|
7
|
+
interface ContextMenuCommandModule extends Omit<BaseModule, 'moduleType'>, ContextMenuCommandModule.ContextMenuCommandWithoutBuilderMethods {}
|
|
8
|
+
declare abstract class ContextMenuCommandModule implements ContextMenuCommandModule {
|
|
9
|
+
readonly moduleType: ModuleType.Command;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
abstract data: ContextMenuCommandBuilder.Data;
|
|
12
|
+
abstract execute(data: ContextMenuCommand.ExecuteData): Promise<void>;
|
|
13
|
+
static from(data: ContextMenuCommandModule.Resolvable): ContextMenuCommandModule;
|
|
14
|
+
}
|
|
15
|
+
declare namespace ContextMenuCommandModule {
|
|
16
|
+
type Resolvable = ContextMenuCommandModule | ContextMenuCommandModule.Data;
|
|
17
|
+
interface Data extends Omit<BaseModule.Data, 'moduleType'>, Omit<ContextMenuCommand.Data, 'id'> {
|
|
18
|
+
moduleType: ModuleType.Command;
|
|
19
|
+
}
|
|
20
|
+
type ContextMenuCommandWithoutBuilderMethods = Omit<ContextMenuCommand, AnyCommandBuilderMethods>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { ContextMenuCommandModule };
|
|
24
|
+
//# sourceMappingURL=ContextMenuCommandModule.d.mts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ModuleType } from "../../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "../BaseModule.mjs";
|
|
3
|
+
import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
|
+
import { ContextMenuCommand } from "@reciple/core";
|
|
5
|
+
import { DiscordSnowflake } from "@sapphire/snowflake";
|
|
6
|
+
import { hasMixin, mix } from "ts-mixer";
|
|
7
|
+
|
|
8
|
+
//#region src/classes/modules/commands/ContextMenuCommandModule.ts
|
|
9
|
+
var _ContextMenuCommandModule;
|
|
10
|
+
let ContextMenuCommandModule = _ContextMenuCommandModule = class ContextMenuCommandModule$1 {
|
|
11
|
+
moduleType = ModuleType.Command;
|
|
12
|
+
id = DiscordSnowflake.generate().toString();
|
|
13
|
+
static from(data) {
|
|
14
|
+
if (data instanceof _ContextMenuCommandModule || hasMixin(data, _ContextMenuCommandModule)) return data;
|
|
15
|
+
const ModuleInstance = class extends _ContextMenuCommandModule {
|
|
16
|
+
data = data.data;
|
|
17
|
+
execute = data.execute;
|
|
18
|
+
};
|
|
19
|
+
Object.assign(ModuleInstance.prototype, data);
|
|
20
|
+
return new ModuleInstance();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
ContextMenuCommandModule = _ContextMenuCommandModule = __decorate([mix(BaseModule, ContextMenuCommand)], ContextMenuCommandModule);
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { ContextMenuCommandModule };
|
|
27
|
+
//# sourceMappingURL=ContextMenuCommandModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextMenuCommandModule.mjs","names":["ContextMenuCommandModule"],"sources":["../../../../src/classes/modules/commands/ContextMenuCommandModule.ts"],"sourcesContent":["import { BaseModule } from '../BaseModule.js';\nimport { ModuleType } from '../../../helpers/constants.js';\nimport { DiscordSnowflake } from '@sapphire/snowflake';\nimport { hasMixin, mix } from 'ts-mixer';\nimport type { AnyCommandBuilderMethods } from '../../../helpers/types.js';\nimport { ContextMenuCommand, type ContextMenuCommandBuilder } from '@reciple/core';\n\nexport interface ContextMenuCommandModule extends Omit<BaseModule, 'moduleType'>, ContextMenuCommandModule.ContextMenuCommandWithoutBuilderMethods {}\n\n@mix(BaseModule, ContextMenuCommand)\nexport abstract class ContextMenuCommandModule implements ContextMenuCommandModule {\n public readonly moduleType: ModuleType.Command = ModuleType.Command;\n public readonly id: string = DiscordSnowflake.generate().toString();\n\n public abstract data: ContextMenuCommandBuilder.Data;\n\n public abstract execute(data: ContextMenuCommand.ExecuteData): Promise<void>;\n\n public static from(data: ContextMenuCommandModule.Resolvable): ContextMenuCommandModule {\n if (data instanceof ContextMenuCommandModule || hasMixin(data, ContextMenuCommandModule)) return data;\n\n const ModuleInstance = class extends ContextMenuCommandModule { data = data.data; execute = data.execute; };\n Object.assign(ModuleInstance.prototype, data);\n return new ModuleInstance();\n }\n}\n\nexport namespace ContextMenuCommandModule {\n export type Resolvable = ContextMenuCommandModule|ContextMenuCommandModule.Data;\n\n export interface Data extends Omit<BaseModule.Data, 'moduleType'>, Omit<ContextMenuCommand.Data, 'id'> {\n moduleType: ModuleType.Command;\n }\n\n export type ContextMenuCommandWithoutBuilderMethods = Omit<ContextMenuCommand, AnyCommandBuilderMethods>;\n}\n"],"mappings":";;;;;;;;;AAUO,iEAAeA,2BAA6D;CAC/E,AAAgB,aAAiC,WAAW;CAC5D,AAAgB,KAAa,iBAAiB,UAAU,CAAC,UAAU;CAMnE,OAAc,KAAK,MAAqE;AACpF,MAAI,6CAA4C,SAAS,gCAA+B,CAAE,QAAO;EAEjG,MAAM,iBAAiB,wCAAuC;GAAE,OAAO,KAAK;GAAM,UAAU,KAAK;;AACjG,SAAO,OAAO,eAAe,WAAW,KAAK;AAC7C,SAAO,IAAI,gBAAgB;;;mEAdlC,IAAI,YAAY,mBAAmB"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleType } from "../../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "../BaseModule.mjs";
|
|
3
|
+
import { AnyCommandBuilderMethods } from "../../../helpers/types.mjs";
|
|
4
|
+
import { MessageCommand, MessageCommandBuilder } from "@reciple/core";
|
|
5
|
+
|
|
6
|
+
//#region src/classes/modules/commands/MessageCommandModule.d.ts
|
|
7
|
+
interface MessageCommandModule extends Omit<BaseModule, 'moduleType'>, MessageCommandModule.MessageCommandWithoutBuilderMethods {}
|
|
8
|
+
declare abstract class MessageCommandModule implements MessageCommandModule {
|
|
9
|
+
readonly moduleType: ModuleType.Command;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
abstract data: MessageCommandBuilder.Data;
|
|
12
|
+
abstract execute(data: MessageCommand.ExecuteData): Promise<void>;
|
|
13
|
+
static from(data: MessageCommandModule.Resolvable): MessageCommandModule;
|
|
14
|
+
}
|
|
15
|
+
declare namespace MessageCommandModule {
|
|
16
|
+
type Resolvable = MessageCommandModule | MessageCommandModule.Data;
|
|
17
|
+
interface Data extends Omit<BaseModule.Data, 'moduleType'>, Omit<MessageCommand.Data, 'id'> {
|
|
18
|
+
moduleType: ModuleType.Command;
|
|
19
|
+
}
|
|
20
|
+
type MessageCommandWithoutBuilderMethods = Omit<MessageCommand, AnyCommandBuilderMethods | 'options' | 'flags'>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { MessageCommandModule };
|
|
24
|
+
//# sourceMappingURL=MessageCommandModule.d.mts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ModuleType } from "../../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "../BaseModule.mjs";
|
|
3
|
+
import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
|
+
import { MessageCommand, MessageCommandBuilder } from "@reciple/core";
|
|
5
|
+
import { DiscordSnowflake } from "@sapphire/snowflake";
|
|
6
|
+
import { hasMixin, mix } from "ts-mixer";
|
|
7
|
+
|
|
8
|
+
//#region src/classes/modules/commands/MessageCommandModule.ts
|
|
9
|
+
var _MessageCommandModule;
|
|
10
|
+
let MessageCommandModule = _MessageCommandModule = class MessageCommandModule$1 {
|
|
11
|
+
moduleType = ModuleType.Command;
|
|
12
|
+
id = DiscordSnowflake.generate().toString();
|
|
13
|
+
static from(data) {
|
|
14
|
+
if (data instanceof _MessageCommandModule || hasMixin(data, _MessageCommandModule)) return data;
|
|
15
|
+
const ModuleInstance = class extends _MessageCommandModule {
|
|
16
|
+
data = data.data;
|
|
17
|
+
execute = data.execute;
|
|
18
|
+
};
|
|
19
|
+
Object.assign(ModuleInstance.prototype, data);
|
|
20
|
+
return new ModuleInstance();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
MessageCommandModule = _MessageCommandModule = __decorate([mix(BaseModule, MessageCommand)], MessageCommandModule);
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { MessageCommandModule };
|
|
27
|
+
//# sourceMappingURL=MessageCommandModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MessageCommandModule.mjs","names":["MessageCommandModule"],"sources":["../../../../src/classes/modules/commands/MessageCommandModule.ts"],"sourcesContent":["import { MessageCommand, MessageCommandBuilder } from '@reciple/core';\nimport { BaseModule } from '../BaseModule.js';\nimport { ModuleType } from '../../../helpers/constants.js';\nimport { DiscordSnowflake } from '@sapphire/snowflake';\nimport { hasMixin, mix } from 'ts-mixer';\nimport type { AnyCommandBuilderMethods } from '../../../helpers/types.js';\n\nexport interface MessageCommandModule extends Omit<BaseModule, 'moduleType'>, MessageCommandModule.MessageCommandWithoutBuilderMethods {}\n\n@mix(BaseModule, MessageCommand)\nexport abstract class MessageCommandModule implements MessageCommandModule {\n public readonly moduleType: ModuleType.Command = ModuleType.Command;\n public readonly id: string = DiscordSnowflake.generate().toString();\n\n public abstract data: MessageCommandBuilder.Data;\n\n public abstract execute(data: MessageCommand.ExecuteData): Promise<void>;\n\n public static from(data: MessageCommandModule.Resolvable): MessageCommandModule {\n if (data instanceof MessageCommandModule || hasMixin(data, MessageCommandModule)) return data;\n\n const ModuleInstance = class extends MessageCommandModule { data = data.data; execute = data.execute; };\n Object.assign(ModuleInstance.prototype, data);\n return new ModuleInstance();\n }\n}\n\nexport namespace MessageCommandModule {\n export type Resolvable = MessageCommandModule|MessageCommandModule.Data;\n\n export interface Data extends Omit<BaseModule.Data, 'moduleType'>, Omit<MessageCommand.Data, 'id'> {\n moduleType: ModuleType.Command;\n }\n\n export type MessageCommandWithoutBuilderMethods = Omit<MessageCommand, AnyCommandBuilderMethods|'options'|'flags'>;\n}\n"],"mappings":";;;;;;;;;AAUO,yDAAeA,uBAAqD;CACvE,AAAgB,aAAiC,WAAW;CAC5D,AAAgB,KAAa,iBAAiB,UAAU,CAAC,UAAU;CAMnE,OAAc,KAAK,MAA6D;AAC5E,MAAI,yCAAwC,SAAS,4BAA2B,CAAE,QAAO;EAEzF,MAAM,iBAAiB,oCAAmC;GAAE,OAAO,KAAK;GAAM,UAAU,KAAK;;AAC7F,SAAO,OAAO,eAAe,WAAW,KAAK;AAC7C,SAAO,IAAI,gBAAgB;;;2DAdlC,IAAI,YAAY,eAAe"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { ModuleType } from "../../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "../BaseModule.mjs";
|
|
3
|
+
import { AnyCommandBuilderMethods } from "../../../helpers/types.mjs";
|
|
4
|
+
import { SlashCommand, SlashCommandBuilder } from "@reciple/core";
|
|
5
|
+
|
|
6
|
+
//#region src/classes/modules/commands/SlashCommandModule.d.ts
|
|
7
|
+
interface SlashCommandModule extends Omit<BaseModule, 'moduleType'>, SlashCommandModule.SlashCommandWithoutBuilderMethods {}
|
|
8
|
+
declare abstract class SlashCommandModule implements SlashCommandModule {
|
|
9
|
+
readonly moduleType: ModuleType.Command;
|
|
10
|
+
readonly id: string;
|
|
11
|
+
abstract data: SlashCommandBuilder.Data;
|
|
12
|
+
abstract execute(data: SlashCommand.ExecuteData): Promise<void>;
|
|
13
|
+
static from(data: SlashCommandModule.Resolvable): SlashCommandModule;
|
|
14
|
+
}
|
|
15
|
+
declare namespace SlashCommandModule {
|
|
16
|
+
type Resolvable = SlashCommandModule | SlashCommandModule.Data;
|
|
17
|
+
interface Data extends Omit<BaseModule.Data, 'moduleType'>, Omit<SlashCommand.Data, 'id'> {
|
|
18
|
+
moduleType: ModuleType.Command;
|
|
19
|
+
}
|
|
20
|
+
type SlashCommandWithoutBuilderMethods = Omit<SlashCommand, AnyCommandBuilderMethods>;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
export { SlashCommandModule };
|
|
24
|
+
//# sourceMappingURL=SlashCommandModule.d.mts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { ModuleType } from "../../../helpers/constants.mjs";
|
|
2
|
+
import { BaseModule } from "../BaseModule.mjs";
|
|
3
|
+
import { __decorate } from "../../../_virtual/_@oxc-project_runtime@0.99.0/helpers/decorate.mjs";
|
|
4
|
+
import { SlashCommand } from "@reciple/core";
|
|
5
|
+
import { DiscordSnowflake } from "@sapphire/snowflake";
|
|
6
|
+
import { hasMixin, mix } from "ts-mixer";
|
|
7
|
+
|
|
8
|
+
//#region src/classes/modules/commands/SlashCommandModule.ts
|
|
9
|
+
var _SlashCommandModule;
|
|
10
|
+
let SlashCommandModule = _SlashCommandModule = class SlashCommandModule$1 {
|
|
11
|
+
moduleType = ModuleType.Command;
|
|
12
|
+
id = DiscordSnowflake.generate().toString();
|
|
13
|
+
static from(data) {
|
|
14
|
+
if (data instanceof _SlashCommandModule || hasMixin(data, _SlashCommandModule)) return data;
|
|
15
|
+
const ModuleInstance = class extends _SlashCommandModule {
|
|
16
|
+
data = data.data;
|
|
17
|
+
execute = data.execute;
|
|
18
|
+
};
|
|
19
|
+
Object.assign(ModuleInstance.prototype, data);
|
|
20
|
+
return new ModuleInstance();
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
SlashCommandModule = _SlashCommandModule = __decorate([mix(BaseModule, SlashCommand)], SlashCommandModule);
|
|
24
|
+
|
|
25
|
+
//#endregion
|
|
26
|
+
export { SlashCommandModule };
|
|
27
|
+
//# sourceMappingURL=SlashCommandModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SlashCommandModule.mjs","names":["SlashCommandModule"],"sources":["../../../../src/classes/modules/commands/SlashCommandModule.ts"],"sourcesContent":["import { BaseModule } from '../BaseModule.js';\nimport { ModuleType } from '../../../helpers/constants.js';\nimport { DiscordSnowflake } from '@sapphire/snowflake';\nimport { hasMixin, mix } from 'ts-mixer';\nimport { SlashCommand, type SlashCommandBuilder } from '@reciple/core';\nimport type { AnyCommandBuilderMethods } from '../../../helpers/types.js';\n\nexport interface SlashCommandModule extends Omit<BaseModule, 'moduleType'>, SlashCommandModule.SlashCommandWithoutBuilderMethods {}\n\n@mix(BaseModule, SlashCommand)\nexport abstract class SlashCommandModule implements SlashCommandModule {\n public readonly moduleType: ModuleType.Command = ModuleType.Command;\n public readonly id: string = DiscordSnowflake.generate().toString();\n\n public abstract data: SlashCommandBuilder.Data;\n\n public abstract execute(data: SlashCommand.ExecuteData): Promise<void>;\n\n public static from(data: SlashCommandModule.Resolvable): SlashCommandModule {\n if (data instanceof SlashCommandModule || hasMixin(data, SlashCommandModule)) return data;\n\n const ModuleInstance = class extends SlashCommandModule { data = data.data; execute = data.execute; };\n Object.assign(ModuleInstance.prototype, data);\n return new ModuleInstance();\n }\n}\n\nexport namespace SlashCommandModule {\n export type Resolvable = SlashCommandModule|SlashCommandModule.Data;\n\n export interface Data extends Omit<BaseModule.Data, 'moduleType'>, Omit<SlashCommand.Data, 'id'> {\n moduleType: ModuleType.Command;\n }\n\n export type SlashCommandWithoutBuilderMethods = Omit<SlashCommand, AnyCommandBuilderMethods>;\n}\n"],"mappings":";;;;;;;;;AAUO,qDAAeA,qBAAiD;CACnE,AAAgB,aAAiC,WAAW;CAC5D,AAAgB,KAAa,iBAAiB,UAAU,CAAC,UAAU;CAMnE,OAAc,KAAK,MAAyD;AACxE,MAAI,uCAAsC,SAAS,0BAAyB,CAAE,QAAO;EAErF,MAAM,iBAAiB,kCAAiC;GAAE,OAAO,KAAK;GAAM,UAAU,KAAK;;AAC3F,SAAO,OAAO,eAAe,WAAW,KAAK;AAC7C,SAAO,IAAI,gBAAgB;;;uDAdlC,IAAI,YAAY,aAAa"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { EventModule } from "./EventModule.mjs";
|
|
2
|
+
import { Client } from "@reciple/core";
|
|
3
|
+
|
|
4
|
+
//#region src/classes/modules/events/ClientEventModule.d.ts
|
|
5
|
+
declare abstract class ClientEventModule<Event extends keyof Client.Events> extends EventModule<Client.Events, Event> {
|
|
6
|
+
emitter: Client;
|
|
7
|
+
abstract event: Event;
|
|
8
|
+
}
|
|
9
|
+
//#endregion
|
|
10
|
+
export { ClientEventModule };
|
|
11
|
+
//# sourceMappingURL=ClientEventModule.d.mts.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { EventModule } from "./EventModule.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/classes/modules/events/ClientEventModule.ts
|
|
4
|
+
var ClientEventModule = class extends EventModule {
|
|
5
|
+
emitter = useClient();
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { ClientEventModule };
|
|
10
|
+
//# sourceMappingURL=ClientEventModule.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ClientEventModule.mjs","names":[],"sources":["../../../../src/classes/modules/events/ClientEventModule.ts"],"sourcesContent":["import type { Client } from '@reciple/core';\nimport { EventModule } from './EventModule.js';\n\nexport abstract class ClientEventModule<Event extends keyof Client.Events> extends EventModule<Client.Events, Event> {\n public emitter: Client = useClient();\n public abstract event: Event;\n}\n"],"mappings":";;;AAGA,IAAsB,oBAAtB,cAAmF,YAAkC;CACjH,AAAO,UAAkB,WAAW"}
|