In-app Chat
SDK Error Codes
On this page

Community mute

2026-06-24
Note

The current Community mute feature only supports muting operations on channels within a Community. Community-level global muting is not yet supported.

After a user logs in to the ZIM SDK, they can set the mute status of Community channels through muteCommunityChannels, supporting batch settings for multiple channels.

Prerequisites

  • Please refer to Send and receive messages to complete ZIM SDK integration, initialization, and user login.
  • Please refer to Token-based authentication to implement user authentication login.
  • The Community feature requires ZIM SDK 3.0.0 or later.
  • The Community feature is part of the Premium plan. Please contact ZEGOCLOUD Technical Support to enable it before use.
  • The Token generation for the Community feature is consistent with other ZIM features, and no additional permission declarations are required.

Feature description

  • Supports batch setting the mute status for multiple channels. The mute configuration is specified through ZIMCommunityChannelMuteConfig.
  • config.mode determines the mute scope: NONE (no mute, used to unmute), NORMAL (mute ordinary members), ALL (mute everyone including admins and group owners), CUSTOM (custom role scope, controlled by config.roles).
  • config.duration specifies the mute duration in seconds, with a range of 1-2592001 (approximately 30 days), or -1 for permanent muting.

After successful setting, the result can be obtained through ZIMCommunityChannelsMutedCallback.

Configuration fieldDescription
modeMute scope: NONE(0) unmute all roles (used to unmute; isMute=true with mode=NONE is equivalent to canceling mute), NORMAL(1) mute ordinary members, ALL(2) mute all members, CUSTOM(3) custom role scope
rolesTakes effect when mode is Custom, specifying the list of roles to be muted
durationMute duration (seconds), 1-2592001 or -1 for permanent muting

channelIDs and communityID are direct parameters of the API method, not config fields.

Mute mechanism description

Community supports two mute dimensions, which can take effect simultaneously:

DimensionAPIScopeDescription
Channel mutemuteCommunityChannelsChannel levelMute specified channels, with the mute role scope controlled by config.mode
Member mutemuteCommunityMembersMember levelMute specified members in specified channels (if left empty, applies to all channels)
  • When a member's channel is set to muted and the member has not been individually muted, the channel mute configuration takes precedence.
  • When a member is individually muted, that member cannot send messages regardless of the channel's mute status.
  • For details on member muting, see Community member management - Set member mute.

Example code

const channelIDs = ['channel_1', 'channel_2'];
const config: ZIMCommunityChannelMuteConfig = {
	duration: 3600,
	mode: 2, // "1: Normal" | "2: All" | "3: Custom"
	// roles: [101, 102], // Pass in when mode = 'Custom'
};

zim.muteCommunityChannels(true, channelIDs, communityID, config)
	.then((result: ZIMCommunityChannelsMutedResult) => {
		// result.errorChannelIDs is the list of channel IDs that failed
	})
	.catch((err: ZIMError) => {
		// Operation failed
	});
Error codeDescriptionRecommendation
6001004Community does not existVerify that the communityID is correct
6001062Channel does not existVerify that the channelID is correct
6001065Cannot disband the default channelThe default channel does not support disbanding
6001007Community permission errorVerify that the current user is an admin or owner

Query channel mute status

Call the queryCommunityChannelsInfo API to batch query the full information of specified channels, including the current mute status.

  • channelInfos returns a list of ZIMCommunityChannelFullInfo, where muteInfo contains the channel mute information.
  • errorChannelIDs returns the list of channel IDs that failed the query.
Result fieldDescription
baseInfoBasic channel information
createTimeChannel creation time
creatorUserIDUser ID of the channel creator
channelNoticeChannel notice
channelAttributesChannel attributes dictionary
currentMemberCountCurrent number of channel members
muteInfoChannel mute information, including mode, expiredTime, and roles

muteInfo field description

FieldTypeDescription
modeZIMCommunityChannelMuteModeCurrent mute mode: NONE(0), NORMAL(1), ALL(2), CUSTOM(3)
expiredTimelongMute expiration time (milliseconds); mute is automatically lifted after expiration
rolesArrayList<Integer>List of currently muted roles; only has a value when mode is CUSTOM
const channelIDs = ['channel_1', 'channel_2'];

zim.queryCommunityChannelsInfo(channelIDs, communityID)
    .then((result: ZIMCommunityChannelsInfoQueriedResult) => {
        const { channelInfos } = result;
        channelInfos.forEach((channelInfo) => {
            const muteInfo = channelInfo.muteInfo;
            // muteInfo.mode : Current channel mute mode
            // muteInfo.expiredTime : Mute expiration time (milliseconds)
            // muteInfo.roles : List of currently muted roles
        });
    })
    .catch((err: ZIMError) => {
        // Query failed
    });

Listen for channel mute change events

When channel information (name, avatar, notice, attributes, mute status, etc.) changes, the SDK triggers a channel information update callback. You can obtain the channelInfo.muteInfo from updateInfoList through this callback to determine the current mute mode and muted roles of a channel.

  • communityID: The Community ID that triggered the update.
  • updateInfoList: The list of updated full channel information.
  • channelInfo.muteInfo: Contains mute status information such as mode, expiredTime, and roles.

Due to the large scale of Communities, the SDK may only push channel information change notifications to active users. If no push is received, you can proactively fetch the latest channel information through queryCommunityChannelsInfo.

zim.on('communityChannelInfoUpdated', (zim, result) => {
    const communityID = result.communityID;
    result.updateInfoList.forEach((updateInfo) => {
        const channelInfo = updateInfo.channelInfo;
        const muteInfo = channelInfo.muteInfo;
        // muteInfo.mode : Current channel mute mode
        // muteInfo.expiredTime : Mute expiration time (milliseconds)
        // muteInfo.roles : List of currently muted roles
    });
});
2026-06-24

Previous

Channel conversation management

Next

Cache management

On this page

Back to top