Chat / Unreal
Current version: v3
Chat Unreal v3
Chat Unreal
Chat
Unreal
Home
/
Chat
/
Unreal
/
Users

Ban and unban a participant from an open channel

Operators of an open channel can remove any users that behave inappropriately in the channel by using our Ban feature. Banned participants are immediately expelled from a channel, but allowed to participate back in the channel again after the time period set by the operators has passed. Operators can ban and unban participants by using the following code.

openChannel->GetChannel(CHANNEL_URL, [](SBDOpenChannel* channel, SBDError* error) {
    if (error != nullptr) {
        // Handle error.
        return;
    }

    if (channel->IsOperator(*SBDMain::GetCurrentUser())) {
        // Ban a user.
        channel->BanUser(USER, SECONDS, [](SBDError* error) {
            if (error != nullptr) {
                // Handle error.
                return;
            }

            // The user is successfully banned from the channel.
            // You could notify the user of being banned by displaying a message.
        });

        // Unban a user.
        channel->UnbanUser(USER, [](SBDError* error) {
            if (error != nullptr) {
                // Handle error.
                return;
            }

            // The user is successfully unbanned for the channel.
            // You can notify the user of being unbanned by displaying a message.
        });
    }
});