mirror of
https://github.com/sern-handler/handler
synced 2026-06-14 20:02:16 +00:00
remove barrel for core/structs
This commit is contained in:
@@ -13,9 +13,14 @@ import {
|
||||
type _Module,
|
||||
} from './core/_internal';
|
||||
import { createInteractionHandler, executeModule, makeModuleExecutor } from './handlers/event-utils';
|
||||
import type { Emitter } from './core/interfaces'
|
||||
import type { Emitter, ErrorHandling, Logging } from './core/interfaces'
|
||||
import { Services } from './core/ioc/dependency-injection';
|
||||
|
||||
export function interactionHandler(client: Emitter, emitter: Emitter, modules: Map<string, _Module>) {
|
||||
export function interactionHandler(client: Emitter,
|
||||
emitter: Emitter,
|
||||
log: Logging,
|
||||
err: ErrorHandling,
|
||||
modules: Map<string, _Module>) {
|
||||
const interactionStream$ = sharedEventStream<Interaction>(client, 'interactionCreate');
|
||||
const handle = createInteractionHandler(interactionStream$, modules);
|
||||
|
||||
@@ -29,3 +34,9 @@ export function interactionHandler(client: Emitter, emitter: Emitter, modules: M
|
||||
emitter.emit('module.activate', resultPayload(PayloadType.Failure, module, SernError.PluginFailure)))),
|
||||
mergeMap(payload => executeModule(emitter, log, err, payload)));
|
||||
}
|
||||
|
||||
export const __dependencies = () =>
|
||||
Services('@sern/emitter',
|
||||
'@sern/errors',
|
||||
'@sern/logger',
|
||||
'@sern/client');
|
||||
|
||||
@@ -5,7 +5,6 @@ export * from './operators';
|
||||
export * as Files from './module-loading';
|
||||
export * from './functions';
|
||||
export { SernError } from './structures/enums';
|
||||
export { __Services } from './structures';
|
||||
export { useContainerRaw } from './ioc/base';
|
||||
|
||||
export type _Module = {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { CommandType, EventType, PluginType } from './structures';
|
||||
import { CommandType, EventType, PluginType } from './structures/enums';
|
||||
import type { Plugin, PluginResult, EventArgs, CommandArgs } from '../types/core-plugin';
|
||||
import type { ClientEvents } from 'discord.js';
|
||||
import { err, ok } from './functions';
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
AutocompleteInteraction
|
||||
} from 'discord.js';
|
||||
import { ApplicationCommandOptionType, InteractionType } from 'discord.js';
|
||||
import { PayloadType, PluginType } from './structures';
|
||||
import { PayloadType, PluginType } from './structures/enums';
|
||||
import assert from 'assert';
|
||||
import type { Payload } from '../types/utility';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ApplicationCommandType, ComponentType, Interaction, InteractionType } from 'discord.js';
|
||||
import { CommandType, EventType } from './structures';
|
||||
import { CommandType, EventType } from './structures/enums';
|
||||
|
||||
/**
|
||||
* Construct unique ID for a given interaction object.
|
||||
|
||||
@@ -2,7 +2,7 @@ import * as assert from 'assert';
|
||||
import type { CoreDependencies, DependencyConfiguration } from '../../types/ioc';
|
||||
import { CoreContainer } from './container';
|
||||
import { Result } from 'ts-results-es';
|
||||
import { __Services } from '../_internal';
|
||||
import * as __Services from '../structures/default-services';
|
||||
import { AnyFunction } from '../../types/utility';
|
||||
import type { Logging } from '../interfaces';
|
||||
import type { UnpackFunction } from 'iti';
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Container } from 'iti';
|
||||
import type { Disposable } from '../interfaces';
|
||||
import * as assert from 'node:assert';
|
||||
import { Subject } from 'rxjs';
|
||||
import { __Services } from '../_internal';
|
||||
import * as __Services from '../structures/default-services';
|
||||
import * as Hooks from './hooks';
|
||||
import { EventEmitter } from 'node:events';
|
||||
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import { ClientEvents } from 'discord.js';
|
||||
import { EventType } from '../core/structures';
|
||||
import type { ClientEvents } from 'discord.js';
|
||||
import { EventType } from '../core/structures/enums';
|
||||
import type { AnyEventPlugin, } from '../types/core-plugin';
|
||||
import type {
|
||||
InputCommand,
|
||||
InputEvent,
|
||||
} from '../types/core-modules';
|
||||
import { _Module, partitionPlugins } from './_internal';
|
||||
import { type _Module, partitionPlugins } from './_internal';
|
||||
import type { Awaitable } from '../types/utility';
|
||||
import callsites from 'callsites';
|
||||
import * as Files from './module-loading'
|
||||
import * as Id from './id'
|
||||
|
||||
/**
|
||||
* @since 1.0.0 The wrapper function to define command modules for sern
|
||||
* @param mod
|
||||
@@ -40,7 +41,6 @@ export function commandModule(mod: InputCommand): _Module {
|
||||
export function eventModule(mod: InputEvent): _Module {
|
||||
const [onEvent, plugins] = partitionPlugins(mod.plugins);
|
||||
const initCallsite = callsites()[1].getFileName();
|
||||
console.log(initCallsite);
|
||||
if(!initCallsite) throw Error("initCallsite is null");
|
||||
const { name, absPath } = Files.parseCallsite(initCallsite);
|
||||
mod.name ??= name;
|
||||
|
||||
@@ -26,7 +26,7 @@ import type { VoidResult } from './_internal';
|
||||
* @param item
|
||||
*/
|
||||
export function filterMapTo<V>(item: () => V): OperatorFunction<boolean, V> {
|
||||
return concatMap(shouldKeep => (shouldKeep ? of(item()) : EMPTY));
|
||||
return concatMap(keep => keep ? of(item()) : EMPTY);
|
||||
}
|
||||
|
||||
interface PluginExecutable {
|
||||
|
||||
@@ -46,8 +46,7 @@ export const Presence = {
|
||||
},
|
||||
/**
|
||||
* @example
|
||||
* Presence
|
||||
* .of({
|
||||
* Presence.of({
|
||||
* activities: [
|
||||
* { name: "Chilling out" }
|
||||
* ]
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
export { CommandType, PluginType, PayloadType, EventType } from './enums';
|
||||
export * from './context';
|
||||
export * as __Services from './default-services';
|
||||
|
||||
@@ -35,7 +35,8 @@ import type { ControlPlugin } from '../types/core-plugin';
|
||||
import type { AnyModule, CommandMeta, CommandModule, Module, Processed } from '../types/core-modules';
|
||||
import { EventEmitter } from 'node:events';
|
||||
import * as assert from 'node:assert';
|
||||
import { CommandType, Context } from '../core/structures';
|
||||
import { Context } from '../core/structures/context';
|
||||
import { CommandType } from '../core/structures/enums'
|
||||
import type { Args } from '../types/utility';
|
||||
import { inspect } from 'node:util'
|
||||
import { disposeAll } from '../core/ioc/base';
|
||||
|
||||
@@ -15,8 +15,7 @@ function isNonBot(prefix: string) {
|
||||
|
||||
function hasPrefix(prefix: string, content: string) {
|
||||
const prefixInContent = content.slice(0, prefix.length);
|
||||
return (
|
||||
prefixInContent.localeCompare(prefix, undefined, {
|
||||
return (prefixInContent.localeCompare(prefix, undefined, {
|
||||
sensitivity: 'accent',
|
||||
}) === 0
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ObservableInput } from 'rxjs';
|
||||
import { EventType } from '../core/structures';
|
||||
import { EventType } from '../core/structures/enums';
|
||||
import { SernError } from '../core/_internal';
|
||||
import { eventDispatcher } from './event-utils'
|
||||
import { Service } from '../core/ioc';
|
||||
|
||||
@@ -53,5 +53,6 @@ export {
|
||||
export * from './core/presences'
|
||||
export * from './core/interfaces'
|
||||
export * from './core/create-plugins';
|
||||
export * from './core/structures';
|
||||
export { CommandType, PluginType, PayloadType, EventType } from './core/structures/enums';
|
||||
export { Context } from './core/structures/context';
|
||||
export * from './core/ioc';
|
||||
|
||||
@@ -15,7 +15,8 @@ import type {
|
||||
UserContextMenuCommandInteraction,
|
||||
UserSelectMenuInteraction,
|
||||
} from 'discord.js';
|
||||
import type { CommandType, Context, EventType } from '../core/structures';
|
||||
import type { CommandType, EventType } from '../core/structures/enums';
|
||||
import { Context } from '../core/structures/context'
|
||||
import { AnyCommandPlugin, AnyEventPlugin, ControlPlugin, InitPlugin } from './core-plugin';
|
||||
import { Awaitable, Args, SlashOptions, SernEventsMapping } from './utility';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user