Skip to content

Commit

Permalink
Include Bot when getting group members. Closes #23
Browse files Browse the repository at this point in the history
  • Loading branch information
yyuueexxiinngg committed Aug 6, 2020
1 parent feee4ce commit e681eed
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/kotlin/tech/mihoyo/mirai/MiraiApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -297,8 +297,16 @@ class MiraiApi(val bot: Bot) {
val groupId = params["group_id"]?.long
val cqGroupMemberListData = mutableListOf<CQMemberInfoData>()
return if (groupId != null) {
val members = bot.getGroup(groupId).members
members.forEach { member -> cqGroupMemberListData.add(CQMemberInfoData(member)) }
var isBotIncluded = false
val group = bot.getGroup(groupId)
val members = group.members
members.forEach { member ->
run {
if (member.id == bot.id) isBotIncluded = true
cqGroupMemberListData.add(CQMemberInfoData(member))
}
}
if (!isBotIncluded) cqGroupMemberListData.add(CQMemberInfoData(group.botAsMember))
CQResponseDTO.CQMemberList(cqGroupMemberListData)
} else {
CQResponseDTO.CQInvalidRequest()
Expand Down

0 comments on commit e681eed

Please sign in to comment.