mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-06 21:10:23 +00:00
refactor: type-check (#586)
* refactor: type-check * fix: default * refactor: type-check
This commit is contained in:
@@ -1,18 +1,14 @@
|
||||
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||
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: {
|
||||
group_id: { type: ['number', 'string'] },
|
||||
user_id: { type: ['number', 'string'] },
|
||||
card: { type: 'string' },
|
||||
},
|
||||
required: ['group_id', 'user_id', 'card'],
|
||||
} as const satisfies JSONSchema;
|
||||
const SchemaData = Type.Object({
|
||||
group_id: Type.Union([Type.Number(), Type.String()]),
|
||||
user_id: Type.Union([Type.Number(), Type.String()]),
|
||||
card: Type.Optional(Type.String())
|
||||
});
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
type Payload = Static<typeof SchemaData>;
|
||||
|
||||
export default class SetGroupCard extends OneBotAction<Payload, null> {
|
||||
actionName = ActionName.SetGroupCard;
|
||||
|
||||
Reference in New Issue
Block a user