Compare commits

...

6 Commits
v4.2.4 ... main

Author SHA1 Message Date
github-actions[bot]
fb6e8c2cfc chore(main): release 4.2.6 (#403)
Some checks failed
Continuous Delivery / Publishing Dev (push) Has been cancelled
NPM / Publish / test-and-publish (push) Has been cancelled
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-09-22 16:52:08 -05:00
Duro
0eecb08e87 chore: release 4.2.6 (#402)
Release-As: 4.2.6
2025-09-22 16:40:12 -05:00
Duro
c67748c7df fix ready deprecation (#401)
* chore: bump discord.js version

* fix: change ready event to clientReady to fix deprecation warning

* fix: fix compatibility for older discord.js versions

* chore: bump package version
2025-09-22 11:23:07 -05:00
github-actions[bot]
efee0fdbe2 chore(main): release 4.2.5 (#400) 2025-08-31 14:27:57 -05:00
Duro
797442ece3 fix: make message module warn rather than throwing (#399) 2025-08-31 14:23:39 -05:00
renovate[bot]
513ac8edf4 chore(deps): lock file maintenance (#391)
Some checks failed
NPM / Publish / test-and-publish (push) Has been cancelled
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-03-10 00:46:28 -05:00
5 changed files with 559 additions and 248 deletions

View File

@@ -1,5 +1,19 @@
# Changelog # Changelog
## [4.2.6](https://github.com/sern-handler/handler/compare/v4.2.5...v4.2.6) (2025-09-22)
### Miscellaneous Chores
* release 4.2.6 ([#402](https://github.com/sern-handler/handler/issues/402)) ([0eecb08](https://github.com/sern-handler/handler/commit/0eecb08e87e26102030ccf6ef38ddd81051ec373))
## [4.2.5](https://github.com/sern-handler/handler/compare/v4.2.4...v4.2.5) (2025-08-31)
### Bug Fixes
* make message module warn rather than throwing ([#399](https://github.com/sern-handler/handler/issues/399)) ([797442e](https://github.com/sern-handler/handler/commit/797442ece3999bf2cb6b5ba0688ce0177e72a22f))
## [4.2.4](https://github.com/sern-handler/handler/compare/v4.2.3...v4.2.4) (2025-03-06) ## [4.2.4](https://github.com/sern-handler/handler/compare/v4.2.3...v4.2.4) (2025-03-06)

699
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{ {
"name": "@sern/handler", "name": "@sern/handler",
"packageManager": "yarn@3.5.0", "packageManager": "yarn@3.5.0",
"version": "4.2.4", "version": "4.2.6",
"description": "A complete, customizable, typesafe, & reactive framework for discord bots.", "description": "A complete, customizable, typesafe, & reactive framework for discord bots.",
"main": "./dist/index.js", "main": "./dist/index.js",
"module": "./dist/index.js", "module": "./dist/index.js",
@@ -47,7 +47,7 @@
"@types/node-cron": "^3.0.11", "@types/node-cron": "^3.0.11",
"@typescript-eslint/eslint-plugin": "5.58.0", "@typescript-eslint/eslint-plugin": "5.58.0",
"@typescript-eslint/parser": "5.59.1", "@typescript-eslint/parser": "5.59.1",
"discord.js": "^14.14.1", "discord.js": "^14.22.1",
"eslint": "8.39.0", "eslint": "8.39.0",
"typescript": "5.0.2", "typescript": "5.0.2",
"vitest": "^1.6.0" "vitest": "^1.6.0"

View File

@@ -36,7 +36,7 @@ export function messageHandler (deps: UnpackedDependencies, defaultPrefix?: stri
const [prefix] = fmt(message.content, defaultPrefix); const [prefix] = fmt(message.content, defaultPrefix);
let module = mg.get(`${prefix}_T`) ?? mg.get(`${prefix}_B`) as Module; let module = mg.get(`${prefix}_T`) ?? mg.get(`${prefix}_B`) as Module;
if(!module) { if(!module) {
throw Error('Possibly undefined behavior: could not find a static id to resolve') log?.warning({ message: 'Possibly undefined behavior: could not find a static id to resolve' });
} }
const payload = { module, args: [Context.wrap(message, defaultPrefix), createSDT(module, deps, undefined)] } const payload = { module, args: [Context.wrap(message, defaultPrefix), createSDT(module, deps, undefined)] }
const result = await callPlugins(payload) const result = await callPlugins(payload)

View File

@@ -1,44 +1,58 @@
import * as Files from '../core/module-loading' import * as Files from "../core/module-loading";
import { once } from 'node:events'; import { once } from "node:events";
import { createLookupTable, resultPayload } from '../core/functions'; import { createLookupTable, resultPayload } from "../core/functions";
import { CommandType } from '../core/structures/enums'; import { CommandType } from "../core/structures/enums";
import { Module, SernOptionsData } from '../types/core-modules'; import { Module, SernOptionsData } from "../types/core-modules";
import type { UnpackedDependencies, Wrapper } from '../types/utility'; import type { UnpackedDependencies, Wrapper } from "../types/utility";
import { callInitPlugins } from './event-utils'; import { callInitPlugins } from "./event-utils";
import { SernAutocompleteData } from '..'; import { SernAutocompleteData } from "..";
import { Events } from "discord.js";
export default async function(dirs: string | string[], deps : UnpackedDependencies) { export default async function (
const { '@sern/client': client, dirs: string | string[],
'@sern/logger': log, deps: UnpackedDependencies,
'@sern/emitter': sEmitter, ) {
'@sern/modules': commands } = deps; const {
log?.info({ message: "Waiting on discord client to be ready..." }) "@sern/client": client,
await once(client, "ready"); "@sern/logger": log,
log?.info({ message: "Client signaled ready, registering modules" }); "@sern/emitter": sEmitter,
"@sern/modules": commands,
} = deps;
log?.info({ message: "Waiting on discord client to be ready..." });
await once(client, Events.ClientReady);
log?.info({ message: "Client signaled ready, registering modules" });
// https://observablehq.com/@ehouais/multiple-promises-as-an-async-generator // https://observablehq.com/@ehouais/multiple-promises-as-an-async-generator
// possibly optimize to concurrently import modules // possibly optimize to concurrently import modules
const directories = Array.isArray(dirs) ? dirs : [dirs]; const directories = Array.isArray(dirs) ? dirs : [dirs];
for (const dir of directories) { for (const dir of directories) {
for await (const path of Files.readRecursive(dir)) { for await (const path of Files.readRecursive(dir)) {
let { module } = await Files.importModule<Module>(path); const { module } = await Files.importModule<Module>(path);
const validType = module.type >= CommandType.Text && module.type <= CommandType.ChannelSelect; const validType =
if(!validType) { module.type >= CommandType.Text &&
throw Error(`Found ${module.name} at ${module.meta.absPath}, which has incorrect \`type\``); module.type <= CommandType.ChannelSelect;
} if (!validType) {
const resultModule = await callInitPlugins(module, deps, true); throw Error(
`Found ${module.name} at ${module.meta.absPath}, which has incorrect \`type\``,
);
}
const resultModule = await callInitPlugins(module, deps, true);
if(module.type === CommandType.Both || module.type === CommandType.Slash) { if (
const options = (Reflect.get(module, 'options') ?? []) as SernOptionsData[]; module.type === CommandType.Both ||
const lookupTable = createLookupTable(options) module.type === CommandType.Slash
module.locals['@sern/lookup-table'] = lookupTable; ) {
} const options = (Reflect.get(module, "options") ??
// FREEZE! no more writing!! []) as SernOptionsData[];
commands.set(resultModule.meta.id, Object.freeze(resultModule)); const lookupTable = createLookupTable(options);
sEmitter.emit('module.register', resultPayload('success', resultModule)); module.locals["@sern/lookup-table"] = lookupTable;
} }
// FREEZE! no more writing!!
commands.set(resultModule.meta.id, Object.freeze(resultModule));
sEmitter.emit("module.register", resultPayload("success", resultModule));
} }
sEmitter.emit('modulesLoaded'); }
sEmitter.emit("modulesLoaded");
} }