mirror of
https://github.com/sern-handler/handler
synced 2026-06-11 18:32:15 +00:00
Compare commits
4 Commits
feat/error
...
v3.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8ef4ee87e9 | ||
|
|
fd39858636 | ||
|
|
132b625070 | ||
|
|
03439fec43 |
2
.github/workflows/release-please.yml
vendored
2
.github/workflows/release-please.yml
vendored
@@ -6,7 +6,7 @@ jobs:
|
|||||||
release-please:
|
release-please:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: google-github-actions/release-please-action@ca6063f4ed81b55db15b8c42d1b6f7925866342d # v3
|
- uses: google-github-actions/release-please-action@4c5670f886fe259db4d11222f7dff41c1382304d # v3
|
||||||
with:
|
with:
|
||||||
release-type: node
|
release-type: node
|
||||||
package-name: release-please-action
|
package-name: release-please-action
|
||||||
|
|||||||
@@ -1,5 +1,13 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## [3.1.1](https://github.com/sern-handler/handler/compare/v3.1.0...v3.1.1) (2023-11-06)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* queuing events ([fd39858](https://github.com/sern-handler/handler/commit/fd39858636d3038abb6d91021b65c99c488a3d6e))
|
||||||
|
* queuing events ([#332](https://github.com/sern-handler/handler/issues/332)) @Benzo-Fury ([#333](https://github.com/sern-handler/handler/issues/333)) ([fd39858](https://github.com/sern-handler/handler/commit/fd39858636d3038abb6d91021b65c99c488a3d6e))
|
||||||
|
|
||||||
## [3.1.0](https://github.com/sern-handler/handler/compare/v3.0.2...v3.1.0) (2023-09-04)
|
## [3.1.0](https://github.com/sern-handler/handler/compare/v3.0.2...v3.1.0) (2023-09-04)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "@sern/handler",
|
"name": "@sern/handler",
|
||||||
"packageManager": "yarn@3.5.0",
|
"packageManager": "yarn@3.5.0",
|
||||||
"version": "3.1.0",
|
"version": "3.1.1",
|
||||||
"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",
|
||||||
|
|||||||
@@ -14,23 +14,6 @@ import { CommandType, Context } from '../core';
|
|||||||
import type { Args } from '../types/utility';
|
import type { Args } from '../types/utility';
|
||||||
import type { BothCommand, CommandModule, Module, Processed } from '../types/core-modules';
|
import type { BothCommand, CommandModule, Module, Processed } from '../types/core-modules';
|
||||||
|
|
||||||
function dispatchInteraction<T extends CommandModule, V extends BaseInteraction | Message>(
|
|
||||||
payload: { module: Processed<T>; event: V },
|
|
||||||
createArgs: (m: typeof payload.event) => unknown[],
|
|
||||||
) {
|
|
||||||
return {
|
|
||||||
module: payload.module,
|
|
||||||
args: createArgs(payload.event),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
//TODO: refactor dispatchers so that it implements a strategy for each different type of payload?
|
|
||||||
export function dispatchMessage(module: Processed<CommandModule>, args: [Context, Args]) {
|
|
||||||
return {
|
|
||||||
module,
|
|
||||||
args,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
function dispatchAutocomplete(payload: {
|
function dispatchAutocomplete(payload: {
|
||||||
module: Processed<BothCommand>;
|
module: Processed<BothCommand>;
|
||||||
event: AutocompleteInteraction;
|
event: AutocompleteInteraction;
|
||||||
@@ -52,9 +35,6 @@ export function contextArgs(wrappable: Message | BaseInteraction, messageArgs?:
|
|||||||
return [ctx, args] as [Context, Args];
|
return [ctx, args] as [Context, Args];
|
||||||
}
|
}
|
||||||
|
|
||||||
function interactionArg<T extends BaseInteraction>(interaction: T) {
|
|
||||||
return [interaction] as [T];
|
|
||||||
}
|
|
||||||
|
|
||||||
function intoPayload(module: Processed<Module>) {
|
function intoPayload(module: Processed<Module>) {
|
||||||
return pipe(
|
return pipe(
|
||||||
@@ -109,9 +89,14 @@ export function createDispatcher(payload: {
|
|||||||
*/
|
*/
|
||||||
return dispatchAutocomplete(payload as never);
|
return dispatchAutocomplete(payload as never);
|
||||||
}
|
}
|
||||||
return dispatchInteraction(payload, contextArgs);
|
return {
|
||||||
|
module: payload.module,
|
||||||
|
args: contextArgs(payload.event),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
default:
|
default: return {
|
||||||
return dispatchInteraction(payload, interactionArg);
|
module: payload.module,
|
||||||
|
args: [payload.event],
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
useContainerRaw,
|
useContainerRaw,
|
||||||
} from '../core/_internal';
|
} from '../core/_internal';
|
||||||
import { Emitter, ErrorHandling, Logging, ModuleManager } from '../core';
|
import { Emitter, ErrorHandling, Logging, ModuleManager } from '../core';
|
||||||
import { contextArgs, createDispatcher, dispatchMessage } from './dispatchers';
|
import { contextArgs, createDispatcher } from './dispatchers';
|
||||||
import { ObservableInput, pipe } from 'rxjs';
|
import { ObservableInput, pipe } from 'rxjs';
|
||||||
import { SernEmitter } from '../core';
|
import { SernEmitter } from '../core';
|
||||||
import { Err, Ok, Result } from 'ts-results-es';
|
import { Err, Ok, Result } from 'ts-results-es';
|
||||||
@@ -78,8 +78,7 @@ export function createInteractionHandler<T extends Interaction>(
|
|||||||
return Files
|
return Files
|
||||||
.defaultModuleLoader<Processed<CommandModule>>(fullPath)
|
.defaultModuleLoader<Processed<CommandModule>>(fullPath)
|
||||||
.then(payload =>
|
.then(payload =>
|
||||||
Ok(createDispatcher({ module: payload.module, event }))
|
Ok(createDispatcher({ module: payload.module, event })));
|
||||||
);
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -98,9 +97,9 @@ export function createMessageHandler(
|
|||||||
}
|
}
|
||||||
return Files
|
return Files
|
||||||
.defaultModuleLoader<Processed<CommandModule>>(fullPath)
|
.defaultModuleLoader<Processed<CommandModule>>(fullPath)
|
||||||
.then(payload => {
|
.then(({ module })=> {
|
||||||
const args = contextArgs(event, rest);
|
const args = contextArgs(event, rest);
|
||||||
return Ok(dispatchMessage(payload.module, args));
|
return Ok({ module, args });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -126,7 +125,9 @@ export function buildModules<T extends AnyModule>(
|
|||||||
input: ObservableInput<string>,
|
input: ObservableInput<string>,
|
||||||
moduleManager: ModuleManager,
|
moduleManager: ModuleManager,
|
||||||
) {
|
) {
|
||||||
return Files.buildModuleStream<Processed<T>>(input).pipe(assignDefaults(moduleManager));
|
return Files
|
||||||
|
.buildModuleStream<Processed<T>>(input)
|
||||||
|
.pipe(assignDefaults(moduleManager));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { Interaction } from 'discord.js';
|
import { Interaction } from 'discord.js';
|
||||||
import { concatMap, merge } from 'rxjs';
|
import { mergeMap, merge } from 'rxjs';
|
||||||
import { SernEmitter } from '../core';
|
import { SernEmitter } from '../core';
|
||||||
import {
|
import {
|
||||||
isAutocomplete,
|
isAutocomplete,
|
||||||
@@ -28,6 +28,6 @@ export function interactionHandler([emitter, , , modules, client]: DependencyLis
|
|||||||
filterTap(e => emitter.emit('warning', SernEmitter.warning(e))),
|
filterTap(e => emitter.emit('warning', SernEmitter.warning(e))),
|
||||||
makeModuleExecutor(module =>
|
makeModuleExecutor(module =>
|
||||||
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure))),
|
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure))),
|
||||||
concatMap(payload => executeModule(emitter, payload)),
|
mergeMap(payload => executeModule(emitter, payload)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { concatMap, EMPTY } from 'rxjs';
|
import { mergeMap, EMPTY } from 'rxjs';
|
||||||
import type { Message } from 'discord.js';
|
import type { Message } from 'discord.js';
|
||||||
import { SernEmitter } from '../core';
|
import { SernEmitter } from '../core';
|
||||||
import { sharedEventStream, SernError, filterTap } from '../core/_internal';
|
import { sharedEventStream, SernError, filterTap } from '../core/_internal';
|
||||||
@@ -42,6 +42,6 @@ export function messageHandler(
|
|||||||
makeModuleExecutor(module => {
|
makeModuleExecutor(module => {
|
||||||
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure));
|
emitter.emit('module.activate', SernEmitter.failure(module, SernError.PluginFailure));
|
||||||
}),
|
}),
|
||||||
concatMap(payload => executeModule(emitter, payload)),
|
mergeMap(payload => executeModule(emitter, payload)),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,14 +24,12 @@ export function eventsHandler(
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
buildModules<EventModule>(allPaths, moduleManager)
|
buildModules<EventModule>(allPaths, moduleManager)
|
||||||
.pipe(
|
.pipe(callInitPlugins(emitter),
|
||||||
callInitPlugins(emitter),
|
|
||||||
map(intoDispatcher),
|
map(intoDispatcher),
|
||||||
/**
|
/**
|
||||||
* Where all events are turned on
|
* Where all events are turned on
|
||||||
*/
|
*/
|
||||||
mergeAll(),
|
mergeAll(),
|
||||||
handleCrash(err, log),
|
handleCrash(err, log))
|
||||||
)
|
|
||||||
.subscribe();
|
.subscribe();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user