From b2ce5f472a589824dce043f84d0baa7ca54d8820 Mon Sep 17 00:00:00 2001 From: icarus-ai <82353054+icarus-ai@users.noreply.github.com> Date: Tue, 8 Oct 2024 19:42:55 +0800 Subject: [PATCH] fix: api.CQSetGroupAdmin (#7) --- coolq/api.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/coolq/api.go b/coolq/api.go index ba5f472c7..05a37e0c5 100644 --- a/coolq/api.go +++ b/coolq/api.go @@ -909,16 +909,16 @@ func (bot *CQBot) CQDeleteMessage(messageID int32) global.MSG { // @route(set_group_admin) // @default(enable=true) func (bot *CQBot) CQSetGroupAdmin(groupID, userID int64, enable bool) global.MSG { - if g := bot.Client.GetCachedGroupInfo(uint32(groupID)); g != nil { + if g := bot.Client.GetCachedGroupInfo(uint32(groupID)); g == nil { return Failed(100, "GROUP_NOT_FOUND", "群不存在") } - if m := bot.Client.GetCachedMemberInfo(uint32(userID), uint32(groupID)); m.Permission != entity.Owner { - return Failed(100, "PERMISSION_DENIED", "或权限不足") - } - mem := bot.Client.GetCachedMemberInfo(uint32(userID), uint32(groupID)) - if mem == nil { + m := bot.Client.GetCachedMemberInfo(uint32(userID), uint32(groupID)) + if m == nil { return Failed(100, "GROUP_MEMBER_NOT_FOUND", "群成员不存在") } + if m.Permission != entity.Owner { + return Failed(100, "PERMISSION_DENIED", "或权限不足") + } if err := bot.Client.GroupSetAdmin(uint32(groupID), uint32(userID), enable); err != nil { return Failed(100, "反正是失败了.png", err.Error()) }