mirror of
https://github.com/sern-handler/handler
synced 2026-06-22 07:42:14 +00:00
fix: accidentally imported wildcard from wrong place & namespace
resolution
This commit is contained in:
416
package-lock.json
generated
416
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -1,16 +1,12 @@
|
||||
|
||||
import { ApplicationCommandType, ChatInputCommandInteraction, Interaction } from 'discord.js';
|
||||
import { fromEvent, Observable, of, concatMap, map, filter, throwError } from 'rxjs';
|
||||
import { CommandType } from '../sern';
|
||||
import Context from '../structures/context';
|
||||
import type { ModuleDefs } from '../structures/modules/commands/moduleHandler';
|
||||
import type { PluggedModule } from '../structures/modules/module';
|
||||
import type { ApplicationCommandType, ChatInputCommandInteraction, CommandInteraction, Interaction } from 'discord.js';
|
||||
import { fromEvent, Observable, of, concatMap, map, throwError } from 'rxjs';
|
||||
import type Wrapper from '../structures/wrapper';
|
||||
import * as Files from '../utilities/readFile';
|
||||
import { match } from 'ts-pattern';
|
||||
import { isEventPlugin } from './readyEvent';
|
||||
import { _ } from 'ts-pattern/dist/patterns';
|
||||
import { P, match } from 'ts-pattern';
|
||||
import { SernError } from '../structures/errors';
|
||||
import { correctModuleType } from './observableHandling';
|
||||
|
||||
|
||||
|
||||
@@ -18,34 +14,33 @@ export const onInteractionCreate = ( wrapper : Wrapper ) => {
|
||||
const { client } = wrapper;
|
||||
|
||||
const interactionEvent$ = (<Observable<Interaction>> fromEvent(client, 'interactionCreate'))
|
||||
|
||||
|
||||
interactionEvent$.pipe(
|
||||
concatMap( interaction => {
|
||||
if(interaction.isCommand()) {
|
||||
return of( Files
|
||||
.ApplicationCommandStore[interaction.commandType]
|
||||
.get(interaction.commandName)
|
||||
).pipe(
|
||||
const modul =
|
||||
Files.ApplicationCommandStore[interaction.commandType].get(interaction.commandName)
|
||||
?? Files.BothCommand.get(interaction.commandName);
|
||||
return of(modul).pipe(
|
||||
map ( plug => {
|
||||
console.log('a');
|
||||
if(plug === undefined) {
|
||||
return throwError(() => SernError.UndefinedModule)
|
||||
}
|
||||
const eventPlugins = plug.plugins.filter(isEventPlugin);
|
||||
match(interaction)
|
||||
.when( interaction.isChatInputCommand, (i : ChatInputCommandInteraction) => {
|
||||
console.log(i, eventPlugins)
|
||||
.when(i => i.isChatInputCommand(), (i : ChatInputCommandInteraction) => {
|
||||
console.log("chatI", eventPlugins)
|
||||
})
|
||||
.when( () => _ , i => {
|
||||
console.log(i, eventPlugins)
|
||||
.when(() => P._, i => {
|
||||
console.log("other I", eventPlugins)
|
||||
})
|
||||
return "fsd"
|
||||
})
|
||||
)
|
||||
}
|
||||
return of()
|
||||
})
|
||||
).subscribe();
|
||||
).subscribe(console.log);
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@ import Context from '../structures/context';
|
||||
import type Wrapper from '../structures/wrapper';
|
||||
import { fmt } from '../utilities/messageHelpers';
|
||||
import * as Files from '../utilities/readFile';
|
||||
import { filterCorrectModule, ignoreNonBot, match } from './observableHandling';
|
||||
import { filterCorrectModule, ignoreNonBot, correctModuleType } from './observableHandling';
|
||||
import { isEventPlugin } from './readyEvent';
|
||||
|
||||
export const onMessageCreate = (wrapper : Wrapper) => {
|
||||
|
||||
@@ -7,7 +7,7 @@ import type { PluggedModule } from '../structures/modules/module';
|
||||
import type { EventPlugin, SernPlugin } from '../plugins/plugin';
|
||||
|
||||
|
||||
export function match<T extends keyof ModuleDefs>(
|
||||
export function correctModuleType<T extends keyof ModuleDefs>(
|
||||
plug: PluggedModule | undefined, type : T
|
||||
) : plug is { mod: ModuleDefs[T], plugins : SernPlugin[] } {
|
||||
return plug !== undefined && plug.mod.type === type;
|
||||
@@ -18,7 +18,7 @@ export function filterCorrectModule<T extends keyof ModuleDefs>(cmdType : T) {
|
||||
new Observable<{ mod : ModuleDefs[T], plugins : SernPlugin[] }>( subscriber => {
|
||||
return src.subscribe({
|
||||
next(plug) {
|
||||
if(match(plug, cmdType)) {
|
||||
if(correctModuleType(plug, cmdType)) {
|
||||
subscriber.next({ mod : plug.mod, plugins : plug.plugins });
|
||||
} else {
|
||||
if (plug === undefined) {
|
||||
|
||||
@@ -5,7 +5,7 @@ import type Wrapper from '../structures/wrapper';
|
||||
import type { HandlerCallback, ModuleHandlers, ModuleStates, ModuleType} from '../structures/modules/commands/moduleHandler';
|
||||
import { CommandType } from '../sern';
|
||||
import { CommandPlugin, EventPlugin, PluginType, SernPlugin } from '../plugins/plugin';
|
||||
import { match, partition } from './observableHandling';
|
||||
import { correctModuleType, partition } from './observableHandling';
|
||||
import { Err, Ok, Result } from 'ts-results';
|
||||
import type { PluggedModule } from '../structures/modules/module';
|
||||
import type { Awaitable } from 'discord.js';
|
||||
@@ -74,7 +74,7 @@ function handler( name : string ) : ModuleHandlers {
|
||||
return {
|
||||
[CommandType.Text] : (mod, plugins) => {
|
||||
mod.alias.forEach ( a => Files.TextCommandStore.aliases.set(a,{ mod, plugins}));
|
||||
Files.ApplicationCommandStore[1].set( name, { mod, plugins } );
|
||||
Files.TextCommandStore.text.set( name, { mod, plugins } );
|
||||
},
|
||||
[CommandType.Slash]: (mod, plugins) => {
|
||||
Files.ApplicationCommandStore[1].set( name , { mod, plugins });
|
||||
|
||||
@@ -14,7 +14,8 @@ import { onReady } from './events/readyEvent';
|
||||
import { onMessageCreate } from './events/messageEvent';
|
||||
import { onInteractionCreate } from './events/interactionCreate';
|
||||
import { match } from 'ts-pattern';
|
||||
import { _ } from 'ts-pattern/dist/patterns';
|
||||
import { P } from 'ts-pattern';
|
||||
import { Sern } from '..';
|
||||
|
||||
export function init( wrapper : Wrapper ) {
|
||||
const { events, client } = wrapper;
|
||||
@@ -50,7 +51,8 @@ export function cmdTypeToDjs(ty: CommandType) {
|
||||
.with(CommandType.Slash, () => ApplicationCommandType.ChatInput)
|
||||
.with(CommandType.MenuUser, () => ApplicationCommandType.User)
|
||||
.with(CommandType.MenuMsg, ()=> ApplicationCommandType.Message)
|
||||
.with(_, () => { throw new Error(SernError.NonValidModuleType) })
|
||||
.with(CommandType.Both, () => ApplicationCommandType.ChatInput )
|
||||
.with(P._, () => { throw new Error(SernError.NonValidModuleType) })
|
||||
.exhaustive()
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user