ModerationRulesBuilder.banKeywords constructor

ModerationRulesBuilder.banKeywords({
  1. required String label,
  2. required List<ModerationAction> actions,
  3. required ModerationTriggerMetadata? triggerMetadata,
  4. List<Snowflake>? exemptRoles,
  5. List<Snowflake>? exemptChannels,
  6. bool enabled = true,
})

Create a new moderation rule for Guild that triggers when a user send a message with a blacklisted word.

Implementation

factory ModerationRulesBuilder.banKeywords ({ required String label, required List<ModerationAction> actions, required ModerationTriggerMetadata? triggerMetadata, List<Snowflake>? exemptRoles, List<Snowflake>? exemptChannels, bool enabled = true }) {
  if (exemptRoles != null && exemptRoles.length > 50) {
    throw TooManyException('You cannot define more than 50 roles in the exclusion zone of the moderation rule.');
  }

  if (exemptChannels != null && exemptChannels.length > 20) {
    throw TooManyException('You cannot define more than 20 channels in the exclusion zone of the moderation rule.');
  }

  return ModerationRulesBuilder(
    label,
    ModerationEventType.messageSend,
    ModerationTriggerType.keywords,
    exemptRoles ?? [],
    exemptChannels ?? [],
    enabled,
    actions,
    triggerMetadata,
  );
}