Automatic message deletion scheduler.
Manages timed message deletions using the BEAM's timer wheel — efficient for thousands of concurrent timers with zero per-timer process overhead.
How it works
schedule/3registers a deletion viaProcess.send_after(O(1) insert)- When the timer fires, a Task is spawned to call
Message.deletewith low priority so deletions never starve important API calls - The existing
EDA.HTTP.RateLimiterhandles 429s automatically
Usage
Typically used via the delete_after: option on message creation:
EDA.API.Message.create(channel_id, content: "Temporary!", delete_after: 10_000)Or directly:
EDA.AutoDelete.schedule(channel_id, message_id, 30_000)
Summary
Functions
Returns a specification to start this module under a supervisor.
Schedules a message for deletion after delay_ms milliseconds.
Schedules an interaction response for deletion after delay_ms milliseconds.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec schedule(String.t(), String.t(), non_neg_integer() | nil) :: :ok
Schedules a message for deletion after delay_ms milliseconds.
This is a non-blocking cast. The deletion will be executed asynchronously
via Task.Supervisor with low priority through the rate limiter.
Does nothing if delay_ms is nil.
Examples
EDA.AutoDelete.schedule("channel_id", "message_id", 30_000)
@spec schedule_interaction_response(String.t(), String.t(), non_neg_integer() | nil) :: :ok
Schedules an interaction response for deletion after delay_ms milliseconds.
Uses the interaction token to delete the original response — works for both
ephemeral and non-ephemeral responses. Unlike schedule/3, this doesn't need
a message ID since interaction responses are deleted via their token.
Does nothing if delay_ms is nil.
Examples
EDA.AutoDelete.schedule_interaction_response(app_id, token, 10_000)