Changing Channel Members Confused about "Changing Channel Members"?
Let us know how we can improve our documentation:
Confused about "Changing Channel Members"?
Let us know how we can improve our documentation:
Adding & Removing Channel Members Copied!Confused about "Adding & Removing Channel Members "?
Let us know how we can improve our documentation:
Confused about "Adding & Removing Channel Members "?
Let us know how we can improve our documentation:
Using the addMembers()
method adds the given users as members, while removeMembers()
removes them.
1
2
await channel.addMembers(['thierry', 'josh']);
await channel.removeMembers(['tommaso']);
1
2
await channel.addMembers(["thierry", "josh"]);
await channel.removeMembers(["tommaso"]);
1
2
$channel->addMembers(['thierry', 'jenny']);
$channel->removeMembers(['thierry', 'jenny']);
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
val channelClient = client.channel("messaging", "general")
// Add members with ids "thierry" and "josh"
channelClient.addMembers("thierry", "josh").enqueue { result ->
if (result.isSuccess) {
val channel: Channel = result.data()
} else {
// Handle result.error()
}
}
// Remove member with id "tommaso"
channelClient.removeMembers("tommaso").enqueue { result ->
if (result.isSuccess) {
val channel: Channel = result.data()
} else {
// Handle result.error()
}
}
1
2
3
4
5
6
import Stream Chat
let controller = chatClient.channelController(for: .init(type: .messaging, id: "general"))
controller.addMembers(userIds: ["thierry", "josh"])
controller.removeMembers(userIds: ["tommaso"])
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
ChannelClient channelClient = client.channel("messaging", "general");
// Add members with ids "thierry" and "josh"
channelClient.addMembers("thierry", "josh").enqueue(result -> {
if (result.isSuccess()) {
Channel channel = result.data();
} else {
// Handle result.error()
}
});
// Remove member with id "tommaso"
channelClient.removeMembers("tommaso").enqueue(result -> {
if (result.isSuccess()) {
Channel channel = result.data();
} else {
// Handle result.error()
}
});
You can optionally include a message object that client-side SDKs will use to populate a system message. This works for both add and remove members
1
2
3
4
// using client-side client
await channel.addMembers(['tommaso'], { text: 'Tommaso joined the channel.' });
// using server-side client
await channel.addMembers(['tommaso'], { text: 'Tommaso joined the channel.', user_id: 'tommaso' });
Leaving a channelCopied!Confused about "Leaving a channel"?
Let us know how we can improve our documentation:
Confused about "Leaving a channel"?
Let us know how we can improve our documentation:
It is possible for user to leave the channel without moderator-level permissions. Make sure channel members have RemoveOwnChannelMembership
permission.
1
2
// remove own channel membership
await channel.removeMembers(['my_user_id']);
Adding & Removing Moderators to a ChannelCopied!Confused about "Adding & Removing Moderators to a Channel"?
Let us know how we can improve our documentation:
Confused about "Adding & Removing Moderators to a Channel"?
Let us know how we can improve our documentation:
Using the addModerators()
method adds the given users as moderators (or updates their role to moderator if already members), while demoteModerators()
removes the moderator status.
1
2
await channel.addModerators(['thierry', 'josh']);
await channel.demoteModerators(['tommaso']);
1
2
channel.add_moderators(["thierry", "josh"]);
channel.demote_moderators(["tommaso"]);
1
2
channel.add_moderators(["thierry", "josh"]);
channel.demote_moderators(["tommaso"]);
1
2
$channel->addModerators(['thierry', 'jenny']);
$channel->demoteModerators(['thierry', 'jenny']);
1
// at the moment we don't have a Java client for server side usage
1
2
await channel.AddModerators(new string[] { "thierry", "josh" });
await channel.DemoteModerators(new string[] { "tommaso" });
1
2
3
4
newModerators := []string{"bob", "sue"}
err = channel.AddModerators("thierry", "josh")
err = channel.AddModerators(newModerators...)
err = channel.DemoteModerators(newModerators...)