setExemptChannels method

Future<void> setExemptChannels(
  1. List<GuildChannel> channels
)

Defines which roles will not be affected by this

Example :

final channel = guild.channels.cache.get('240561194958716924');

if (channel != null) {
  await rule.setExemptChannels([channel]);
}

Implementation

Future<void> setExemptChannels(List<GuildChannel> channels) async {
  int maxItems = 50;
  if (channels.length > maxItems) {
    TooManyException("The list of channels cannot exceed $maxItems items (currently ${channels.length} given)");
  }

  Response response = await ioc.use<HttpService>().patch(url: "/guilds/$guildId/auto-moderation/rules/$id", payload: {
    'exempt_roles': channels.map((GuildChannel channel) => channel.id)
  });

  if (response.statusCode == 200) {
    exemptChannels = channels;
  }
}