Chat / JavaScript
Chat JavaScript v4
Chat JavaScript
Chat
JavaScript
Home
/
Chat
/
JavaScript
/
User
This is the new Docs for Chat SDK v4 for JavaScript. To see the previous Docs, click here.

Ban and unban a user

Operators of an open or group channel can remove any users that behave inappropriately in the channel by using the ban feature. A banned user is immediately kicked out of the channel, but allowed to participate in the channel again after a set period of time has passed. Operators can ban and unban users in channels using the following code.

Open channelGroup channel
// Ban a user.
await channel.banUser(USER, SECONDS);

// Unban a user.
await channel.unbanUser(USER);

Note: You can also use banUserWithUserId() and unbanUserWithUserId() as they have the same functionalities. See our API reference for more information.