import type { CommandInteractionOptionResolver } from 'discord.js'; import type { CommandModule, EventModule, Module } from '../handler/structures/module'; import type { PayloadType } from '../handler/structures/enums'; export type Nullish = T | undefined | null; // Thanks to @kelsny export type ParseType = { [K in keyof T]: T[K] extends unknown ? [k: K, args: T[K]] : never; }[keyof T]; export type Args = ParseType<{ text: string[]; slash: SlashOptions }>; export type SlashOptions = Omit; // Source: https://dev.to/vborodulin/ts-how-to-override-properties-with-type-intersection-554l export type Override = Omit & T2; export type DefinitelyDefined = { [L in K]-?: T[L] extends Record ? DefinitelyDefined : Required[L]; } & T; export type EventInput = | string | { mod: EventModule; absPath: string }[] | (() => { mod: EventModule; absPath: string }[]); export type Reconstruct = T extends Omit ? O & Reconstruct : T; export type IsOptional = { [K in keyof T]-?: T[K] extends Required[K] ? false : true; }; /** * Turns a function with a union of array of args into a single union * [ T , V , B ] | [ A ] => T | V | B | A */ export type SpreadParams unknown> = ( args: Parameters[number], ) => unknown; /** * After modules are transformed, name and description are given default values if none * are provided to Module. This type represents that transformation */ export type DefinedModule = DefinitelyDefined; export type DefinedCommandModule = DefinitelyDefined; export type DefinedEventModule = DefinitelyDefined; export type Payload = | { type: PayloadType.Success; module: Module } | { type: PayloadType.Failure; module?: Module; reason: string | Error }; export type SernEventsMapping = { ['module.register']: [Payload]; ['module.activate']: [Payload]; ['error']: [Payload]; ['warning']: [string]; };