refactor: Cleaning up more, moving things for organization

This commit is contained in:
Jacob Nguyen
2022-05-15 19:31:30 -05:00
parent 269ab563ab
commit bcbfd28788
5 changed files with 19 additions and 17 deletions

View File

@@ -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';

View File

@@ -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 = [

View 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;
}

View File

@@ -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;

View File

@@ -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;