fix: GuildSchedule not being cached correctly + missing fields#3025
fix: GuildSchedule not being cached correctly + missing fields#3025
Conversation
|
Thanks for opening this pull request! This pull request can be checked-out with: git fetch origin pull/3025/head:pr-3025
git checkout pr-3025This pull request can be installed with: pip install git+https://github.com/Pycord-Development/pycord@refs/pull/3025/head |
|
Audit Logs still need to be rework (i didnt understand how it work yet) |
|
should we use use_cache_on_error, instead of only use cache ? that way we will be able to fetch first and if unavailable we will get |
Paillat-dev
left a comment
There was a problem hiding this comment.
If possible, make this pr not interfere with the recurrence one from anonymous. There will probably be merge conflicts once that one is merged, but they shouldn't both implement recurrence in a different way.
Co-authored-by: Paillat <paillat@pycord.dev> Signed-off-by: Lumouille <144063653+Lumabots@users.noreply.github.com>
when anonymous pr will be merged i'll edit it to make it work |
|
@Lumabots Your PR uses utils.deprecated. Use @typing_extensions.deprecated instead. |
| entity_type: ScheduledEventEntityType = MISSING, | ||
| entity_metadata: ScheduledEventEntityMetadata | None = MISSING, | ||
| channel_id: int = MISSING, | ||
| privacy_level: ScheduledEventPrivacyLevel = ScheduledEventPrivacyLevel.guild_only, |
There was a problem hiding this comment.
privacy_level is deprecated and ignored by the api
discord/guild.py
Outdated
| entity_type: ScheduledEventEntityType = MISSING, | ||
| entity_metadata: ScheduledEventEntityMetadata | None = MISSING, | ||
| channel_id: int = MISSING, | ||
| privacy_level: ScheduledEventPrivacyLevel = ScheduledEventPrivacyLevel.guild_only, |
There was a problem hiding this comment.
Here it wasn't added tho so we can't remove it. But you can warn_deprecated @Lumabots when it's not MISSING
There was a problem hiding this comment.
deprecate it and avoid emitting it in calls
|
This pull request does not follow the required pull request template. Please use the default template ( Problems detected: |
Signed-off-by: Paillat <paillat@pycord.dev>
| @typing_extensions.deprecated( | ||
| "location is deprecated since 2.7 and will be removed in 3.0, consider using entity_metadata instead", | ||
| ) | ||
| def location(self) -> ScheduledEventLocation | None: |
There was a problem hiding this comment.
This property never returns anything. Also this can lead to infinite reucrsion (? I think) since it sets self.location inside itself.
| f"creator_id={self.creator_id}>" | ||
| f"channel_id={self.channel_id}>" |
There was a problem hiding this comment.
| f"creator_id={self.creator_id}>" | |
| f"channel_id={self.channel_id}>" | |
| f"creator_id={self.creator_id} " | |
| f"channel_id={self.channel_id}>" |
There was a problem hiding this comment.
Also this uses deprecated attributes like self.location and self.user_count
|
|
||
| async def _fill_from_cache(self): | ||
| """Fill subscribers queue from cached user IDs.""" | ||
| cached_user_ids = list(self.event._cached_subscribers.keys()) |
There was a problem hiding this comment.
event._cached_subscribers is set[int] which doesn't have keys
| "scheduled_start_time": start_time.isoformat(), | ||
| "privacy_level": int(privacy_level), | ||
| "scheduled_start_time": scheduled_start_time.isoformat(), | ||
| "entity_type": int(entity_type), |
There was a problem hiding this comment.
This could be missing which would lead here to an error bc of int(MISSING)
| def location(self) -> ScheduledEventLocation | None: | ||
| """Returns the location of the event.""" | ||
| if self.channel_id is None: | ||
| self.location = ScheduledEventLocation( |
There was a problem hiding this comment.
So basically this is deprecated but then it means accessing the deprecated .location will cause two warnings. Maybe add an _internal: True which doesn't warn_deprecated in the init or something.

Summary
summary is not complete, just check the code
Added
New Enums :
ScheduledEventRecurrenceFrequency (yearly, monthly, weekly, daily)
ScheduledEventRecurrenceWeekday (monday-sunday)
ScheduledEventRecurrenceMonth (january-december)
New Classes:
ScheduledEventEntityMetadata (location)
ScheduledEventRecurrenceNWeekday Represents n-weekday entries (e.g., "1st Tuesday")
ScheduledEventRecurrenceRule: Full recurrence rule with validation
Auto-validates on to_payload() serialization
New fields Guild.create_scheduled_event():
Enforces Discord's constraints:
Information
examples, ...).
Checklist
type: ignorecomments were used, a comment is also left explaining why.