isOnline
field, indicating whether the member is online.muteUntil
) of group members. Based on this value, you can determine if a member is muted and the remaining muting time.memberCount
), please use getGroupProfile
.filter
parameter. Please refer to mark
GroupMemberList
to tag group members.userID
, nick
, avatar
, joinTime
and role
. To set nick and avatar information, please call: updateMyProfile
.chat.getGroupMemberList(options);
options
parameter is of the Object
type, and contains the following attribute values:Name | Type | Description |
groupID | String | Group ID |
role | String | Group member roles. By default, the SDK pulls all group members, but you can set this field to pull a list of group members with specified roles. The supported values are as follows: TencentCloudChat.GRP_MBR_ROLE_OWNER - Group ownerTencentCloudChat.GRP_MBR_ROLE_ADMIN - Group administratorTencentCloudChat.GRP_MBR_ROLE_MEMBER - Ordinary group member |
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 Premium edition for AVChatRoom ignores the count parameter when using this API). |
offset | Number | String | Offset, default is to start pulling from 0. When used in Community, this field is of type String . |
filter | Number | Custom tags for group members, supported only in AVChatRoom. |
Promise
// Pull all administrators of the grouplet promise = chat.getGroupMemberList({groupID: 'group1',role: TencentCloudChat.TYPES.GRP_MBR_ROLE_ADMIN,count: 15,offset: 0});promise.then(function(imResponse) {console.log(imResponse.data.memberList);}).catch(function(imError) {console.warn('getGroupMemberList error:', imError);});
// Pull 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 Premium edition supports retrieving the list of online members in the AVChatRoomlet promise = chat.getGroupMemberList({groupID: 'group1',filter: 1000,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);});
// filter the list of online members in the AVChatRoomlet promise = chat.getGroupMemberList({ groupID: 'group1', filter: 1000, offset: 0 }); promise.then(function(imResponse) { console.log(imResponse.data.memberList); }).catch(function(imError) { console.warn('getGroupMemberList error:', imError); });
TencentCloudChat.TYPES.GRP_WORK
type groups do not support this operation.TencentCloudChat.TYPES.GRP_AVCHATROOM
type groups do not support this operation。deleteGroup
Member
interface.updateGroupProfile
.chat.setGroupMemberMuteTime(options);
parameter
is of the Object
type, and contains the following attribute values: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.member); // New member 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.member); // New member 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});
TencentCloudChat.TYPES.GRP_WORK
(Work): By default, any group member can directly invite others into the group without the need for the invitee's consent, and they are added to the group directly. You can set inviteOption
to TencentCloudChat.TYPES.INVITE_OPTIONS_DISABLE_INVITE
to prohibit any group member from inviting others into the group.TencentCloudChat.TYPES.GRP_PUBLIC
(Public) / TencentCloudChat.TYPES.GRP_MEETING
(Meeting): By default, group members are not allowed to invite others into the group. You can control the invitation options by setting inviteOption
.TencentCloudChat.TYPES.GRP_COMMUNITY
(Community): By default, group members are allowed to invite others into the group.TencentCloudChat.TYPES.GRP_AVCHATROOM
(AVChatRoom): No one is allowed to invite others into the group (including App administrators).chat.addGroupMember(options);
parameter
is of the Object
type, and contains the following attribute values:Name | Type | Description |
groupID | String | Group ID |
userIDList | Array.<String> | The array of group member IDs to be added, with a maximum of 20 members per time. |
Promise
let promise = chat.addGroupMember({groupID: 'group1', userIDList: ['user1','user2','user3']});promise.then(function(imResponse) {console.log(imResponse.data.successUserIDList);console.log(imResponse.data.failureUserIDList);console.log(imResponse.data.existedUserIDList);// A user userX is allowed to join up to N groups.// If userX has already joined N groups, attempting to add userX as a group member again will result in userX being unable to join the group normally.// SDK places userX's information into the overLimitUserIDList for processing by the access side.console.log(imResponse.data.overLimitUserIDList);console.log(imResponse.data.group);}).catch(function(imError) {console.warn('addGroupMember error:', imError);});
chat.deleteGroupMember(options);
options
parameter is of the Object
type, and contains the following attribute values:Name | Type | Description |
groupID | String | Group ID or topic ID |
userIDList | Array | List of IDs of the group members to be removed |
reason | String | Reason for kicking out |
duration | Number | Kick-out duration must be greater than 0 (supported only by AVChatRoom) |
Promise
// Removing group members from non-live groupslet promise = chat.deleteGroupMember({groupID: 'group1',userIDList:['user1'],reason: 'You violated the rules, I am 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 AVChatRoomlet 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 do not support this operation.TencentCloudChat.TYPES.GRP_AVCHATROOM
type groups do not support this operation.chat.setGroupMemberRole(options);
parameter
is of the Object
type, and contains the following attribute values: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.member); // New member 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 AVChatRoomlet 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?