mirror of
https://github.com/sern-handler/handler
synced 2026-06-06 01:16:55 +00:00
changing ret type of parse fn
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import type { MessagePackage, Visibility } from "../../types/handler/handler";
|
||||
import { CommandType } from "../../types/handler/handler";
|
||||
import { Files } from "../utils/readFile"
|
||||
import type { Awaitable, Client, Message } from "discord.js";
|
||||
import type { Awaitable, Client, Message, Util } from "discord.js";
|
||||
import type { possibleOutput } from "../../types/handler/handler"
|
||||
import { Err, Ok, Result } from "ts-results";
|
||||
import type { Utils } from "../utils/preprocessors/args";
|
||||
|
||||
|
||||
|
||||
export namespace Sern {
|
||||
type Error = string;
|
||||
|
||||
export class Handler {
|
||||
private wrapper: Sern.Wrapper;
|
||||
private msgHandler : MsgHandler = new MsgHandler();
|
||||
@@ -67,13 +66,13 @@ export namespace Sern {
|
||||
privateServerId : string
|
||||
}
|
||||
|
||||
export interface Module<Args> {
|
||||
export interface Module<T> {
|
||||
alias: string[],
|
||||
desc : string,
|
||||
visibility : Visibility,
|
||||
type: CommandType,
|
||||
delegate : (message: Message, args: Ok<Args> ) => Awaitable<Result<possibleOutput, string > | void>
|
||||
parse? : (args: string) => Result<Args, Error>
|
||||
delegate : (message: Message, args: Ok<T> ) => Awaitable<Result<possibleOutput, string > | void>
|
||||
parse? : (args: string) => Utils.ArgType<T>
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ export namespace Utils {
|
||||
/**
|
||||
* Wrapper type taking `Ok(T)` or `Err(possibleOutput)` e.g `Result<T, possibleOutput`
|
||||
*/
|
||||
type ArgType<T> = Result<T, possibleOutput>
|
||||
export type ArgType<T> = Result<T, possibleOutput>
|
||||
/**
|
||||
*
|
||||
* @param {string} arg
|
||||
@@ -38,6 +38,15 @@ export namespace Utils {
|
||||
}
|
||||
return Err(onFailure)
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param {string} arg
|
||||
* @param {string} sep
|
||||
* @returns
|
||||
*/
|
||||
export function toArr(arg: string, sep: string) : ArgType<string[]> {
|
||||
return Ok(arg.split(sep));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user