> ## Documentation Index
> Fetch the complete documentation index at: https://cometchat-013b37f0.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Change Member Scope

## Change Scope of a Group Member

In order to change the scope of a group member, you can use the `changeGroupMemberScope()`.

<Tabs>
  <Tab title="JavaScript">
    ```js theme={null}
    var GUID = "GUID";
    var UID = "UID";
    var scope = CometChat.GROUP_MEMBER_SCOPE.ADMIN;

    CometChat.updateGroupMemberScope(GUID, UID, scope).then(
      (response) => {
        console.log("Group member scopped changed", response);
      },
      (error) => {
        console.log("Group member scopped changed failed", error);
      }
    );
    ```
  </Tab>
</Tabs>

This method takes the below parameters:

| Parameter | Description                                                                                                                                                                                                                 |
| --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `UID`     | The UID of the member whose scope you would like to change                                                                                                                                                                  |
| `GUID`    | The GUID of the group for which the member's scope needs to be changed                                                                                                                                                      |
| `scope`   | The updated scope of the member. This can be either of the 3 values: 1.`CometChatConstants.SCOPE_ADMIN` (admin)  2.`CometChatConstants.SCOPE_MODERATOR` (moderator)  3.`CometChatConstants.SCOPE_PARTICIPANT` (participant) |

The default scope of any member is `participant`. Only the **Admin** of the group can change the scope of any participant in the group.

## Real-Time Group Member Scope Changed Events

*In other words, as a member of a group, how do I know when someone's scope is changed when my app is running?*

In order to receive real-time events for the change member scope event, you will need to override the `onGroupMemberScopeChanged()` method of the `GroupListener` class

<Tabs>
  <Tab title="Group Listener">
    ```
    let listenerID = "UNIQUE_LISTENER_ID";

    CometChat.addGroupListener(
      listenerID,
      new CometChat.GroupListener({
        onGroupMemberScopeChanged: (
          message,
          changedUser,
          newScope,
          oldScope,
          changedGroup
        ) => {
          console.log("User joined", {
            message,
            changedUser,
            newScope,
            oldScope,
            changedGroup,
          });
        },
      })
    );
    ```
  </Tab>
</Tabs>

## Missed Group Member Scope Changed Events

*In other words, as a member of a group, how do I know when someone's scope is changed when my app is not running?*

When you retrieve the list of previous messages if a member's scope has been changed for any group that the logged-in user is a member of, the list of messages will contain an `Action` message. An `Action` message is a sub-class of `BaseMessage` class.

For the group member scope changed event, in the `Action` object received, the following fields can help you get the relevant information-

1. `action` - `scopeChanged`
2. `actionOn` - User object containing the details of the user whose scope has been changed
3. `actionBy` - User object containing the details of the user who changed the scope of the member
4. `actionFor` - Group object containing the details of the group in which the member scope was changed
5. `oldScope` - The original scope of the member
6. `newScope` - The updated scope of the member
