-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatCommand.ts
29 lines (25 loc) · 916 Bytes
/
ChatCommand.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import {ChatCommandData} from "./ChatCommandData";
/**
* Chat command type
*/
export interface ChatCommand<A> extends Record<string, unknown>{
readonly commonData: ChatCommandData
readonly actionData: A
}
export function isChatCommand(data: unknown): data is ChatCommand<unknown> {
return "object" === typeof data && null !== data
&& "commonData" in data && "object" === typeof data.commonData
&& "actionData" in data && "object" === typeof data.actionData;
}
/**
* Chat command bound to queue
*/
export interface BoundChatCommand<A> {
readonly queueName: string
readonly command: ChatCommand<A>
}
export function isBoundChatCommand<A>(data: unknown): data is BoundChatCommand<A> {
return "object" === typeof data && null !== data
&& "queueName" in data && "string" === typeof data.queueName
&& "command" in data && "object" === typeof data.command;
}