From 5ac7368e442ec7777ac02ca2c97b09ce22d8c30c Mon Sep 17 00:00:00 2001 From: Developer Anonymous Date: Wed, 28 Aug 2024 23:31:36 +0200 Subject: [PATCH] things --- discord/scheduled_event.py | 14 ++++++++------ docs/api.rst | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/discord/scheduled_event.py b/discord/scheduled_event.py index 5763e209a..330de7efa 100644 --- a/discord/scheduled_event.py +++ b/discord/scheduled_event.py @@ -96,8 +96,9 @@ class ScheduledEventRecurrenceRule: interval: :class:`int` The spacing between the events, defined by ``frequency``. - For example, a ``frequency`` of :attr:`ScheduledEventRecurrenceFrequency.weekly` and an ``interval`` of ``2`` - will result in an "Every other week" recurrence rule. + For example, a ``frequency`` of :attr:`ScheduledEventRecurrenceFrequency.weekly` and an + ``interval`` of :attr:`ScheduledEventRecurrenceFrequency.weekly` will result in an "Every + other week recurrence rule. weekdays: Optional[List[:class:`ScheduledEventRecurrenceWeekday`]] The weekdays the event will recur on. n_weekdays: Optional[List[Tuple[:class:`int`, :class:`ScheduledEVentRecurrenceWeekday`]]] @@ -174,6 +175,7 @@ class ScheduledEventRecurrenceRule: self._count: Optional[int] = None self._end: Optional[datetime] = None self._year_days: Optional[List[int]] = None + # We will be keeping the MISSING values for future use in _to_dict() self._weekdays: Optional[List[ScheduledEventRecurrenceWeekday]] = weekdays self._n_weekdays: Optional[List[_NWeekday]] = n_weekdays self._month_days: Optional[List[date]] = month_days @@ -288,12 +290,12 @@ class ScheduledEventRecurrenceRule: by_year_day: Optional[List[int]] = None if self._weekdays not in (MISSING, None): - by_weekday = self._weekdays + by_weekday = [w.value for w in self._weekdays] if self._n_weekdays not in (MISSING, None): by_n_weekday = [ {'n': n, 'day': day} for n, day in self._n_weekdays - ] + ] # type: ignore if self._month_days not in (MISSING, None): by_month = [] @@ -309,7 +311,7 @@ class ScheduledEventRecurrenceRule: return { 'start': self.start.isoformat(), 'end': self._end.isoformat() if self._end is not None else None, - 'frequency': self.frequency, + 'frequency': self.frequency.value, 'interval': self.interval, 'by_weekday': by_weekday, 'by_n_weekday': by_n_weekday, @@ -325,7 +327,7 @@ class ScheduledEventRecurrenceRule: start=parse_time(data['start']), frequency=data['frequency'], interval=data['interval'], - ) + ) # type: ignore self._count = data.get('count') self._year_days = data.get('by_year_day') diff --git a/docs/api.rst b/docs/api.rst index ad065ebee..bfc08836b 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -3686,6 +3686,42 @@ of :class:`enum.Enum`. The event repeats daily. +.. class:: ScheduledEventRecurrenceWeekday + + Represents the weekdays a scheduled event recurrence rule accepts. + + .. versionadded:: 2.5 + + .. attribute:: monday + + The ``0`` day of the week. + + .. attribute:: tuesday + + The ``1`` day of the week. + + .. attribute:: wednesday + + The ``2`` day of the week. + + .. attribute:: thursday + + The ``3`` day of the week. + + .. attribute:: friday + + The ``4`` day of the week. + + .. attribute:: saturday + + The ``5`` day of the week. + + .. attribute:: sunday + + + The ``6`` day of the week. + + .. _discord-api-audit-logs: Audit Log Data