|
3 | 3 |
|
4 | 4 | from ...client.models.component import ActionRow, Button, SelectMenu, _build_components |
5 | 5 | from .channel import Channel, ThreadMember |
| 6 | +from .guild import EventMetadata |
6 | 7 | from .member import Member |
7 | 8 | from .message import Embed, Emoji, Message, MessageInteraction, Sticker |
8 | 9 | from .misc import MISSING, ClientStatus, DictSerializerMixin, File, Snowflake |
@@ -571,6 +572,97 @@ def __init__(self, **kwargs): |
571 | 572 | ) |
572 | 573 |
|
573 | 574 |
|
| 575 | +class GuildScheduledEvent(DictSerializerMixin): |
| 576 | + """ |
| 577 | + A class object representing gateway events ``GUILD_SCHEDULED_EVENT_CREATE``, ``GUILD_SCHEDULED_EVENT_UPDATE``, ``GUILD_SCHEDULED_EVENT_DELETE``. |
| 578 | +
|
| 579 | + .. note:: |
| 580 | + Some attributes are optional via creator_id/creator implementation by the API: |
| 581 | + "`creator_id` will be null and `creator` will not be included for events created before October 25th, 2021, when the concept of `creator_id` was introduced and tracked." |
| 582 | +
|
| 583 | + :ivar Snowflake id: The ID of the scheduled event. |
| 584 | + :ivar Snowflake guild_id: The ID of the guild that this scheduled event belongs to. |
| 585 | + :ivar Optional[Snowflake] channel_id?: The channel ID in which the scheduled event belongs to, if any. |
| 586 | + :ivar Optional[Snowflake] creator_id?: The ID of the user that created the scheduled event. |
| 587 | + :ivar str name: The name of the scheduled event. |
| 588 | + :ivar str description: The description of the scheduled event. |
| 589 | + :ivar datetime scheduled_start_time?: The scheduled event start time. |
| 590 | + :ivar Optional[datetime] scheduled_end_time?: The scheduled event end time, if any. |
| 591 | + :ivar int privacy_level: The privacy level of the scheduled event. |
| 592 | + :ivar int entity_type: The type of the scheduled event. |
| 593 | + :ivar Optional[Snowflake] entity_id?: The ID of the entity associated with the scheduled event. |
| 594 | + :ivar Optional[EventMetadata] entity_metadata?: Additional metadata associated with the scheduled event. |
| 595 | + :ivar Optional[User] creator?: The user that created the scheduled event. |
| 596 | + :ivar Optional[int] user_count?: The number of users subscribed to the scheduled event. |
| 597 | + :ivar int status: The status of the scheduled event |
| 598 | + :ivar Optional[str] image: The hash containing the image of an event, if applicable. |
| 599 | + """ |
| 600 | + |
| 601 | + __slots__ = ( |
| 602 | + "_json", |
| 603 | + "id", |
| 604 | + "guild_id", |
| 605 | + "channel_id", |
| 606 | + "creator_id", |
| 607 | + "name", |
| 608 | + "description", |
| 609 | + "scheduled_start_time", |
| 610 | + "scheduled_end_time", |
| 611 | + "privacy_level", |
| 612 | + "entity_type", |
| 613 | + "entity_id", |
| 614 | + "entity_metadata", |
| 615 | + "creator", |
| 616 | + "user_count", |
| 617 | + "status", |
| 618 | + "image", |
| 619 | + ) |
| 620 | + |
| 621 | + def __init__(self, **kwargs): |
| 622 | + super().__init__(**kwargs) |
| 623 | + self.id = Snowflake(self.id) if self._json.get("id") else None |
| 624 | + self.guild_id = Snowflake(self.guild_id) if self._json.get("guild_id") else None |
| 625 | + self.channel_id = Snowflake(self.channel_id) if self._json.get("channel_id") else None |
| 626 | + self.creator_id = Snowflake(self.creator_id) if self._json.get("creator_id") else None |
| 627 | + self.entity_id = Snowflake(self.entity_id) if self._json.get("entity_id") else None |
| 628 | + self.scheduled_start_time = ( |
| 629 | + datetime.fromisoformat(self._json.get("scheduled_start_time")) |
| 630 | + if self._json.get("scheduled_start_time") |
| 631 | + else None |
| 632 | + ) |
| 633 | + self.scheduled_end_time = ( |
| 634 | + datetime.fromisoformat(self._json.get("scheduled_end_time")) |
| 635 | + if self._json.get("scheduled_end_time") |
| 636 | + else None |
| 637 | + ) |
| 638 | + self.entity_metadata = ( |
| 639 | + EventMetadata(**self.entity_metadata) if self._json.get("entity_metadata") else None |
| 640 | + ) |
| 641 | + self.creator = User(**self.creator) if self._json.get("creator") else None |
| 642 | + |
| 643 | + |
| 644 | +class GuildScheduledEventUser(DictSerializerMixin): |
| 645 | + """ |
| 646 | + A class object representing the gateway events ``GUILD_SCHEDULED_EVENT_USER_ADD`` and ``GUILD_SCHEDULED_EVENT_USER_REMOVE`` |
| 647 | +
|
| 648 | + :ivar Snowflake guild_scheduled_event_id: The ID of the guild scheduled event. |
| 649 | + :ivar Snowflake guild_id: The ID of the guild associated with this event. |
| 650 | + :ivar Snowflake user_id: The ID of the user associated with this event. |
| 651 | + """ |
| 652 | + |
| 653 | + __slots__ = ("_json", "guild_scheduled_event_id", "user_id", "guild_id") |
| 654 | + |
| 655 | + def __init__(self, **kwargs): |
| 656 | + super().__init__(**kwargs) |
| 657 | + self.guild_scheduled_event_id = ( |
| 658 | + Snowflake(self.guild_scheduled_event_id) |
| 659 | + if self._json.get("guild_scheduled_event_id") |
| 660 | + else None |
| 661 | + ) |
| 662 | + self.guild_id = Snowflake(self.guild_id) if self._json.get("guild_id") else None |
| 663 | + self.user_id = Snowflake(self.user_id) if self._json.get("user_id") else None |
| 664 | + |
| 665 | + |
574 | 666 | class Integration(DictSerializerMixin): |
575 | 667 | """ |
576 | 668 | A class object representing the gateway events ``INTEGRATION_CREATE``, ``INTEGRATION_UPDATE`` and ``INTEGRATION_DELETE``. |
|
0 commit comments