Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Guild Scheduled Event Recurrence #9685

Open
wants to merge 43 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
41706dd
Base commit
DA-344 Dec 14, 2023
1527450
Added eq dunder method to Scheduled Event Exception Counts
DA-344 Dec 16, 2023
8df1460
Reworked everything :pensive:
DA-344 Jun 7, 2024
368eedd
Merge branch 'master' of https://github.com/Rapptz/discord.py into re…
DA-344 Jun 7, 2024
cd5cbc6
........
DA-344 Jun 7, 2024
f1ea23a
space
DA-344 Jun 7, 2024
dd780af
fix imports
DA-344 Jun 7, 2024
ad87962
overloads fix
DA-344 Jun 7, 2024
aa6e4d9
overloads fix
DA-344 Jun 7, 2024
f54ec22
not in (MISSING, None) -> not in MISSING
DA-344 Jun 7, 2024
32e6739
first docs commit
DA-344 Jun 7, 2024
e721c98
idk i guess merge from master
DA-344 Jul 1, 2024
9afda1c
First commit on the new recurrence rule objects
DA-344 Aug 6, 2024
f90431c
Merge branch 'master' of https://github.com/Rapptz/discord.py into re…
DA-344 Aug 6, 2024
96e9be5
fixed as I didnt knew dateutil isnt built-in lmao
DA-344 Aug 6, 2024
29adc26
Add ScheduledEventRecurrenceRule to __all__
DA-344 Aug 6, 2024
c6eea29
ScheduledEvent.recurrence -> ScheduledEvent.recurrence_rule
DA-344 Aug 6, 2024
427f1e8
Docstring fixes
DA-344 Aug 6, 2024
a2c431c
More docstring fixes
DA-344 Aug 6, 2024
478a193
More changes
DA-344 Aug 6, 2024
73ff797
Remove ScheduledEvent.fetch_counts
DA-344 Aug 6, 2024
0f2f84d
Remove get_scheduled_event_counts from HTTPClient and more type fixes
DA-344 Aug 6, 2024
12ec0ac
Fix ScheduledEvent.edit
DA-344 Aug 6, 2024
1ec6ad7
type fixes
DA-344 Aug 6, 2024
8f9c19f
more changes
DA-344 Aug 7, 2024
2418b4c
Docs things
DA-344 Aug 7, 2024
647f6e2
Remove ScheduledEventRecurrenceRule.from_str and related
DA-344 Aug 28, 2024
25234fe
Merge branch 'master' of https://github.com/Rapptz/discord.py into re…
DA-344 Aug 28, 2024
150c9e1
Remove an enum from docs
DA-344 Aug 28, 2024
5ac7368
things
DA-344 Aug 28, 2024
a1988ba
Docstring fixes
DA-344 Aug 28, 2024
b1a053e
_from_data finished...?
DA-344 Aug 28, 2024
1a3310a
typo on docstring
DA-344 Aug 28, 2024
3318ff2
Black
DA-344 Aug 28, 2024
ca53a5c
More black
DA-344 Aug 28, 2024
64f6515
what did i write here lmao
DA-344 Aug 29, 2024
694590e
Merge branch 'master' of https://github.com/Rapptz/discord.py into re…
DA-344 Aug 29, 2024
390e9ac
Fixes
DA-344 Aug 29, 2024
1f84efc
Final nits and examples in recurrence rule
DA-344 Aug 29, 2024
f1c0470
Black
DA-344 Aug 29, 2024
9c53a27
Forgot a quote
DA-344 Aug 29, 2024
94c001a
Add another "
DA-344 Aug 29, 2024
002f18c
Fix ScheduledEvent.users doc
DA-344 Aug 29, 2024
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
19 changes: 19 additions & 0 deletions discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@
'EntitlementType',
'EntitlementOwnerType',
'PollLayoutType',
'ScheduledEventRecurrenceFrequency',
'ScheduledEventRecurrenceWeekday',
)


Expand Down Expand Up @@ -835,6 +837,23 @@ class ReactionType(Enum):
burst = 1


class ScheduledEventRecurrenceFrequency(Enum):
yearly = 0
monthly = 1
weekly = 2
daily = 3


class ScheduledEventRecurrenceWeekday(Enum):
monday = 0
tuesday = 1
wednesday = 2
thursday = 3
friday = 4
saturday = 5
sunday = 6


def create_unknown_value(cls: Type[E], val: Any) -> E:
value_cls = cls._enum_value_cls_ # type: ignore # This is narrowed below
name = f'unknown_{val}'
Expand Down
16 changes: 15 additions & 1 deletion discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
from .asset import Asset
from .flags import SystemChannelFlags
from .integrations import Integration, PartialIntegration, _integration_factory
from .scheduled_event import ScheduledEvent
from .scheduled_event import ScheduledEvent, ScheduledEventRecurrenceRule
from .stage_instance import StageInstance
from .threads import Thread, ThreadMember
from .sticker import GuildSticker
Expand Down Expand Up @@ -3038,6 +3038,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence_rule: Optional[ScheduledEventRecurrenceRule] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3054,6 +3055,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence_rule: Optional[ScheduledEventRecurrenceRule] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3069,6 +3071,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence_rule: Optional[ScheduledEventRecurrenceRule] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3084,6 +3087,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence_rule: Optional[ScheduledEventRecurrenceRule] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3100,6 +3104,7 @@ async def create_scheduled_event(
description: str = MISSING,
image: bytes = MISSING,
reason: Optional[str] = None,
recurrence_rule: Optional[ScheduledEventRecurrenceRule] = MISSING,
) -> ScheduledEvent:
r"""|coro|

Expand Down Expand Up @@ -3146,6 +3151,9 @@ async def create_scheduled_event(
Required if the ``entity_type`` is :attr:`EntityType.external`.
reason: Optional[:class:`str`]
The reason for creating this scheduled event. Shows up on the audit log.
recurrence_rule: Optional[:class:`ScheduledEventRecurrenceRule`]
The recurrence rule this event will follow. If this is ``None`` then this is
a one-time event.

Raises
-------
Expand Down Expand Up @@ -3240,6 +3248,12 @@ async def create_scheduled_event(
)
payload['scheduled_end_time'] = end_time.isoformat()

if recurrence_rule is not MISSING:
if recurrence_rule is not None:
payload['recurrence_rule'] = recurrence_rule._to_dict()
else:
payload['recurrence_rule'] = None

if metadata:
payload['entity_metadata'] = metadata

Expand Down
2 changes: 2 additions & 0 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -2032,6 +2032,7 @@ def create_guild_scheduled_event(
'description',
'entity_type',
'image',
'recurrence_rule',
)
payload = {k: v for k, v in payload.items() if k in valid_keys}

Expand Down Expand Up @@ -2085,6 +2086,7 @@ def edit_scheduled_event(
'description',
'entity_type',
'image',
'recurrence_rule',
)
payload = {k: v for k, v in payload.items() if k in valid_keys}

Expand Down
Loading
Loading