-
-
Notifications
You must be signed in to change notification settings - Fork 493
fix: GuildSchedule not being cached correctly + missing fields #3025
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
base: master
Are you sure you want to change the base?
Changes from 10 commits
43227c4
fe47678
fff9b3b
9e6a986
7b2c31f
5a2581e
973a3d2
9d1d5d7
8c85a05
40d79b6
b5dc3e9
405f2c6
13420ce
469a7b5
a2f09fe
7e42577
1c50c9e
2ff8daf
6dfd511
7fdf52e
bafd549
8f887d3
6772e09
79194b5
70c37cb
2800a08
b9ddb02
7b4f7f5
44fbd76
a548783
a594faa
294dc39
ef960ff
8c4c395
b1bbf52
ddd0c0e
28b4682
c78136d
7022e67
b86cd07
124169b
8cd3495
61078d3
45c2beb
425be22
b01dbcf
207396e
fd65324
38e0034
4742b65
fe312f0
44ae828
e216d2e
ea24bd3
373c815
c8536da
cc87293
d87c944
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -58,15 +58,21 @@ | |
| NotificationLevel, | ||
| NSFWLevel, | ||
| OnboardingMode, | ||
| ScheduledEventLocationType, | ||
| ScheduledEventEntityType, | ||
| ScheduledEventPrivacyLevel, | ||
| SortOrder, | ||
| VerificationLevel, | ||
| VideoQualityMode, | ||
| VoiceRegion, | ||
| try_enum, | ||
| ) | ||
| from .errors import ClientException, HTTPException, InvalidArgument, InvalidData | ||
| from .errors import ( | ||
| ClientException, | ||
| HTTPException, | ||
| InvalidArgument, | ||
| InvalidData, | ||
| ValidationError, | ||
| ) | ||
| from .file import File | ||
| from .flags import SystemChannelFlags | ||
| from .incidents import IncidentsData | ||
|
|
@@ -84,7 +90,11 @@ | |
| from .onboarding import Onboarding | ||
| from .permissions import PermissionOverwrite | ||
| from .role import Role, RoleColours | ||
| from .scheduled_events import ScheduledEvent, ScheduledEventLocation | ||
| from .scheduled_events import ( | ||
| ScheduledEvent, | ||
| ScheduledEventEntityMetadata, | ||
| ScheduledEventRecurrenceRule, | ||
| ) | ||
| from .soundboard import SoundboardSound | ||
| from .stage_instance import StageInstance | ||
| from .sticker import GuildSticker | ||
|
|
@@ -4213,36 +4223,49 @@ async def create_scheduled_event( | |
| *, | ||
| name: str, | ||
| description: str = MISSING, | ||
| start_time: datetime.datetime, | ||
| end_time: datetime.datetime = MISSING, | ||
| location: str | int | VoiceChannel | StageChannel | ScheduledEventLocation, | ||
| scheduled_start_time: datetime.datetime, | ||
| scheduled_end_time: datetime.datetime = MISSING, | ||
| entity_type: ScheduledEventEntityType, | ||
| entity_metadata: ScheduledEventEntityMetadata | None = MISSING, | ||
| channel_id: int = MISSING, | ||
| privacy_level: ScheduledEventPrivacyLevel = ScheduledEventPrivacyLevel.guild_only, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. see above
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here it wasn't added tho so we can't remove it. But you can
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. deprecate it and avoid emitting it in calls |
||
| reason: str | None = None, | ||
| image: bytes = MISSING, | ||
| recurrence_rule: ScheduledEventRecurrenceRule | None = MISSING, | ||
| ) -> ScheduledEvent | None: | ||
| """|coro| | ||
| Creates a scheduled event. | ||
|
|
||
| For EXTERNAL events, ``entity_metadata`` with a location and ``end_time`` are required. | ||
| For STAGE_INSTANCE or VOICE events, ``channel_id`` is required. | ||
|
|
||
| Parameters | ||
| ---------- | ||
| name: :class:`str` | ||
| The name of the scheduled event. | ||
| description: Optional[:class:`str`] | ||
| The description of the scheduled event. | ||
| start_time: :class:`datetime.datetime` | ||
| scheduled_start_time: :class:`datetime.datetime` | ||
| A datetime object of when the scheduled event is supposed to start. | ||
| end_time: Optional[:class:`datetime.datetime`] | ||
| scheduled_end_time: Optional[:class:`datetime.datetime`] | ||
| A datetime object of when the scheduled event is supposed to end. | ||
| location: :class:`ScheduledEventLocation` | ||
| The location of where the event is happening. | ||
| Required for EXTERNAL events. | ||
| entity_type: :class:`ScheduledEventEntityType` | ||
| The type of scheduled event (STAGE_INSTANCE, VOICE, or EXTERNAL). | ||
| entity_metadata: Optional[:class:`ScheduledEventEntityMetadata`] | ||
| The entity metadata (required for EXTERNAL events with a location). | ||
| channel_id: Optional[Union[:class:`int`, :class:`VoiceChannel`, :class:`StageChannel`]] | ||
| The channel ID for STAGE_INSTANCE or VOICE events. | ||
| Can be a channel object or a snowflake ID. | ||
| privacy_level: :class:`ScheduledEventPrivacyLevel` | ||
| The privacy level of the event. Currently, the only possible value | ||
| is :attr:`ScheduledEventPrivacyLevel.guild_only`, which is default, | ||
| so there is no need to change this parameter. | ||
| is :attr:`ScheduledEventPrivacyLevel.guild_only`, which is default. | ||
| reason: Optional[:class:`str`] | ||
| The reason to show in the audit log. | ||
| image: Optional[:class:`bytes`] | ||
| The cover image of the scheduled event | ||
| recurrence_rule: Optional[Union[:class:`ScheduledEventRecurrenceRule`, :class:`dict`]] | ||
| The definition for how often this event should recur. | ||
|
|
||
| Returns | ||
| ------- | ||
|
|
@@ -4255,34 +4278,55 @@ async def create_scheduled_event( | |
| You do not have the Manage Events permission. | ||
| HTTPException | ||
| The operation failed. | ||
| ValidationError | ||
| Invalid parameters for the event type. | ||
| """ | ||
| payload: dict[str, str | int] = { | ||
|
Lumabots marked this conversation as resolved.
Outdated
|
||
| "name": name, | ||
| "scheduled_start_time": start_time.isoformat(), | ||
| "scheduled_start_time": scheduled_start_time.isoformat(), | ||
| "privacy_level": int(privacy_level), | ||
| "entity_type": int(entity_type), | ||
|
Lumabots marked this conversation as resolved.
Outdated
|
||
| } | ||
|
|
||
| if not isinstance(location, ScheduledEventLocation): | ||
| location = ScheduledEventLocation(state=self._state, value=location) | ||
|
|
||
| payload["entity_type"] = location.type.value | ||
|
|
||
| if location.type == ScheduledEventLocationType.external: | ||
| payload["channel_id"] = None | ||
| payload["entity_metadata"] = {"location": location.value} | ||
| else: | ||
| payload["channel_id"] = location.value.id | ||
| payload["entity_metadata"] = None | ||
| if scheduled_end_time is not MISSING: | ||
| payload["scheduled_end_time"] = scheduled_end_time.isoformat() | ||
|
|
||
| if description is not MISSING: | ||
| payload["description"] = description | ||
|
|
||
| if end_time is not MISSING: | ||
| payload["scheduled_end_time"] = end_time.isoformat() | ||
|
|
||
| if image is not MISSING: | ||
| payload["image"] = utils._bytes_to_base64_data(image) | ||
|
|
||
| if recurrence_rule is not MISSING: | ||
| if recurrence_rule is None: | ||
| payload["recurrence_rule"] = None | ||
| else: | ||
| payload["recurrence_rule"] = recurrence_rule.to_payload() | ||
|
|
||
| if entity_type == ScheduledEventEntityType.external: | ||
| if entity_metadata is MISSING or entity_metadata is None: | ||
|
Lumabots marked this conversation as resolved.
|
||
| raise ValidationError( | ||
| "entity_metadata with a location is required for EXTERNAL events." | ||
|
Lumabots marked this conversation as resolved.
Outdated
|
||
| ) | ||
| if not entity_metadata.location: | ||
| raise ValidationError( | ||
| "entity_metadata.location cannot be empty for EXTERNAL events." | ||
| ) | ||
| if scheduled_end_time is MISSING: | ||
| raise ValidationError( | ||
| "scheduled_end_time is required for EXTERNAL events." | ||
| ) | ||
|
|
||
| payload["channel_id"] = None | ||
| payload["entity_metadata"] = entity_metadata.to_payload() | ||
| else: | ||
| if channel_id is MISSING: | ||
| raise ValidationError( | ||
| "channel_id is required for STAGE_INSTANCE and VOICE events." | ||
| ) | ||
|
|
||
| payload["channel_id"] = channel_id | ||
|
|
||
| data = await self._state.http.create_scheduled_event( | ||
| guild_id=self.id, reason=reason, **payload | ||
| ) | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.