mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-12 16:00:27 +00:00
refactor: type-check (#586)
* refactor: type-check * fix: default * refactor: type-check
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
import { NTGroupRequestOperateTypes } from '@/core/types';
|
||||
import { ActionName } from '@/onebot/action/router';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
import { Static, Type } from '@sinclair/typebox';
|
||||
|
||||
const SchemaData = {
|
||||
type: 'object',
|
||||
properties: {
|
||||
flag: { type: 'string' },
|
||||
approve: { type: ['string', 'boolean'] },
|
||||
reason: { type: 'string', nullable: true },
|
||||
},
|
||||
required: ['flag'],
|
||||
} as const satisfies JSONSchema;
|
||||
const SchemaData = Type.Object({
|
||||
flag: Type.String(),
|
||||
approve: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||
reason: Type.String({ default: ' ' }),
|
||||
});
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.SetGroupAddRequest;
|
||||
@@ -24,7 +20,7 @@ export default class SetGroupAddRequest extends OneBotAction<Payload, null> {
|
||||
const approve = payload.approve?.toString() !== 'false';
|
||||
await this.core.apis.GroupApi.handleGroupRequest(flag,
|
||||
approve ? NTGroupRequestOperateTypes.KAGREE : NTGroupRequestOperateTypes.KREFUSE,
|
||||
payload.reason ?? ' ',
|
||||
payload.reason,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user