Manage Channel Members

1. Invite Users

You can invite members to the channel even if you are not the owner.

const resp = await client.addChannelMembers({
    channelId: 'my_channel',
    members: ['new_user1', 'new_user_2'],
});

2. Remove Members

const resp = await client.removeChannelMembers({
    channelId: 'my_channel',
    members: ['new_user1', 'new_user_2'],
});

3. Get Channel Member List

const numOfRows = 5;

const resp = await client.getChannelMembers({
    channelId: 'my_channel',
});

if (resp.hasNext) {
    const lastUserId = resp.users[resp.users.length - 1].id;
    const moreResp = await client.getChannelMembers({lastUserId, limit: numOfRows});
}

4. Ban Users

await client.banChannelMembers({
    channelId: 'my_channel',
    members: ['bad_user_1', 'bad_user_2'],
});

5. Unban Users

await client.unbanChannelMembers({
    channelId: 'my_channel',
    members: ['good_user_1', 'good_user_2'],
});

6. Get Banned User List

const numOfRows = 5;

const resp = await client.getBannedChannelUsers({
    channelId: 'my_channel',
});

if (resp.hasNext) {
    const lastUserId = resp.users[resp.users.length - 1].id;
    const moreResp = await client.getBannedChannelUsers({lastUserId, limit: numOfRows});
}

7. Mute Members

Mute feature allows the channel owner to mute specific members in the channel. Muted members are not allowed to send messages.

await client.muteChannelMembers({
    channelId: 'some_public_channel',
    members: ['talkative_user1'],
});

8. Unmute Members

await client.unmuteChannelMembers({
    channelId: 'some_public_channel',
    members: ['talkative_user1'],
});

9. Get Muted User List

const numOfRows = 5;

const resp = await client.getMutedChannelMembers({
    channelId: 'my_channel',
});

if (resp.hasNext) {
    const lastUserId = resp.users[resp.users.length - 1].id;
    const moreResp = await client.getMutedChannelMembers({lastUserId, limit: numOfRows});
}

10. Peer Mute

You can 'peer mute' another member in the channel.

const resp = await client.mutePeers({
    channelId: 'my_channel',
    members: ['other_user'],
    expireInMinutes: 5, // 5분 후 mute 해제
});

11. Get Peer Muted List

const numOfRows = 5;

const resp = await client.getMutedPeers({
    channelId: 'my_channel',
    limit: numOfRows,
});

if (resp.hasNext) {
    const lastUserId = resp.users[resp.members.length - 1].id;
    const moreResp = await client.getMutedPeers({lastUserId, limit: numOfRows});
}

12. Peer Mute

You can 'unmute peer' another member in the channel.

// unmute peers
const resp = await client.unmutePeers({
    channelId: 'my_channel',
    members: ['other_user'],
});

Last updated