Commit 0407b0af authored by nanahira's avatar nanahira

catchup

parent 46da4815
......@@ -107,7 +107,11 @@ export class KoishiMetascanService {
return user?.name;
}
}
return argv.session.author?.nickname || argv.session.author?.username;
return (
argv.session.author?.nickname ||
argv.session.author?.username ||
argv.session.userId
);
case 'sessionField':
const { data: sessionField } =
config as CommandPutConfig<'sessionField'>;
......
......@@ -201,6 +201,11 @@ export const CommandDef = (
): MethodDecorator & ClassDecorator =>
AppendMetadata(KoishiCommandDefinition, def);
export const CommandUse = <T extends Command, R extends any[]>(
callback: (command: Command, ...args: R) => T,
...args: R
) => CommandDef((cmd) => callback(cmd, ...args));
export const CommandDescription = (desc: string) =>
CommandDef((cmd) => {
cmd.description = desc;
......@@ -254,11 +259,10 @@ function PutCommandParam<T extends keyof CommandPutConfigMap>(
};
}
export const PutArgv = () => PutCommandParam('argv');
export const PutArgv = (field?: keyof Argv) =>
field ? PutCommandParam('argvField', field) : PutCommandParam('argv');
export const PutSession = (field?: keyof Session) =>
field
? PutCommandParam('sessionField', field)
: PutCommandParam('argvField', 'session');
field ? PutCommandParam('sessionField', field) : PutArgv('session');
export const PutArg = (i: number) => PutCommandParam('arg', i);
export const PutArgs = () => PutCommandParam('args');
export const PutOption = (
......@@ -283,7 +287,7 @@ export const PutChannelId = () => PutSession('channelId');
export const PutChannelName = () => PutSession('channelName');
export const PutSelfId = () => PutSession('selfId');
export const PutBot = () => PutSession('bot');
export const PutNext = () => PutCommandParam('argvField', 'next');
export const PutNext = () => PutArgv('next');
// Service
......
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