Skip to main content

Documentation Index

Fetch the complete documentation index at: https://www.cometchat.com/docs/llms.txt

Use this file to discover all available pages before exploring further.

Leave a Group

Use leaveGroup() to leave a group.
const GUID: string = "GUID";

CometChat.leaveGroup(GUID).then(
(hasLeft: boolean) => {
console.log("Group left successfully:", hasLeft);
}, (error: CometChat.CometChatException) => {
console.log("Group leaving failed with exception:", error);
}
);

ParameterDescription
GUIDThe GUID of the group you would like to leave
Once a group is left, the user will no longer receive any updates or messages pertaining to the group. On success, the method resolves with true (boolean).

Real-time Group Member Left Events

Register a GroupListener to receive events when members leave.
CometChat.addGroupListener(
  "UNIQUE_LISTENER_ID",
  new CometChat.GroupListener({
      onGroupMemberLeft: (message: CometChat.Action, leavingUser: CometChat.User, group: CometChat.Group) => {
          console.log("User left", { message, leavingUser, group });
      }
  })
);
Always remove group listeners when they’re no longer needed (e.g., on component unmount or page navigation). Failing to remove listeners can cause memory leaks and duplicate event handling.
CometChat.removeGroupListener("UNIQUE_LISTENER_ID");

Missed Group Member Left Events

When fetching message history, leave events appear as Action messages with:
  • action"left"
  • actionByUser who left
  • actionForGroup that was left

Next Steps

Join a Group

Join public or password-protected groups

Delete a Group

Permanently delete a group

Kick & Ban Members

Remove or ban members from a group

Retrieve Groups

Fetch and filter the list of groups