Commit 0407b0af authored by nanahira's avatar nanahira

catchup

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