Freezing Channels

LAST EDIT Apr 08 2021

Freezing a channel will disallow sending new messages and sending / deleting reactions. Sending a message to a frozen channel will return a message of type error. Sending and deleting reactions to frozen channels will result in a 403 Not Allowed error. User roles with the UseFrozenChannel permission are still able to use frozen channels as if they weren't frozen. By default no user role has the UseFrozenChannel permission.

Freeze a channel

1
2
3
4
const update = await channel.update( 
	{ frozen: true },  
	{ text: 'Thierry has frozen the channel', user_id: "Thierry" } 
)

Unfreeze a channel

1
2
3
4
const update = await channel.update( 
	{ frozen: false },  
	{ text: 'Thierry has unfrozen the channel', user_id: "Thierry" } 
)

Grant the UseFrozenChannel permission

Since by default no role has the UseFrozenChannel resource permission, you can edit the channel type to grant the permission to a role (this is only allowed via server side API calls). Read more about user permissions here

1
2
3
4
const useFrozenChannel = new Permission("Admin users can use frozen channels", 600, ["UseFrozenChannel"], ["admin"], false, Allow);  
const { permissions } = await client.getChannelType("messaging"); 
permissions.push(useFrozenChannel); 
await client.updateChannelType("messaging", { permissions });