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

Guild Scheduled Event Recurrence & Exceptions #9685

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion discord/guild.py
Expand Up @@ -83,7 +83,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, ScheduledEventRecurrence
from .stage_instance import StageInstance
from .threads import Thread, ThreadMember
from .sticker import GuildSticker
Expand Down Expand Up @@ -3003,6 +3003,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence: Optional[ScheduledEventRecurrence] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3019,6 +3020,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence: Optional[ScheduledEventRecurrence] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3034,6 +3036,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence: Optional[ScheduledEventRecurrence] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3049,6 +3052,7 @@ async def create_scheduled_event(
description: str = ...,
image: bytes = ...,
reason: Optional[str] = ...,
recurrence: Optional[ScheduledEventRecurrence] = ...,
) -> ScheduledEvent:
...

Expand All @@ -3065,6 +3069,7 @@ async def create_scheduled_event(
description: str = MISSING,
image: bytes = MISSING,
reason: Optional[str] = None,
recurrence: Optional[ScheduledEventRecurrence] = MISSING,
) -> ScheduledEvent:
r"""|coro|

Expand Down Expand Up @@ -3111,6 +3116,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: Optional[:class:`ScheduledEventRecurrence`]
The recurrence rule this event will follow. If this is `None` then this is
a one-time event.

Raises
-------
Expand Down Expand Up @@ -3205,6 +3213,9 @@ async def create_scheduled_event(
)
payload['scheduled_end_time'] = end_time.isoformat()

if recurrence not in (MISSING, None):
payload['recurrence_rule'] = recurrence.to_dict()

if metadata:
payload['entity_metadata'] = metadata

Expand Down
23 changes: 23 additions & 0 deletions discord/http.py
Expand Up @@ -1985,6 +1985,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 @@ -2038,6 +2039,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 Expand Up @@ -2133,6 +2135,27 @@ def get_scheduled_event_users(
),
params=params,
)

def get_scheduled_event_counts(
self,
guild_id: Snowflake,
guild_scheduled_event_id: Snowflake,
scheduled_event_exception_ids: Tuple[Snowflake, ...]
) -> Response[scheduled_event.GuildScheduledEventExceptionCounts]:
route: str = '/guilds/{guild_id}/scheduled-events/{guild_scheduled_event_id}/users/counts?'

if len(scheduled_event_exception_ids) > 0:
for exception_id in scheduled_event_exception_ids:
route += f"guild_scheduled_event_exception_ids={exception_id}&"

return self.request(
Route(
'GET',
route,
guild_id=guild_id,
guild_scheduled_event_id=guild_scheduled_event_id
)
)

# Application commands (global)

Expand Down