Commit 9f95354c authored by nanahira's avatar nanahira

fix middleware and command types

parent e77dd121
...@@ -85,4 +85,6 @@ export interface CommandOptionConfig { ...@@ -85,4 +85,6 @@ export interface CommandOptionConfig {
config?: CommandOptionConfigWithDescription; config?: CommandOptionConfigWithDescription;
} }
export type CommandReturnType = CanBeObserved<string | void | segment>; export type CommandReturnType = CanBeObserved<
string | void | segment | (string | segment)[]
>;
import { Awaitable, Session, segment } from 'koishi'; import { Awaitable, Session } from 'koishi';
import { isObservable, Observable } from 'rxjs'; import { isObservable, Observable } from 'rxjs';
import { CommandReturnType } from '../def';
export type CanBeObserved<T> = Awaitable<T | Observable<T>>; export type CanBeObserved<T> = Awaitable<T | Observable<T>>;
export async function sessionRxToPromise( export async function sessionRxToPromise(
session: Session, session: Session,
obs: CanBeObserved<string | void | segment>, obs: CommandReturnType,
) { ) {
const obsAwaited = await obs; const obsAwaited = await obs;
if (!isObservable(obsAwaited)) { if (!isObservable(obsAwaited)) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment