setActions method

Future<void> setActions(
  1. List<ModerationAction> actions, {
  2. String? reason,
})

Update actions of this

Example :

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

final action = ModerationAction(
  metadata: ModerationActionMetadata(duration: 3000, channel: channel),
  type: ModerationActionType.sendAlertMessage
);

await rule.setActions([action]);

Implementation

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

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