work on strategy and lifted Context

This commit is contained in:
Jacob Nguyen
2023-04-12 17:03:35 -05:00
parent 58b3d85da8
commit 8bdb6d8216
2 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,22 @@
enum DispatchType {
Websocket,
Serverless
}
type PlatformStrategy =
| WebsocketStrategy
| ServerlessStrategy;
interface WebsocketStrategy {
type: DispatchType.Websocket;
interactionCreate: string;
messageCreate: string;
ready: string;
}
interface ServerlessStrategy {
type: DispatchType.Serverless;
}

View File

@@ -0,0 +1,18 @@
import { Result as Either } from 'ts-results-es';
export abstract class Context<Left, Right> {
private constructor(private _: Either<Left, Right>){}
abstract get message(): Left;
abstract get interaction(): Right;
abstract get id(): string;
}
export function wrap<Left, Right>(
val: Left|Right,
fa: (val: Left|Right
) => Either<Left, Right>) {
return fa(val);
}