Ban a list of channel users

When a user is banned in a channel, the user is removed from a channel and no longer able to participate or observe messages in that channel.

Banning and Unbanning

Moderators can ban and unban users. When a user is banned in a channel, the user is forcibly removed from the channel and may no longer participate or observe messages in that channel. All their previous messages in the channel will also be automatically deleted.

A user that has been banned from a channel cannot rejoin the channel until that user has been unbanned.

Global Ban

As well as the banning and unbanning of users, admins also have the ability to global ban a user. When a user is globally banned, they can no longer access Amity's network and will be forcibly removed from all their existing channels. All the globally banned user's messages will also be deleted.

The globally banned user can not access Amity's network again until they have been globally unbanned.

To subscribe to a Global ban/unban event, you may use this sample code:

amityClient.on(‘dataError’, error => console.log(error.code === 400312)) 

When a user is banned, it can take up to 30 seconds before the user is disconnected from the network.

Ban Users

Banning users is a more heavy-handed moderation method. When a user is banned, all its messages are retroactively deleted, it will be removed from the channel, and it will not be allowed to join the channel again until he is explicitly unbanned.

repository.banMembers({
  userIds: ['user1'],
}).catch(error => {
  ...
});

There is a separate unban call to unban a user:

repository.unbanMembers({
  userIds: ['user1'],
}).catch(error => {
  ...
});

This feature does not work with Broadcast and Conversation channels. Calling banUsers() or unBanUsers() on these channels will result in an error.

To subscribe to a Channel ban/unban event, you may use this sample code:

const liveChannel = ChannelRepository.getChannel(“myChanneId”)
liveChannel.on(‘dataError’, error => console.log(error.code === 400312)) 

Last updated