mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2026-02-11 23:40:24 +00:00
chore: OneBotApi
This commit is contained in:
30
src/onebot/action/group/SetGroupCard.ts
Normal file
30
src/onebot/action/group/SetGroupCard.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import BaseAction from '../BaseAction';
|
||||
import { getGroupMember } from '@/core/data';
|
||||
import { ActionName } from '../types';
|
||||
import { NTQQGroupApi } from '@/core/apis/group';
|
||||
import { FromSchema, JSONSchema } from 'json-schema-to-ts';
|
||||
|
||||
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;
|
||||
|
||||
type Payload = FromSchema<typeof SchemaData>;
|
||||
|
||||
export default class SetGroupCard extends BaseAction<Payload, null> {
|
||||
actionName = ActionName.SetGroupCard;
|
||||
PayloadSchema = SchemaData;
|
||||
protected async _handle(payload: Payload): Promise<null> {
|
||||
const member = await getGroupMember(payload.group_id, payload.user_id);
|
||||
if (!member) {
|
||||
throw `群成员${payload.user_id}不存在`;
|
||||
}
|
||||
await NTQQGroupApi.setMemberCard(payload.group_id.toString(), member.uid, payload.card || '');
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user