Skip to main content

Actions Reference

This document provides an exhaustive list of all actions supported by Modegator's execution engine, along with the specific properties they accept.

Every action in an actions or fallback_actions array must specify a type. Depending on the type, other properties become required or optional.


Dynamic Placeholders

Modegator supports the interpolation of dynamic placeholders inside specific YAML string properties. This mechanism allows rules, UI actions, and scheduled tasks to personalize user interactions, construct context-specific keys for the Redis state engine, or dynamically target communication recipients at execution time.

Syntax Specification

Placeholders are evaluated using the double-curly-braces syntax:

{{ placeholder_name }}

During execution, if a property supports placeholder resolution, any matching patterns are replaced by their corresponding value derived from the triggering event's context.

Pipeline Filters

Resolved values can be modified prior to insertion by applying one or more pipeline filters. Filters are appended to the placeholder name separated by a pipe (|) character:

{{ placeholder_name | filter1 | filter2 }}

The execution engine supports the following formatting filters:

  • lowercase: Transforms all alphabetical characters in the value to lowercase (e.g., {{author | lowercase}} resolves YashArote to yasharote).
  • uppercase: Transforms all alphabetical characters in the value to uppercase (e.g., {{subreddit | uppercase}} resolves Modegator to MODEGATOR).
  • trim: Strips leading and trailing whitespace characters from the value.

These filters can be chained sequentially in left-to-right order (e.g., {{post_title | trim | lowercase}}).

Supported Properties

The following action properties support dynamic placeholder interpolation:

PropertyDescriptionExample Target
toRecipient username for direct messages or modmail conversations. This field supports full placeholder resolution (e.g., targeting a post author dynamically via {{author}}).to: "{{author}}"
textMarkdown text content of submitted comments or modmail replies.text: "Hi u/{{author}}, welcome!"
subjectSubject line of private messages or modmail threads.subject: "Alert regarding post: {{post_id}}"
bodyMain text body of private messages or modmail threads.body: "Your post titled '{{post_title}}' was reviewed."
reasonInternal ban reason logged in moderation history.reason: "Repetitive posts by {{author}}"
messageBan notification message delivered to the banned user.message: "You have been banned from r/{{subreddit}}."
mod_noteInternal note attached to a user's subreddit ban record.mod_note: "Banned on {{date}} at {{time}}"
noteText content of a Reddit-native moderator profile note.note: "Solid contributor since {{date}}"
keyIdentifier key used in state management actions (store_value and increment_counter).key: "user_warnings_{{author}}"
domainTarget domain name for marking link domains.domain: "{{post_domain}}"
urlDestination URL for external HTTP webhook payloads.url: "https://logs.example.com/webhook/{{subreddit}}"

Variable Reference Index

The following table documents all available placeholder variables accessible within the execution environment:

VariableData TypeContext Resolution
{{author}}
{{author_name}}
stringThe Reddit username of the user who triggered the event.
{{author_karma}}numberThe total numeric karma score of the triggering author.
{{author_age_days}}numberThe age of the triggering author's account, measured in days.
{{post_id}}stringThe unique Reddit ID of the associated post (e.g., t3_xyz123).
{{post_title}}stringThe text title of the associated post.
{{post_url}}stringThe canonical URL link of the associated post.
{{post_domain}}stringThe domain name of the submitted link (if the post is a link post).
{{post_flair}}stringThe current text value of the post's flair.
{{comment_id}}stringThe unique Reddit ID of the associated comment (e.g., t1_abc456).
{{comment_body}}stringThe text content of the comment (truncated to the first 500 characters).
{{subreddit}}stringThe name of the subreddit where the event occurred.
{{report_reason}}stringThe reason provided in the report (only available for report-triggered events).
{{date}}stringThe current date in UTC, formatted as YYYY-MM-DD.
{{time}}stringThe current time in UTC, formatted as HH:MM.

Post Actions

These actions modify Reddit posts.

  • remove_post: Removes the target post.
    • spam (boolean): If true, flags the removal as spam in the spam filter (default: false).
  • approve_post: Approves the post, removing it from the spam filter/mod queue.
  • lock_post: Locks the post to prevent new comments.
  • unlock_post: Unlocks the post.
  • set_post_flair: Applies flair to the post.
    • flair_text (string): The plain text of the flair.
    • flair_css_class (string): A CSS class from the subreddit stylesheet to apply to the flair.
    • color (string, optional): The flair background color. Use a named color (red, orange, yellow, green, blue, gray) or a hex value (e.g. '#FF4500').
    • text_color (string, optional): The flair text color. Either 'dark' or 'light'.
  • mark_post_nsfw: Marks the post as Not Safe For Work (NSFW).
  • unmark_post_nsfw: Removes the NSFW tag.
  • mark_post_spoiler: Marks the post as a spoiler.
  • unmark_post_spoiler: Removes the spoiler tag.

Comment Actions

