Compare commits

...

16 Commits
v4.2.2 ... 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
github-actions[bot]
81a0180d05 chore(main): release 4.2.4 (#396)
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-03-05 21:24:41 -06:00
Jacob Nguyen
89d7409536 fix: flat autocomplete (#395)
* first

* fix
2025-03-05 21:22:54 -06:00
github-actions[bot]
aa802f761e chore(main): release 4.2.3 (#394)
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-03-03 21:48:03 -06:00
Jacob Nguyen
2414992b73 fix: autocomplete sdt.module not present (#393) 2025-03-03 21:45:18 -06:00
kingomes
70c6236802 Update README.md (#392)
Some checks failed
NPM / Publish / test-and-publish (push) Has been cancelled
2025-02-15 11:09:34 -06:00
Jacob Nguyen
1f25aa64b9 plock
Some checks failed
Continuous Delivery / Publishing Dev (push) Has been cancelled
NPM / Publish / test-and-publish (push) Has been cancelled
2025-02-07 01:45:57 -06:00
Jacob Nguyen
7cddee30aa lock 2025-02-07 01:44:49 -06:00
renovate[bot]
e7286eee9f chore(deps): lock file maintenance (#331)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
2025-02-07 01:43:27 -06:00
Jacob Nguyen
a67450328e fuckyarn 2025-02-07 00:50:17 -06:00
Jacob Nguyen
47401f46a3 Update README.md
Some checks failed
NPM / Publish / test-and-publish (push) Has been cancelled
2025-02-03 11:47:49 -06:00
12 changed files with 3998 additions and 4228 deletions

View File

@@ -13,9 +13,9 @@ jobs:
- uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3
- uses: actions/setup-node@1a4442cacd436585916779262731d5b162bc6ec7 # v3
with:
node-version: 17
- run: yarn --immutable
- run: yarn build:prod
node-version: 18
- run: npm i
- run: npm run build:prod
- uses: JS-DevTools/npm-publish@0f451a94170d1699fd50710966d48fb26194d939 # v1
with:
token: ${{ secrets.NPM_TOKEN }}

View File

@@ -24,6 +24,5 @@ jobs:
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install -g yarn
- run: yarn install
- run: yarn test
- run: npm install
- run: npm run test

File diff suppressed because one or more lines are too long

View File

@@ -1,5 +0,0 @@
enableGlobalCache: true
nodeLinker: node-modules
yarnPath: .yarn/releases/yarn-3.5.1.cjs

View File

@@ -1,5 +1,33 @@
# 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)
### Bug Fixes
* autocomplete sdt.module not present ([#393](https://github.com/sern-handler/handler/issues/393)) ([2414992](https://github.com/sern-handler/handler/commit/2414992b73a40065464b20f2d53826c78fcd3a5f))
## [4.2.2](https://github.com/sern-handler/handler/compare/v4.2.1...v4.2.2) (2025-02-03)

View File

@@ -7,6 +7,7 @@
<div align="center" styles="margin-top: 10px">
<img src="https://img.shields.io/badge/open-source-brightgreen" />
<img src="https://img.shields.io/badge/built_with-sern-pink?labelColor=%230C3478&color=%23ed5087&link=https%3A%2F%2Fsern.dev"/>
<a href="https://www.npmjs.com/package/@sern/handler"><img src="https://img.shields.io/npm/v/@sern/handler?maxAge=3600" alt="NPM version" /></a>
<a href="https://www.npmjs.com/package/@sern/handler"><img src="https://img.shields.io/npm/dt/@sern/handler?maxAge=3600" alt="NPM downloads" /></a>
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/license-MIT-brightgreen" alt="License MIT" /></a>
@@ -43,6 +44,11 @@ export default commandModule({
```
</details>
# Show off your sern Discord Bot!
## Badge
- Copy this and add it to your [README.md](https://img.shields.io/badge/built_with-sern-pink?labelColor=%230C3478&color=%23ed5087&link=https%3A%2F%2Fsern.dev)
<img src="https://img.shields.io/badge/built_with-sern-pink?labelColor=%230C3478&color=%23ed5087&link=https%3A%2F%2Fsern.dev">
## 🤖 Bots Using sern
- [Community Bot](https://github.com/sern-handler/sern-community) - The community bot for our [Discord server](https://sern.dev/discord).
@@ -53,10 +59,14 @@ export default commandModule({
- [SmokinWeed 💨](https://github.com/Peter-MJ-Parker/sern-bud) - A fun bot for a small, but growing server.
- [Man Nomic](https://github.com/jacoobes/man-nomic) - A simple information bot to provide information to the nomic-ai Discord community.
- [Linear-Discord](https://github.com/sern-handler/linear-discord) - Display and manage a linear dashboard.
- [ZenithBot](https://github.com/CodeCraftersHaven/ZenithBot) - A versatile bot coded in TypeScript, designed to enhance server management and user interaction through its robust features.
## 💻 CLI
It is **highly encouraged** to use the [command line interface](https://github.com/sern-handler/cli) for your project. Don't forget to view it.
## 🔗 Links
- [Official Documentation and Guide](https://sern.dev)

3897
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,7 +1,7 @@
{
"name": "@sern/handler",
"packageManager": "yarn@3.5.0",
"version": "4.2.2",
"version": "4.2.6",
"description": "A complete, customizable, typesafe, & reactive framework for discord bots.",
"main": "./dist/index.js",
"module": "./dist/index.js",
@@ -36,7 +36,7 @@
"author": "SernDevs",
"license": "MIT",
"dependencies": {
"@sern/ioc": "^1.1.0",
"@sern/ioc": "^1.1.2",
"callsites": "^3.1.0",
"cron": "^3.1.7",
"deepmerge": "^4.3.1"
@@ -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.15.3",
"discord.js": "^14.22.1",
"eslint": "8.39.0",
"typescript": "5.0.2",
"vitest": "^1.6.0"

View File

@@ -33,14 +33,14 @@ 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)
const resolvedModule = (lookupTable.get(fullPath)!.command) as Module
payload= { module: resolvedModule , //autocomplete is not a true "module" warning cast!
args: [event, createSDT(resolvedModule, deps, params)] };
args: [event, createSDT(module, deps, params)] };
// either CommandTypes Slash | ContextMessage | ContextUesr
} else if(isCommand(event)) {
const sdt = createSDT(module, deps, params)

View File

@@ -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)

View File

@@ -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");
}

3300
yarn.lock

File diff suppressed because it is too large Load Diff