AI Integration Quick Reference
AI Integration Quick Reference
- Kick a member from the group
- Ban a member from the group
- Unban a member from the group
- Update the scope of the member of the group
Kick a Group Member
The Admin or Moderator of a group can kick a member out of the group using thekickGroupMember() method.
- Dart
kickGroupMember() takes following parameters:
| Parameter | Type | Description |
|---|---|---|
guid | String | The GUID of the group from which user is to be kicked |
uid | String | The UID of the user to be kicked |
onSuccess | Function(String) | Callback triggered on successful kick |
onError | Function(CometChatException) | Callback triggered on error |
Response
Response
On Success — A
String message confirming the member was kicked:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
message | string | Success confirmation message | "cometchat-uid-3 kicked successfully" |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | string | Error code identifier | "ERR_NOT_A_MEMBER" |
message | string | Human-readable error message | "The user is not a member of this group." |
details | string | Additional technical details | "Please verify the user ID and group ID and try again." |
Ban a Group Member
The Admin or Moderator of the group can ban a member from the group using thebanGroupMember() method. Unlike kicked users, banned users cannot rejoin until unbanned.
- Dart
banGroupMember() method takes the following parameters:
| Parameter | Type | Description |
|---|---|---|
guid | String | The GUID of the group from which user is to be banned |
uid | String | The UID of the user to be banned |
onSuccess | Function(String) | Callback triggered on successful ban |
onError | Function(CometChatException) | Callback triggered on error |
Response
Response
On Success — A
String message confirming the member was banned:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
message | string | Success confirmation message | "cometchat-uid-3 banned successfully" |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | string | Error code identifier | "ERR_NOT_A_MEMBER" |
message | string | Human-readable error message | "The user is not a member of this group." |
details | string | Additional technical details | "Please verify the user ID and group ID and try again." |
Unban a Banned Group Member from a Group
Only Admin or Moderators of the group can unban a previously banned member from the group using theunbanGroupMember() method.
- Dart
unbanGroupMember() method takes the following parameters
| Parameter | Type | Description |
|---|---|---|
guid | String | The GUID of the group from which user is to be unbanned |
uid | String | The UID of the user to be unbanned |
onSuccess | Function(String) | Callback triggered on successful unban |
onError | Function(CometChatException) | Callback triggered on error |
Response
Response
On Success — A
String message confirming the member was unbanned:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
message | string | Success confirmation message | "cometchat-uid-3 unbanned successfully" |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | string | Error code identifier | "ERR_NOT_A_MEMBER" |
message | string | Human-readable error message | "The user is not a member of this group." |
details | string | Additional technical details | "Please verify the user ID and group ID and try again." |
Get List of Banned Members for a Group
In order to fetch the list of banned groups members for a group, you can use theBannedGroupMembersRequest class. To use this class i.e to create an object of the BannedGroupMembersRequest class, you need to use the BannedGroupMembersRequestBuilder class. The BannedGroupMembersRequestBuilder class allows you to set the parameters based on which the banned group members are to be fetched.
The BannedGroupMembersRequestBuilder class allows you to set the below parameters:
The GUID of the group for which the banned members are to be fetched must be specified in the constructor of the GroupMembersRequestBuilder class.
Set Limit
This method sets the limit i.e. the number of banned members that should be fetched in a single iteration.- Dart
Set Search Keyword
This method allows you to set the search string based on which the banned group members are to be fetched.- Dart
build() method to get the object of the BannedGroupMembersRequest class.
Once you have the object of the BannedGroupMembersRequest class, you need to call the fetchNext() method. Calling this method will return a list of GroupMember objects containing n number of banned members where n is the limit set in the builder class.
- Dart
Response
Response
On Success — A
List<GroupMember> containing the banned group members for the specified group (each item is a GroupMember object):GroupMember Object (per item in array):| Parameter | Type | Description | Sample Value |
|---|---|---|---|
uid | string | Unique identifier of the user | "cometchat-uid-3" |
name | string | Display name of the user | "Kevin Hart" |
link | string | Profile link | null |
avatar | string | Avatar URL | "https://assets.cometchat.io/sampleapp/v2/users/cometchat-uid-3.webp" |
metadata | object | Custom metadata | {} |
status | string | Online status | "offline" |
role | string | User role | "default" |
statusMessage | string | Status message | null |
tags | array | User tags | [] |
hasBlockedMe | boolean | Whether this user has blocked the current user | false |
blockedByMe | boolean | Whether the current user has blocked this user | false |
lastActiveAt | number | Epoch timestamp of last activity | 1745554700 |
scope | string | Member scope in the group | "participant" |
joinedAt | number | Epoch timestamp when the member joined the group | 1745550000 |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | string | Error code identifier | "ERR_NOT_A_MEMBER" |
message | string | Human-readable error message | "The user is not a member of this group." |
details | string | Additional technical details | "Please verify the group ID and try again." |
Real-Time Group Member Kicked/Banned Events
In other words, as a member of a group, how do I know when someone is banned/kicked when my app is running? Implement theseGroupListener methods to receive real-time notifications:
| Method | Triggered When |
|---|---|
onGroupMemberKicked() | A member is kicked |
onGroupMemberBanned() | A member is banned |
onGroupMemberUnbanned() | A member is unbanned |
- Dart
Missed Group Member Kicked/Banned Events
In other words, as a member of a group, how do I know when someone is banned/kicked when my app is not running? When you retrieve the list of previous messages if a member has been kicked/banned/unbanned from any group that the logged-in user is a member of, the list of messages will contain anAction message. An Action message is a sub-class of BaseMessage class.
Kicked event:
| Field | Value/Type | Description |
|---|---|---|
action | "kicked" | The action type |
actionBy | User | The user who kicked the member |
actionOn | User | The member who was kicked |
actionFor | Group | The group from which the member was kicked |
| Field | Value/Type | Description |
|---|---|---|
action | "banned" | The action type |
actionBy | User | The user who banned the member |
actionOn | User | The member who was banned |
actionFor | Group | The group from which the member was banned |
| Field | Value/Type | Description |
|---|---|---|
action | "unbanned" | The action type |
actionBy | User | The user who unbanned the member |
actionOn | User | The member who was unbanned |
actionFor | Group | The group from which the member was unbanned |
Next Steps
Add Members
Add new members to your groups
Change Member Scope
Update member roles and permissions
Retrieve Group Members
Fetch the list of members in a group
Leave a Group
Allow members to leave a group