Skip to content
This repository has been archived by the owner on Dec 26, 2022. It is now read-only.

✨ Adding ScheduleEvent #304

Merged
merged 12 commits into from
Dec 16, 2021
10 changes: 4 additions & 6 deletions pincer/objects/guild/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,21 @@

from __future__ import annotations

from collections import AsyncIterator
from dataclasses import dataclass, field
from enum import IntEnum
from typing import AsyncGenerator, overload, TYPE_CHECKING

from aiohttp import FormData

from .invite import Invite
from .channel import Channel
from ..message.emoji import Emoji
from .invite import Invite
from .schedule_events import ScheduledEvent
from ..message.file import File
from ...exceptions import UnavailableGuildError
from ...utils.api_object import APIObject
from ...utils.conversion import construct_client_dict, remove_none
from ...utils.types import MISSING


if TYPE_CHECKING:
from typing import Any, Dict, List, Optional, Tuple, Union, Generator
from collections.abc import AsyncIterator
Expand All @@ -41,7 +39,7 @@
from ..voice.region import VoiceRegion
from ..events.presence import PresenceUpdateEvent
from ..message.emoji import Emoji
from ..message.sticker import Sticker, StickerPack
from ..message.sticker import Sticker
from ..user.voice_state import VoiceState
from ...client import Client
from ...utils.timestamp import Timestamp
Expand Down Expand Up @@ -366,7 +364,7 @@ class Guild(APIObject):
preferred_locale: APINullable[str] = MISSING
roles: APINullable[List[Role]] = MISSING

guild_scheduled_events: APINullable[List] = MISSING
guild_scheduled_events: APINullable[List[ScheduledEvent]] = MISSING
lazy: APINullable[bool] = MISSING
premium_progress_bar_enabled: APINullable[bool] = MISSING
guild_hashes: APINullable[Dict] = MISSING
Expand Down
104 changes: 104 additions & 0 deletions pincer/objects/guild/schedule_events.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
from dataclasses import dataclass
from enum import IntEnum, Enum
from typing import Optional

from ..guild.stage import PrivacyLevel
from ..user import User
from ...utils.api_object import APIObject, MISSING
from ...utils.snowflake import Snowflake
from ...utils.types import APINullable


class EventStatus(IntEnum):
"""
The status of an event.

Attributes
----------
SCHEDULED: int
The event is scheduled.
Sigmanificient marked this conversation as resolved.
Show resolved Hide resolved
CANCELLED: int
The event is cancelled.
COMPLETED: int
The event is completed.
"""
SCHEDULED = 1
ACTIVE = 2
COMPLETED = 3
CANCELLED = 4


class GuildScheduledEventEntityType(Enum):
"""
The type of entity that is scheduled.

Attributes
----------
STAGE_INSTANCE: int
The event is scheduled for a stage instance.
VOICE: int
The event is scheduled for a voice channel.
EXTERNAL: int
The event is scheduled for an external resource.
"""
STAGE_INSTANCE = 1
VOICE = 2
EXTERNAL = 3


@dataclass(repr=False)
class ScheduledEvent(APIObject):
"""
Represents a scheduled event in a guild.

Attributes
----------
id: :class:`int`
The ID of the scheduled event.
name: :class:`str`
The name of the scheduled event (1-100 characters)
guild_id: :class:`int`
The guild id which the scheduled event belongs to
scheduled_start_time: str
The scheduled start time of the event.
privacy_level: :class:`PrivacyLevel`
Sigmanificient marked this conversation as resolved.
Show resolved Hide resolved
The privacy level of the scheduled event.
status: :class:`EventStatus`
Sigmanificient marked this conversation as resolved.
Show resolved Hide resolved
The status of the scheduled event.
entity_type: :class:`GuildScheduledEventEntityType`
Sigmanificient marked this conversation as resolved.
Show resolved Hide resolved
The type of the scheduled event
channel_id: :class:`int`
The channel id in which the scheduled event will be hosted,
or null if scheduled entity type is EXTERNAL
creator_id: :class:`int`
The user id of the creator of the scheduled event
scheduled_end_time: str
The time the scheduled event will end, required if entity_type is EXTERNAL
description: :class:`str`
The description of the scheduled event (0-1000 characters)
entity_id: :class:`int`
The id of an entity associated with a guild scheduled event
entity_metadata: :class:`str`
Additional metadata for the guild scheduled event
creator: :class:`User`
Sigmanificient marked this conversation as resolved.
Show resolved Hide resolved
The user who created the scheduled event
user_count: :class:`int`
The number of users who have joined the scheduled event
"""
id: Snowflake
name: str
guild_id: Snowflake
scheduled_start_time: str
privacy_level = PrivacyLevel
status: EventStatus
entity_type: GuildScheduledEventEntityType

channel_id: APINullable[Snowflake] = MISSING
creator_id: APINullable[Snowflake] = MISSING
scheduled_end_time: Optional[str] = None

description: APINullable[str] = MISSING
entity_id: APINullable[Snowflake] = MISSING
entity_metadata: APINullable[str] = MISSING
creator: APINullable[User] = MISSING
user_count: APINullable[int] = MISSING