ModerationRulesBuilder.spam constructor

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

Create a new moderation rule for Guild that triggers when a user spam many messages.

Implementation

factory ModerationRulesBuilder.spam ({ required String label, required List<ModerationAction> actions, 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.spam,
    exemptRoles ?? [],
    exemptChannels ?? [],
    enabled,
    actions,
    null
  );
}