These actions modify Reddit comments.

  • remove_comment: Removes the target comment.
    • spam (boolean): If true, flags it as spam (default: false).
  • approve_comment: Approves the comment.
  • lock_comment: Locks the comment to prevent replies.
  • submit_comment: Replies to the target item (supports posts or comments).
    • text (string): The body of the comment (supports placeholders).
    • distinguish (boolean): If true, distinguishes the comment as moderator-distinguished (default: false).
    • sticky (boolean): If true and replying to a post, stickies the comment to the top of the thread (default: false).

User Actions

These actions modify user permissions and flairs within the subreddit.

  • ban_user: Bans the author of the triggering event.
    • duration (number | "permanent"): Ban duration in days or "permanent".
    • reason (string): Internal ban reason logged in Mod Tools (supports placeholders).
    • message (string): Ban notification message sent to the user (supports placeholders).
    • mod_note (string): Internal mod note attached to the ban record (supports placeholders).
  • unban_user: Unbans the user.
  • mute_user: Mutes the user in Modmail for 3 days.
  • unmute_user: Unmutes the user in Modmail.
  • set_user_flair: Sets the user's flair in the subreddit.
    • flair_text (string): The plain text of the flair.
    • flair_css_class (string, optional): A CSS class from the subreddit stylesheet.
    • color (string, optional): The flair background color. Named color or hex value (see set_post_flair above).
    • text_color (string, optional): Either 'dark' or 'light'.
  • clear_user_flair: Clears the user's flair.
  • approve_user: Adds the user as an Approved Submitter.
  • remove_approval: Removes Approved Submitter status.
  • add_mod_note: Appends a Reddit native Mod Note to the user's profile.
    • label (string, required): Must be one of the following exact strings:
      • BOT_BAN
      • PERMA_BAN
      • BAN
      • ABUSE_WARNING
      • SPAM_WARNING
      • SPAM_WATCH
      • SOLID_CONTRIBUTOR
      • HELPFUL_USER
    • note (string, required): The text content of the note (supports placeholders).

Communication Actions

  • send_modmail (or sendmodmail): Sends a new Modmail conversation.
    • to (string, optional): The target recipient. Defaults to the author of the triggering item. (Note: Must be explicitly provided if run from a Scheduled Task cron context).
    • subject (string): The Modmail subject line (supports placeholders).
    • body (string): The Modmail body text (supports placeholders).
    • hidden (boolean): If true, hides the moderator's username, sending it as the subreddit (default: false).
  • reply_modmail: Replies to the current Modmail thread. (Note: Only valid in rules triggered by ModMail event).
    • text (string): The reply content (supports placeholders).
    • internal (boolean): If true, posts the reply as a private Moderator Note inside the modmail thread instead of sending it to the user (default: false).
    • hidden (boolean): Hides the moderator's username (default: false).
  • send_private_message: Sends a direct private message.
    • to (string, optional): Recipient username. Defaults to the event author. (Note: Required in Scheduled Task cron contexts).
    • subject (string): The message subject (supports placeholders).
    • body (string): The message body (supports placeholders).
  • send_webhook: Sends a payload to an external HTTP webhook.
    • url (string): The full target webhook URL (e.g., https://discord.com/api/webhooks/...).
    • message (string, optional): The simple text message payload. If provided without a custom payload, Modegator automatically formats it to match both Discord and Slack JSON specs ({"content": "...", "text": "..."}).
    • headers (object, optional): A dictionary of custom HTTP headers to pass along (e.g., Authorization: "Bearer {{custom_token}}"). Supports deep placeholder interpolation.
    • payload (object, optional): A custom raw JSON payload to send in the HTTP body (e.g., custom Discord Embeds). Fully overrides the default message formatting. Supports deep placeholder interpolation.
    • Note: Target domains must be whitelisted under permissions.http.domains in your devvit.json file and approved by Reddit Admins.

State & Storage Actions

These actions are useful for tracking data across events.

  • store_value: Saves a persistent key-value string in Redis.
    • key (string): The key to write to (creates a database entry under your custom key name).
    • value (string): The text to store.
  • increment_counter: Increments a Redis counter by 1.
    • key (string): The key of the counter (creates a database counter entry under your custom key name).
  • tag_domain: Tags a link domain with a visual tag in the dashboard.
    • domain (string): The target domain (e.g. example.com). Supports placeholders (e.g. {{post_domain}}).
    • tag (string): The text tag to assign (e.g. Spam Site, Under Review).

Control Flow Actions

  • run_macro: Evaluates a predefined macro.
    • macro (string): The name of the macro.
  • if: Conditionally executes a nested block of actions.
    • conditions (array): An array of logical conditions to evaluate.
    • then (array): An array of actions to execute if the conditions evaluate to true.
  • stop_if: Halts further execution in the current action sequence (Rule, UI Action, Macro, or Scheduler).
    • conditions (array, optional): An array of logical conditions (supports any_of, all_of, etc.). Execution only halts if these conditions evaluate to true. If omitted, execution halts unconditionally.
  • delay: Pauses execution.
    • duration_ms (number): Milliseconds to wait before executing subsequent actions.