mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-06-07 12:18:59 +00:00
Type up Guild Scheduled Events
This commit is contained in:
parent
423fd1bc26
commit
d034264973
@ -35,6 +35,7 @@ from typing import (
|
|||||||
Dict,
|
Dict,
|
||||||
Iterable,
|
Iterable,
|
||||||
List,
|
List,
|
||||||
|
Literal,
|
||||||
Optional,
|
Optional,
|
||||||
Sequence,
|
Sequence,
|
||||||
TYPE_CHECKING,
|
TYPE_CHECKING,
|
||||||
@ -42,6 +43,7 @@ from typing import (
|
|||||||
Type,
|
Type,
|
||||||
TypeVar,
|
TypeVar,
|
||||||
Union,
|
Union,
|
||||||
|
overload,
|
||||||
)
|
)
|
||||||
from urllib.parse import quote as _uriquote
|
from urllib.parse import quote as _uriquote
|
||||||
import weakref
|
import weakref
|
||||||
@ -83,6 +85,7 @@ if TYPE_CHECKING:
|
|||||||
widget,
|
widget,
|
||||||
threads,
|
threads,
|
||||||
voice,
|
voice,
|
||||||
|
scheduled_event,
|
||||||
sticker,
|
sticker,
|
||||||
)
|
)
|
||||||
from .types.snowflake import Snowflake, SnowflakeList
|
from .types.snowflake import Snowflake, SnowflakeList
|
||||||
@ -1532,6 +1535,24 @@ class HTTPClient:
|
|||||||
def delete_stage_instance(self, channel_id: Snowflake, *, reason: Optional[str] = None) -> Response[None]:
|
def delete_stage_instance(self, channel_id: Snowflake, *, reason: Optional[str] = None) -> Response[None]:
|
||||||
return self.request(Route('DELETE', '/stage-instances/{channel_id}', channel_id=channel_id), reason=reason)
|
return self.request(Route('DELETE', '/stage-instances/{channel_id}', channel_id=channel_id), reason=reason)
|
||||||
|
|
||||||
|
# Guild scheduled event management
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def get_scheduled_events(
|
||||||
|
self, guild_id: Snowflake, with_user_count: Literal[True]
|
||||||
|
) -> Response[List[scheduled_event.GuildScheduledEventWithUserCount]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
@overload
|
||||||
|
def get_scheduled_events(
|
||||||
|
self, guild_id: Snowflake, with_user_count: Literal[False]
|
||||||
|
) -> Response[List[scheduled_event.GuildScheduledEvent]]:
|
||||||
|
...
|
||||||
|
|
||||||
|
def get_scheduled_events(self, guild_id: Snowflake, with_user_count: bool) -> Response[Any]:
|
||||||
|
payload = {'with_user_count': with_user_count}
|
||||||
|
return self.request(Route('GET', '/guilds/{guild_id}/scheduled-events', guild_id=guild_id), json=payload)
|
||||||
|
|
||||||
# Application commands (global)
|
# Application commands (global)
|
||||||
|
|
||||||
def get_global_commands(self, application_id: Snowflake) -> Response[List[interactions.ApplicationCommand]]:
|
def get_global_commands(self, application_id: Snowflake) -> Response[List[interactions.ApplicationCommand]]:
|
||||||
|
99
discord/types/scheduled_event.py
Normal file
99
discord/types/scheduled_event.py
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
"""
|
||||||
|
The MIT License (MIT)
|
||||||
|
|
||||||
|
Copyright (c) 2015-present Rapptz
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
copy of this software and associated documentation files (the "Software"),
|
||||||
|
to deal in the Software without restriction, including without limitation
|
||||||
|
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
Software is furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in
|
||||||
|
all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||||
|
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
DEALINGS IN THE SOFTWARE.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from typing import Literal, Optional, TypedDict, Union
|
||||||
|
|
||||||
|
from .snowflake import Snowflake
|
||||||
|
from .user import User
|
||||||
|
|
||||||
|
GuildScheduledEventPrivacyLevel = Literal[1]
|
||||||
|
EventStatus = Literal[1, 2, 3, 4]
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseGuildScheduledEventOptional(TypedDict, total=False):
|
||||||
|
creator_id: Optional[Snowflake]
|
||||||
|
description: str
|
||||||
|
creator: User
|
||||||
|
|
||||||
|
|
||||||
|
class _BaseGuildScheduledEvent(_BaseGuildScheduledEventOptional):
|
||||||
|
id: Snowflake
|
||||||
|
guild_id: Snowflake
|
||||||
|
name: str
|
||||||
|
scheduled_start_time: str
|
||||||
|
privacy_level: GuildScheduledEventPrivacyLevel
|
||||||
|
status: EventStatus
|
||||||
|
image: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
|
class _VoiceChannelScheduledEventOptional(_BaseGuildScheduledEvent, total=False):
|
||||||
|
scheduled_end_time: Optional[str]
|
||||||
|
|
||||||
|
|
||||||
|
class _VoiceChannelScheduledEvent(_VoiceChannelScheduledEventOptional):
|
||||||
|
channel_id: Snowflake
|
||||||
|
entity_metadata: Literal[None]
|
||||||
|
|
||||||
|
|
||||||
|
class StageInstanceScheduledEvent(_VoiceChannelScheduledEvent):
|
||||||
|
entity_type: Literal[1]
|
||||||
|
|
||||||
|
|
||||||
|
class VoiceScheduledEvent(_VoiceChannelScheduledEvent):
|
||||||
|
entity_type: Literal[2]
|
||||||
|
|
||||||
|
|
||||||
|
class EntityMetadata(TypedDict):
|
||||||
|
location: str
|
||||||
|
|
||||||
|
|
||||||
|
class ExternalScheduledEvent(_BaseGuildScheduledEvent):
|
||||||
|
channel_id: Literal[None]
|
||||||
|
entity_metadata: EntityMetadata
|
||||||
|
scheduled_end_time: Optional[str]
|
||||||
|
entity_type: Literal[3]
|
||||||
|
|
||||||
|
|
||||||
|
GuildScheduledEvent = Union[StageInstanceScheduledEvent, VoiceScheduledEvent, ExternalScheduledEvent]
|
||||||
|
|
||||||
|
|
||||||
|
class _WithUserCount(TypedDict):
|
||||||
|
user_count: str
|
||||||
|
|
||||||
|
|
||||||
|
class _StageInstanceScheduledEventWithUserCount(StageInstanceScheduledEvent, _WithUserCount):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
class _VoiceScheduledEventWithUserCount(VoiceScheduledEvent, _WithUserCount):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
class _ExternalScheduledEventWithUserCount(ExternalScheduledEvent, _WithUserCount):
|
||||||
|
...
|
||||||
|
|
||||||
|
|
||||||
|
GuildScheduledEventWithUserCount = Union[
|
||||||
|
_StageInstanceScheduledEventWithUserCount, _VoiceScheduledEventWithUserCount, _ExternalScheduledEventWithUserCount
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user