From 038d0c5412420f58766ebca52223893aa8d207b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=89=8B=E7=93=9C=E4=B8=80=E5=8D=81=E9=9B=AA?= Date: Sun, 2 Mar 2025 14:55:47 +0800 Subject: [PATCH] fix: #785 --- src/onebot/action/group/SetGroupBan.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/onebot/action/group/SetGroupBan.ts b/src/onebot/action/group/SetGroupBan.ts index aa5cdf26..fd98030e 100644 --- a/src/onebot/action/group/SetGroupBan.ts +++ b/src/onebot/action/group/SetGroupBan.ts @@ -16,6 +16,9 @@ export default class SetGroupBan extends OneBotAction { async _handle(payload: Payload): Promise { const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString()); if (!uid) throw new Error('uid error'); + let member_role = (await this.core.apis.GroupApi.getGroupMemberEx(payload.group_id.toString(), uid, true))?.role; + if (member_role === 4) throw new Error('cannot ban owner'); + if (member_role === 3) throw new Error('cannot ban admin'); // 例如无管理员权限时 result为 120101005 errMsg为 'ERR_NOT_GROUP_ADMIN' let ret = await this.core.apis.GroupApi.banMember(payload.group_id.toString(), [{ uid: uid, timeStamp: +payload.duration }]);