mirror of
https://github.com/sern-handler/handler
synced 2026-06-27 10:12:14 +00:00
feat: types organization and cleaning up code base
This commit is contained in:
53
src/shared.ts
Normal file
53
src/shared.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import type {
|
||||
CommandInteractionOptionResolver,
|
||||
InteractionReplyOptions,
|
||||
MessageReplyOptions,
|
||||
} from 'discord.js';
|
||||
import { PayloadType } from './core';
|
||||
import { Dependencies } from './core/ioc/types';
|
||||
import { AnyModule } from './core/types/modules';
|
||||
|
||||
export type ReplyOptions =
|
||||
| string
|
||||
| Omit<InteractionReplyOptions, 'fetchReply'>
|
||||
| MessageReplyOptions;
|
||||
|
||||
export type Payload =
|
||||
| { type: PayloadType.Success; module: AnyModule }
|
||||
| { type: PayloadType.Failure; module?: AnyModule; reason: string | Error }
|
||||
| { type: PayloadType.Warning; reason: string };
|
||||
|
||||
export interface SernEventsMapping {
|
||||
'module.register': [Payload];
|
||||
'module.activate': [Payload];
|
||||
error: [Payload];
|
||||
warning: [Payload];
|
||||
}
|
||||
|
||||
|
||||
export type Awaitable<T> = PromiseLike<T> | T;
|
||||
|
||||
export type ModuleStore = Map<string, string>;
|
||||
|
||||
export type Deprecated<Message extends string> = [never, Message];
|
||||
|
||||
|
||||
export interface Wrapper {
|
||||
commands: string;
|
||||
defaultPrefix?: string;
|
||||
events?: string;
|
||||
containerConfig?: {
|
||||
get: (...keys: (keyof Dependencies)[]) => unknown[];
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// Thanks to @kelsny
|
||||
export type ParseType<T> = {
|
||||
[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<CommandInteractionOptionResolver, 'getMessage' | 'getFocused'>;
|
||||
|
||||
Reference in New Issue
Block a user