Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -3201,6 +3201,7 @@ async def create_scheduled_event(
end_time: datetime.datetime = ...,
description: str = ...,
image: bytes = ...,
recurrence_rule: str = ...,
reason: Optional[str] = ...,
) -> ScheduledEvent:
...
Expand All @@ -3217,6 +3218,7 @@ async def create_scheduled_event(
end_time: datetime.datetime = ...,
description: str = ...,
image: bytes = ...,
recurrence_rule: str = ...,
reason: Optional[str] = ...,
) -> ScheduledEvent:
...
Expand All @@ -3232,6 +3234,7 @@ async def create_scheduled_event(
end_time: datetime.datetime = ...,
description: str = ...,
image: bytes = ...,
recurrence_rule: str = ...,
reason: Optional[str] = ...,
) -> ScheduledEvent:
...
Expand All @@ -3247,6 +3250,7 @@ async def create_scheduled_event(
end_time: datetime.datetime = ...,
description: str = ...,
image: bytes = ...,
recurrence_rule: str = ...,
reason: Optional[str] = ...,
) -> ScheduledEvent:
...
Expand All @@ -3263,6 +3267,7 @@ async def create_scheduled_event(
end_time: datetime.datetime = MISSING,
description: str = MISSING,
image: bytes = MISSING,
recurrence_rule: str = MISSING,
reason: Optional[str] = None,
) -> ScheduledEvent:
r"""|coro|
Expand Down Expand Up @@ -3308,6 +3313,9 @@ async def create_scheduled_event(
The location of the scheduled event.

Required if the ``entity_type`` is :attr:`EntityType.external`.
recurrence_rule: :class:`str`
The recurrence rule for the scheduled event in iCalendar format.
This determines how often the event repeats.
reason: Optional[:class:`str`]
The reason for creating this scheduled event. Shows up on the audit log.

Expand Down Expand Up @@ -3377,6 +3385,9 @@ async def create_scheduled_event(
image_as_str: str = utils._bytes_to_base64_data(image)
payload['image'] = image_as_str

if recurrence_rule is not MISSING:
payload['recurrence_rule'] = recurrence_rule

if entity_type in (EntityType.stage_instance, EntityType.voice):
if channel in (MISSING, None):
raise TypeError('channel must be set when entity_type is voice or stage_instance')
Expand Down
15 changes: 15 additions & 0 deletions discord/scheduled_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ class ScheduledEvent(Hashable):
.. versionadded:: 2.2
location: Optional[:class:`str`]
The location of the scheduled event.
recurrence_rule: Optional[:class:`str`]
The recurrence rule for the scheduled event in iCalendar format.
This determines how often the event repeats.
"""

__slots__ = (
Expand All @@ -125,6 +128,7 @@ class ScheduledEvent(Hashable):
'channel_id',
'creator_id',
'location',
'recurrence_rule',
)

def __init__(self, *, state: ConnectionState, data: GuildScheduledEventPayload) -> None:
Expand All @@ -145,6 +149,7 @@ def _update(self, data: GuildScheduledEventPayload) -> None:
self._cover_image: Optional[str] = data.get('image', None)
self.user_count: int = data.get('user_count', 0)
self.creator_id: Optional[int] = _get_as_snowflake(data, 'creator_id')
self.recurrence_rule: Optional[str] = data.get('recurrence_rule')

creator = data.get('creator')
self.creator: Optional[User] = self._state.store_user(creator) if creator else None
Expand Down Expand Up @@ -343,6 +348,7 @@ async def edit(
status: EventStatus = ...,
image: bytes = ...,
location: str,
recurrence_rule: str = ...,
reason: Optional[str] = ...,
) -> ScheduledEvent:
...
Expand All @@ -359,6 +365,7 @@ async def edit(
privacy_level: PrivacyLevel = ...,
status: EventStatus = ...,
image: bytes = ...,
recurrence_rule: str = ...,
reason: Optional[str] = ...,
) -> ScheduledEvent:
...
Expand All @@ -375,6 +382,7 @@ async def edit(
status: EventStatus = ...,
image: bytes = ...,
location: str,
recurrence_rule: str = ...,
reason: Optional[str] = ...,
) -> ScheduledEvent:
...
Expand All @@ -392,6 +400,7 @@ async def edit(
status: EventStatus = MISSING,
image: bytes = MISSING,
location: str = MISSING,
recurrence_rule: str = MISSING,
reason: Optional[str] = None,
) -> ScheduledEvent:
r"""|coro|
Expand Down Expand Up @@ -439,6 +448,9 @@ async def edit(
The new location of the scheduled event.

Required if the entity type is :attr:`EntityType.external`.
recurrence_rule: :class:`str`
The recurrence rule for the scheduled event in iCalendar format.
This determines how often the event repeats.
reason: Optional[:class:`str`]
The reason for editing the scheduled event. Shows up on the audit log.

Expand Down Expand Up @@ -494,6 +506,9 @@ async def edit(
image_as_str: Optional[str] = _bytes_to_base64_data(image) if image is not None else image
payload['image'] = image_as_str

if recurrence_rule is not MISSING:
payload['recurrence_rule'] = recurrence_rule

entity_type = entity_type or getattr(channel, '_scheduled_event_entity_type', MISSING)
if entity_type is MISSING:
if channel and isinstance(channel, Object):
Expand Down
1 change: 1 addition & 0 deletions discord/types/scheduled_event.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class _BaseGuildScheduledEvent(TypedDict):
creator: NotRequired[User]
user_count: NotRequired[int]
image: NotRequired[Optional[str]]
recurrence_rule: NotRequired[Optional[str]]


class _VoiceChannelScheduledEvent(_BaseGuildScheduledEvent):
Expand Down
1 change: 1 addition & 0 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1306,6 +1306,7 @@ Scheduled Events
- The description is changed.
- The status is changed.
- The image is changed.
- The recurrence rule is changed.

.. versionadded:: 2.0

Expand Down
Loading