chat.getGroupMemberList(options);
Name | Type | Description |
groupID | String | Group ID |
count | Number | The number of entries to be fetched. Default value: 15, Maximum value: 100, to avoid response failure due to large packages. If more than 100 is passed in, only the first 100 will be fetched (the Enterprise Edition for live groups ignores the count parameter when using this API). |
offset | Number | Offset, default is to start pulling from 0. |
Promise
let promise = chat.getGroupMemberList({groupID: 'group1',count: 30,offset:0,}); // Pull 30 group members starting from 0promise.then(function(imResponse) {console.log(imResponse.data.memberList); // Group member list}).catch(function(imError) {console.warn('getGroupMemberList error:', imError);});
// This API supports pulling the muting end timestamp of group members.let promise = tim.getGroupMemberList({groupID: 'group1',count: 30,offset:0,}); // Pull 30 group members starting from 0promise.then(function(imResponse) {console.log(imResponse.data.memberList); // Group member listfor (let groupMember of imResponse.data.memberList) {if (groupMember.muteUntil * 1000 > Date.now()) {console.log(`${groupMember.userID} muted`);} else {console.log(`${groupMember.userID} not muted`);}}}).catch(function(imError) {console.warn('getGroupMemberProfile error:', imError);});
// The Enterprise Edition Package supports retrieving the list of online members in the live grouplet promise = chat.getGroupMemberList({groupID: 'group1',offset:0, // Default is to start pulling from 0});promise.then(function(imResponse) {console.log(imResponse.data.memberList); // Group member list}).catch(function(imError) {console.warn('getGroupMemberList error:', imError);});
TencentCloudChat.TYPES.GRP_WORK
type groups (i.e., friend work groups) do not support this operation.TencentCloudChat.TYPES.GRP_AVCHATROOM
type groups (i.e., live chat groups) do not support this operation.chat.setGroupMemberMuteTime(options);
Name | Type | Description |
groupID | String | Group ID or topic ID |
userID | String | User ID |
muteTime | Number | Mute duration, in seconds. For example, setting it to 1000 means muting the user for 1000 seconds from now; setting it to 0 means unmuting. |
Promise
let promise = chat.setGroupMemberMuteTime({groupID: 'group1',userID: 'user1',muteTime: 600 // Mute for 10 minutes; set to 0 to unmute});promise.then(function(imResponse) {console.log(imResponse.data.group); // New group profileconsole.log(imResponse.data.group); // New group profile}).catch(function(imError) {console.warn('setGroupMemberMuteTime error:', imError); // Error information});
// Set the period for muting a group member in the topiclet promise = chat.setGroupMemberMuteTime({groupID: 'topicID',userID: 'user1',muteTime: 600 // Mute for 10 minutes; set to 0 to unmute});promise.then(function(imResponse) {console.log(imResponse.data.group); // New group profileconsole.log(imResponse.data.group); // New group profile}).catch(function(imError) {console.warn('setGroupMemberMuteTime error:', imError); // Error information});
// Global Mutelet promise = chat.updateGroupProfile({groupID: 'group1',muteAllMembers: true, // `true`: mute all; `false`: unmute all});promise.then(function(imResponse) {console.log(imResponse.data.group) // Detailed group profile after modification}).catch(function(imError) {console.warn('updateGroupProfile error:', imError); // Error information});
chat.deleteGroupMember(options);
Name | Type | Description |
groupID | String | Group ID or topic ID |
userIDList | Array | List of IDs of the group members to be removed |
reason | String | undefined | Reason for kicking out |
duration | Number | Kick-out duration must be greater than 0 (supported only by live broadcast groups) |
Promise
// Removing group members from non-live broadcast groupslet promise = chat.deleteGroupMember({groupID: 'group1',userIDList:['user1'],reason: 'You violated the rules, I'm kicking you out!',});promise.then(function(imResponse) {console.log(imResponse.data.group); // Group profile after group member removalconsole.log(imResponse.data.userIDList); // List of userID of the removed group member}).catch(function(imError) {console.warn('deleteGroupMember error:', imError); // Error information});
// Removing group members from live broadcast groupslet promise = chat.deleteGroupMember({groupID: 'group1',userIDList:['user1'],reason: 'You violated the rules, I'm kicking you out!',duration: 60,});promise.then(function(imResponse) {console.log(imResponse.data.group); // Group profile after group member removalconsole.log(imResponse.data.userIDList); // List of userID of the removed group member}).catch(function(imError) {console.warn('deleteGroupMember error:', imError); // Error information});
TencentCloudChat.TYPES.GRP_WORK
type groups (i.e., friend work groups) do not support this operation.TencentCloudChat.TYPES.GRP_AVCHATROOM
type groups (i.e., live chat groups) do not support this operation.chat.setGroupMemberRole(options);
Name | Type | Description |
groupID | String | Group ID or topic ID |
userID | String | User ID |
role | String | Valid values: TencentCloudChat.TYPES.GRP_MBR_ROLE_ADMIN (Group Administrator),TencentCloudChat.TYPES.GRP_MBR_ROLE_MEMBER (Group Regular Member),TencentCloudChat.TYPES.GRP_MBR_ROLE_CUSTOM (Custom Group Member Roles, supported only by the Community) |
Promise
let promise = chat.setGroupMemberRole({groupID: 'group1',userID: 'user1',role: TencentCloudChat.TYPES.GRP_MBR_ROLE_ADMIN // Set user: user1 as an admin in group ID: group1});promise.then(function(imResponse) {console.log(imResponse.data.group); // New group profileconsole.log(imResponse.data.group); // New group profile}).catch(function(imError) {console.warn('setGroupMemberRole error:', imError); // Error information});
chat.getGroupOnlineMemberCount(groupID);
Name | Type | Description |
groupID | String | Group ID |
Promise
// Querying the Number of Online Users in an Audio-Video Grouplet promise = chat.getGroupOnlineMemberCount('group1');promise.then(function(imResponse) {console.log(imResponse.data.memberCount);}).catch(function(imError) {console.warn('getGroupOnlineMemberCount error:', imError); // Error information});
Was this page helpful?