#[non_exhaustive]pub struct RecurrenceRuleData {
pub start: Timestamp,
pub frequency: RecurrenceFrequency,
pub interval: u16,
pub by_weekday: Vec<RecurrenceWeekday>,
pub by_n_weekday: Vec<RecurrenceNWeekday>,
pub by_month: Vec<RecurrenceMonth>,
pub by_month_day: Vec<u8>,
}Expand description
How a scheduled event repeats, as sent to Discord (D-124): the settable fields of a
RecurrenceRule.
Discord accepts only some combinations; the constructors build exactly those shapes:
daily, daily_on (a known set of weekdays),
weekly, every_other_week,
monthly (the n-th weekday) and yearly.
From<RecurrenceRule> keeps the rule of
an existing event.
discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions.
§Examples
use djs_model::{
guild_scheduled_event::RecurrenceWeekday, rest::RecurrenceRuleData, util::Timestamp,
};
let start = Timestamp::parse("2026-11-17T18:00:00Z")?;
let rule = RecurrenceRuleData::monthly(start, 3, RecurrenceWeekday::Tuesday);
assert_eq!(
serde_json::to_string(&rule)?,
r#"{"start":"2026-11-17T18:00:00.000000+00:00","frequency":1,"interval":1,"by_n_weekday":[{"n":3,"day":1}]}"#
);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.start: TimestampWhen the recurrence starts (the first occurrence).
frequency: RecurrenceFrequencyHow often the event repeats.
interval: u16The spacing between occurrences in units of frequency; only weekly events may use 2.
by_weekday: Vec<RecurrenceWeekday>The weekdays to repeat on (daily: a known set; weekly: one day).
by_n_weekday: Vec<RecurrenceNWeekday>The n-th weekday of the month to repeat on (monthly: one entry).
by_month: Vec<RecurrenceMonth>The month to repeat in (yearly: one entry, with by_month_day).
by_month_day: Vec<u8>The day of the month to repeat on (yearly: one entry, with by_month).
Implementations§
Source§impl RecurrenceRuleData
impl RecurrenceRuleData
Sourcepub const fn daily(start: Timestamp) -> Self
pub const fn daily(start: Timestamp) -> Self
Every day.
discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Daily.
Sourcepub fn daily_on(
start: Timestamp,
days: impl IntoIterator<Item = RecurrenceWeekday>,
) -> Self
pub fn daily_on( start: Timestamp, days: impl IntoIterator<Item = RecurrenceWeekday>, ) -> Self
Every day of a set of weekdays. Discord accepts these sets only: Monday–Friday, Tuesday–Saturday, Sunday–Thursday, Friday and Saturday, Saturday and Sunday, Sunday and Monday.
discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Daily and byWeekday.
Sourcepub fn weekly(start: Timestamp, day: RecurrenceWeekday) -> Self
pub fn weekly(start: Timestamp, day: RecurrenceWeekday) -> Self
Every week on day.
discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Weekly.
Sourcepub fn every_other_week(start: Timestamp, day: RecurrenceWeekday) -> Self
pub fn every_other_week(start: Timestamp, day: RecurrenceWeekday) -> Self
Every other week on day.
discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Weekly and interval: 2.
Sourcepub fn monthly(start: Timestamp, n: u8, day: RecurrenceWeekday) -> Self
pub fn monthly(start: Timestamp, n: u8, day: RecurrenceWeekday) -> Self
Every month on the n-th (1-5) day, e.g. the third Tuesday.
discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Monthly.
Sourcepub fn yearly(start: Timestamp, month: RecurrenceMonth, day: u8) -> Self
pub fn yearly(start: Timestamp, month: RecurrenceMonth, day: u8) -> Self
Every year on day of month.
discord.js counterpart: GuildScheduledEventRecurrenceRuleOptions with frequency: Yearly.
Trait Implementations§
Source§impl Clone for RecurrenceRuleData
impl Clone for RecurrenceRuleData
Source§impl Debug for RecurrenceRuleData
impl Debug for RecurrenceRuleData
impl Eq for RecurrenceRuleData
Source§impl From<RecurrenceRule> for RecurrenceRuleData
impl From<RecurrenceRule> for RecurrenceRuleData
Source§fn from(rule: RecurrenceRule) -> Self
fn from(rule: RecurrenceRule) -> Self
Keeps the settable fields of an existing rule (not end, count, by_year_day).