setTriggerMetadata method

Future<void> setTriggerMetadata(
  1. ModerationTriggerMetadata triggerMetadata, {
  2. String? reason,
})

Update the trigger metadata of this

Example :

final metadata = ModerationTriggerMetadata(
  keywordFilter: ['foo'],
  presets: [ModerationPresetType.profanity]
);

await rule.setTriggerMetadata(metadata);

Implementation

Future<void> setTriggerMetadata(ModerationTriggerMetadata triggerMetadata, { String? reason }) async {
  Response response = await ioc.use<DiscordApiHttpService>().patch(url: "/guilds/$guildId/auto-moderation/rules/$id")
    .payload({ 'trigger_metadata': triggerMetadata.toJson() })
    .auditLog(reason)
    .build();

  if (response.statusCode == 200) {
    this.triggerMetadata = triggerMetadata;
  }
}