mirror of
https://github.com/sern-handler/handler
synced 2026-06-23 00:02:14 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9d5c6c714f | ||
|
|
4f2387119a | ||
|
|
a6fa4e3dcb |
@@ -1,5 +1,12 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [3.3.2](https://github.com/sern-handler/handler/compare/v3.3.1...v3.3.2) (2024-01-08)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* presence feature not working on cjs applications ([#351](https://github.com/sern-handler/handler/issues/351)) ([4f23871](https://github.com/sern-handler/handler/commit/4f2387119acfde036d0d1626553e9050f55627d1))
|
||||||
|
|
||||||
## [3.3.1](https://github.com/sern-handler/handler/compare/v3.3.0...v3.3.1) (2024-01-07)
|
## [3.3.1](https://github.com/sern-handler/handler/compare/v3.3.0...v3.3.1) (2024-01-07)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@sern/handler",
|
"name": "@sern/handler",
|
||||||
"packageManager": "yarn@3.5.0",
|
"packageManager": "yarn@3.5.0",
|
||||||
"version": "3.3.1",
|
"version": "3.3.2",
|
||||||
"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.mjs",
|
"module": "./dist/index.mjs",
|
||||||
|
|||||||
@@ -1,20 +1,19 @@
|
|||||||
import { Result } from 'ts-results-es';
|
import { Result } from 'ts-results-es';
|
||||||
import { type Observable, from, mergeMap, ObservableInput } from 'rxjs';
|
import { type Observable, from, mergeMap, ObservableInput } from 'rxjs';
|
||||||
import { readdir, stat } from 'fs/promises';
|
import { readdir, stat } from 'fs/promises';
|
||||||
import { basename, extname, join, resolve, parse } from 'path';
|
import { basename, extname, join, resolve, parse, dirname } from 'path';
|
||||||
import assert from 'assert';
|
import assert from 'assert';
|
||||||
import { createRequire } from 'node:module';
|
import { createRequire } from 'node:module';
|
||||||
import type { ImportPayload, Wrapper } from '../types/core';
|
import type { ImportPayload, Wrapper } from '../types/core';
|
||||||
import type { Module } from '../types/core-modules';
|
import type { Module } from '../types/core-modules';
|
||||||
import { existsSync } from 'fs';
|
import { existsSync } from 'fs';
|
||||||
import { fileURLToPath } from 'node:url';
|
|
||||||
|
|
||||||
export const shouldHandle = (path: string, fpath: string) => {
|
export const shouldHandle = (path: string, fpath: string) => {
|
||||||
const newPath = new URL(fpath+extname(path), path).href;
|
const file_name = fpath+extname(path);
|
||||||
return {
|
let newPath = join(dirname(path), file_name)
|
||||||
exists: existsSync(fileURLToPath(newPath)),
|
.replace(/file:\\?/, "");
|
||||||
path: newPath
|
return { exists: existsSync(newPath),
|
||||||
}
|
path: 'file:///'+newPath };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -79,11 +78,9 @@ const isSkippable = (filename: string) => {
|
|||||||
|
|
||||||
async function deriveFileInfo(dir: string, file: string) {
|
async function deriveFileInfo(dir: string, file: string) {
|
||||||
const fullPath = join(dir, file);
|
const fullPath = join(dir, file);
|
||||||
return {
|
return { fullPath,
|
||||||
fullPath,
|
fileStats: await stat(fullPath),
|
||||||
fileStats: await stat(fullPath),
|
base: basename(file) };
|
||||||
base: basename(file),
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function* readPaths(dir: string): AsyncGenerator<string> {
|
async function* readPaths(dir: string): AsyncGenerator<string> {
|
||||||
@@ -131,10 +128,8 @@ export function loadConfig(wrapper: Wrapper | 'file'): Wrapper {
|
|||||||
console.log('Events path is set to', eventsPath);
|
console.log('Events path is set to', eventsPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return { defaultPrefix: config.defaultPrefix,
|
||||||
defaultPrefix: config.defaultPrefix,
|
commands: commandsPath,
|
||||||
commands: commandsPath,
|
events: eventsPath };
|
||||||
events: eventsPath,
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ export type Config <T extends (keyof Dependencies)[]> =
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* A small wrapper to provide type inference.
|
* A small wrapper to provide type inference.
|
||||||
* Create a Presence module which **MUST** be put in a file called presence.<language-extension>
|
* Create a Presence module which **MUST** be put in a file called presence.(language-extension)
|
||||||
* adjacent to the file where **Sern.init** is CALLED.
|
* adjacent to the file where **Sern.init** is CALLED.
|
||||||
*/
|
*/
|
||||||
export function module<T extends (keyof Dependencies)[]>
|
export function module<T extends (keyof Dependencies)[]>
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export function init(maybeWrapper: Wrapper | 'file') {
|
|||||||
if (wrapper.events !== undefined) {
|
if (wrapper.events !== undefined) {
|
||||||
eventsHandler(dependencies, Files.getFullPathTree(wrapper.events));
|
eventsHandler(dependencies, Files.getFullPathTree(wrapper.events));
|
||||||
}
|
}
|
||||||
|
|
||||||
const initCallsite = callsites()[1].getFileName();
|
const initCallsite = callsites()[1].getFileName();
|
||||||
const presencePath = Files.shouldHandle(initCallsite!, "presence");
|
const presencePath = Files.shouldHandle(initCallsite!, "presence");
|
||||||
//Ready event: load all modules and when finished, time should be taken and logged
|
//Ready event: load all modules and when finished, time should be taken and logged
|
||||||
|
|||||||
Reference in New Issue
Block a user