mirror of
https://github.com/sern-handler/handler
synced 2026-06-13 11:22:15 +00:00
refactor: Cleaning up more, moving things for organization
This commit is contained in:
@@ -13,10 +13,9 @@ import { SernError } from '../structures/errors';
|
||||
import Context from '../structures/context';
|
||||
import type { Result } from 'ts-results';
|
||||
import { CommandType, controller } from '../sern';
|
||||
import type { Args } from '../../types/handler';
|
||||
import type { Args, UnionToTuple } from '../../types/handler';
|
||||
import type { MessageComponentInteraction } from 'discord.js';
|
||||
import { ComponentType } from 'discord.js';
|
||||
import type { UnionToTuple } from '../utilities/resolveParameters';
|
||||
import type { Module } from '../structures/module';
|
||||
import type { EventPlugin } from '../plugins/plugin';
|
||||
|
||||
|
||||
@@ -3,13 +3,7 @@ import { Observable, throwError } from 'rxjs';
|
||||
import { SernError } from '../structures/errors';
|
||||
import { isNotFromBot } from '../utilities/messageHelpers';
|
||||
import type { Module, ModuleDefs } from '../structures/module';
|
||||
|
||||
export function correctModuleType<T extends keyof ModuleDefs>(
|
||||
plug: Module | undefined,
|
||||
type: T,
|
||||
): plug is ModuleDefs[T] {
|
||||
return plug !== undefined && plug.type === type;
|
||||
}
|
||||
import { correctModuleType } from '../utilities/predicates';
|
||||
|
||||
export function filterCorrectModule<T extends keyof ModuleDefs>(cmdType: T) {
|
||||
return (src: Observable<Module | undefined>) =>
|
||||
@@ -33,7 +27,7 @@ export function filterCorrectModule<T extends keyof ModuleDefs>(cmdType: T) {
|
||||
|
||||
export function ignoreNonBot(prefix: string) {
|
||||
return (src: Observable<Message>) =>
|
||||
new Observable(subscriber => {
|
||||
new Observable<Message>(subscriber => {
|
||||
return src.subscribe({
|
||||
next(m) {
|
||||
const passAll = [
|
||||
|
||||
8
src/handler/utilities/predicates.ts
Normal file
8
src/handler/utilities/predicates.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Module, ModuleDefs } from '../structures/module';
|
||||
|
||||
export function correctModuleType<T extends keyof ModuleDefs>(
|
||||
plug: Module | undefined,
|
||||
type: T,
|
||||
): plug is ModuleDefs[T] {
|
||||
return plug !== undefined && plug.type === type;
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
export type UnionToTuple<T> = T extends readonly [infer V, infer S]
|
||||
? V extends V
|
||||
? S extends S
|
||||
? [V, S]
|
||||
: [V]
|
||||
: never
|
||||
: never;
|
||||
@@ -22,3 +22,11 @@ export type SlashOptions = Omit<CommandInteractionOptionResolver, 'getMessage' |
|
||||
|
||||
//https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l
|
||||
export type Override<T1, T2> = Omit<T1, keyof T2> & T2;
|
||||
|
||||
export type UnionToTuple<T> = T extends readonly [infer V, infer S]
|
||||
? V extends V
|
||||
? S extends S
|
||||
? [V, S]
|
||||
: [V]
|
||||
: never
|
||||
: never;
|
||||
Reference in New Issue
Block a user