mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb6e8c2cfc | ||
|
|
0eecb08e87 | ||
|
|
c67748c7df | ||
|
|
efee0fdbe2 | ||
|
|
797442ece3 | ||
|
|
513ac8edf4 | ||
|
|
81a0180d05 | ||
|
|
89d7409536 |
21
CHANGELOG.md
21
CHANGELOG.md
@@ -1,5 +1,26 @@
|
||||
# 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)
|
||||
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* flat autocomplete ([#395](https://github.com/sern-handler/handler/issues/395)) ([89d7409](https://github.com/sern-handler/handler/commit/89d74095363befddc3222b9e5c89c35e7c6457b9))
|
||||
|
||||
## [4.2.3](https://github.com/sern-handler/handler/compare/v4.2.2...v4.2.3) (2025-03-04)
|
||||
|
||||
|
||||
|
||||
1193
package-lock.json
generated
1193
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@sern/handler",
|
||||
"packageManager": "yarn@3.5.0",
|
||||
"version": "4.2.3",
|
||||
"version": "4.2.6",
|
||||
"description": "A complete, customizable, typesafe, & reactive framework for discord bots.",
|
||||
"main": "./dist/index.js",
|
||||
"module": "./dist/index.js",
|
||||
@@ -47,7 +47,7 @@
|
||||
"@types/node-cron": "^3.0.11",
|
||||
"@typescript-eslint/eslint-plugin": "5.58.0",
|
||||
"@typescript-eslint/parser": "5.59.1",
|
||||
"discord.js": "^14.14.1",
|
||||
"discord.js": "^14.22.1",
|
||||
"eslint": "8.39.0",
|
||||
"typescript": "5.0.2",
|
||||
"vitest": "^1.6.0"
|
||||
|
||||
@@ -33,8 +33,8 @@ export function interactionHandler(deps: UnpackedDependencies, defaultPrefix?: s
|
||||
// handles autocomplete
|
||||
if(isAutocomplete(event)) {
|
||||
const lookupTable = module.locals['@sern/lookup-table'] as Map<string, SernAutocompleteData>
|
||||
const subCommandGroup = event.options.getSubcommandGroup() ?? "",
|
||||
subCommand = event.options.getSubcommand() ?? "",
|
||||
const subCommandGroup = event.options.getSubcommandGroup(false) ?? "",
|
||||
subCommand = event.options.getSubcommand(false) ?? "",
|
||||
option = event.options.getFocused(true),
|
||||
fullPath = path.posix.join("<parent>", subCommandGroup, subCommand, option.name)
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ export function messageHandler (deps: UnpackedDependencies, defaultPrefix?: stri
|
||||
const [prefix] = fmt(message.content, defaultPrefix);
|
||||
let module = mg.get(`${prefix}_T`) ?? mg.get(`${prefix}_B`) as 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 result = await callPlugins(payload)
|
||||
|
||||
@@ -1,19 +1,25 @@
|
||||
import * as Files from '../core/module-loading'
|
||||
import { once } from 'node:events';
|
||||
import { createLookupTable, resultPayload } from '../core/functions';
|
||||
import { CommandType } from '../core/structures/enums';
|
||||
import { Module, SernOptionsData } from '../types/core-modules';
|
||||
import type { UnpackedDependencies, Wrapper } from '../types/utility';
|
||||
import { callInitPlugins } from './event-utils';
|
||||
import { SernAutocompleteData } from '..';
|
||||
import * as Files from "../core/module-loading";
|
||||
import { once } from "node:events";
|
||||
import { createLookupTable, resultPayload } from "../core/functions";
|
||||
import { CommandType } from "../core/structures/enums";
|
||||
import { Module, SernOptionsData } from "../types/core-modules";
|
||||
import type { UnpackedDependencies, Wrapper } from "../types/utility";
|
||||
import { callInitPlugins } from "./event-utils";
|
||||
import { SernAutocompleteData } from "..";
|
||||
import { Events } from "discord.js";
|
||||
|
||||
export default async function(dirs: string | string[], deps : UnpackedDependencies) {
|
||||
const { '@sern/client': client,
|
||||
'@sern/logger': log,
|
||||
'@sern/emitter': sEmitter,
|
||||
'@sern/modules': commands } = deps;
|
||||
log?.info({ message: "Waiting on discord client to be ready..." })
|
||||
await once(client, "ready");
|
||||
export default async function (
|
||||
dirs: string | string[],
|
||||
deps: UnpackedDependencies,
|
||||
) {
|
||||
const {
|
||||
"@sern/client": client,
|
||||
"@sern/logger": log,
|
||||
"@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
|
||||
@@ -23,22 +29,30 @@ export default async function(dirs: string | string[], deps : UnpackedDependenci
|
||||
|
||||
for (const dir of directories) {
|
||||
for await (const path of Files.readRecursive(dir)) {
|
||||
let { module } = await Files.importModule<Module>(path);
|
||||
const validType = module.type >= CommandType.Text && module.type <= CommandType.ChannelSelect;
|
||||
if(!validType) {
|
||||
throw Error(`Found ${module.name} at ${module.meta.absPath}, which has incorrect \`type\``);
|
||||
const { module } = await Files.importModule<Module>(path);
|
||||
const validType =
|
||||
module.type >= CommandType.Text &&
|
||||
module.type <= CommandType.ChannelSelect;
|
||||
if (!validType) {
|
||||
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) {
|
||||
const options = (Reflect.get(module, 'options') ?? []) as SernOptionsData[];
|
||||
const lookupTable = createLookupTable(options)
|
||||
module.locals['@sern/lookup-table'] = lookupTable;
|
||||
if (
|
||||
module.type === CommandType.Both ||
|
||||
module.type === CommandType.Slash
|
||||
) {
|
||||
const options = (Reflect.get(module, "options") ??
|
||||
[]) as SernOptionsData[];
|
||||
const lookupTable = createLookupTable(options);
|
||||
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("module.register", resultPayload("success", resultModule));
|
||||
}
|
||||
}
|
||||
sEmitter.emit('modulesLoaded');
|
||||
sEmitter.emit("modulesLoaded");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user