From 704119bded4706926a18abb2eda985ea2b23d211 Mon Sep 17 00:00:00 2001 From: Middledot Date: Wed, 30 Mar 2022 21:38:51 -0400 Subject: [PATCH] Fully deprecate/remove store channels Removes all references to Store Channels (of those I could find) --- discord/channel.py | 173 ------------------------------ discord/enums.py | 1 - discord/ext/commands/converter.py | 21 ---- discord/guild.py | 5 +- discord/interactions.py | 2 - discord/types/channel.py | 7 +- docs/api.rst | 18 +--- docs/ext/commands/api.rst | 3 - docs/ext/commands/commands.rst | 3 - 9 files changed, 8 insertions(+), 225 deletions(-) diff --git a/discord/channel.py b/discord/channel.py index 095bf528be..2aee2dc469 100644 --- a/discord/channel.py +++ b/discord/channel.py @@ -73,7 +73,6 @@ "StageChannel", "DMChannel", "CategoryChannel", - "StoreChannel", "GroupChannel", "PartialMessageable", ) @@ -90,7 +89,6 @@ from .types.channel import DMChannel as DMChannelPayload from .types.channel import GroupDMChannel as GroupChannelPayload from .types.channel import StageChannel as StageChannelPayload - from .types.channel import StoreChannel as StoreChannelPayload from .types.channel import TextChannel as TextChannelPayload from .types.channel import VoiceChannel as VoiceChannelPayload from .types.snowflake import SnowflakeList @@ -1641,175 +1639,6 @@ async def create_stage_channel(self, name: str, **options: Any) -> StageChannel: return await self.guild.create_stage_channel(name, category=self, **options) -class StoreChannel(discord.abc.GuildChannel, Hashable): - """Represents a Discord guild store channel. - - .. container:: operations - - .. describe:: x == y - - Checks if two channels are equal. - - .. describe:: x != y - - Checks if two channels are not equal. - - .. describe:: hash(x) - - Returns the channel's hash. - - .. describe:: str(x) - - Returns the channel's name. - - Attributes - ----------- - name: :class:`str` - The channel name. - guild: :class:`Guild` - The guild the channel belongs to. - id: :class:`int` - The channel ID. - category_id: :class:`int` - The category channel ID this channel belongs to. - position: :class:`int` - The position in the channel list. This is a number that starts at 0. e.g. the - top channel is position 0. - nsfw: :class:`bool` - If the channel is marked as "not safe for work". - - .. note:: - - To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead. - """ - - __slots__ = ( - "name", - "id", - "guild", - "_state", - "nsfw", - "category_id", - "position", - "_overwrites", - ) - - def __init__(self, *, state: ConnectionState, guild: Guild, data: StoreChannelPayload): - self._state: ConnectionState = state - self.id: int = int(data["id"]) - self._update(guild, data) - - def __repr__(self) -> str: - return f"" - - def _update(self, guild: Guild, data: StoreChannelPayload) -> None: - self.guild: Guild = guild - self.name: str = data["name"] - self.category_id: Optional[int] = utils._get_as_snowflake(data, "parent_id") - self.position: int = data["position"] - self.nsfw: bool = data.get("nsfw", False) - self._fill_overwrites(data) - - @property - def _sorting_bucket(self) -> int: - return ChannelType.text.value - - @property - def type(self) -> ChannelType: - """:class:`ChannelType`: The channel's Discord type.""" - return ChannelType.store - - @utils.copy_doc(discord.abc.GuildChannel.permissions_for) - def permissions_for(self, obj: Union[Member, Role], /) -> Permissions: - base = super().permissions_for(obj) - - # store channels do not have voice related permissions - denied = Permissions.voice() - base.value &= ~denied.value - return base - - def is_nsfw(self) -> bool: - """:class:`bool`: Checks if the channel is NSFW.""" - return self.nsfw - - @utils.copy_doc(discord.abc.GuildChannel.clone) - async def clone(self, *, name: Optional[str] = None, reason: Optional[str] = None) -> StoreChannel: - return await self._clone_impl({"nsfw": self.nsfw}, name=name, reason=reason) - - @overload - async def edit( - self, - *, - name: str = ..., - position: int = ..., - nsfw: bool = ..., - sync_permissions: bool = ..., - category: Optional[CategoryChannel], - reason: Optional[str], - overwrites: Mapping[Union[Role, Member], PermissionOverwrite], - ) -> Optional[StoreChannel]: - ... - - @overload - async def edit(self) -> Optional[StoreChannel]: - ... - - async def edit(self, *, reason=None, **options): - """|coro| - - Edits the channel. - - You must have the :attr:`~Permissions.manage_channels` permission to - use this. - - .. versionchanged:: 2.0 - Edits are no longer in-place, the newly edited channel is returned instead. - - Parameters - ---------- - name: :class:`str` - The new channel name. - position: :class:`int` - The new channel's position. - nsfw: :class:`bool` - To mark the channel as NSFW or not. - sync_permissions: :class:`bool` - Whether to sync permissions with the channel's new or pre-existing - category. Defaults to ``False``. - category: Optional[:class:`CategoryChannel`] - The new category for this channel. Can be ``None`` to remove the - category. - reason: Optional[:class:`str`] - The reason for editing this channel. Shows up on the audit log. - overwrites: :class:`Mapping` - A :class:`Mapping` of target (either a role or a member) to - :class:`PermissionOverwrite` to apply to the channel. - - .. versionadded:: 1.3 - - Raises - ------ - InvalidArgument - If position is less than 0 or greater than the number of channels, or if - the permission overwrite information is not in proper form. - Forbidden - You do not have permissions to edit the channel. - HTTPException - Editing the channel failed. - - Returns - -------- - Optional[:class:`.StoreChannel`] - The newly edited store channel. If the edit was only positional - then ``None`` is returned instead. - """ - - payload = await self._edit(options, reason=reason) - if payload is not None: - # the payload will always be the proper channel payload - return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore - - DMC = TypeVar("DMC", bound="DMChannel") @@ -2164,8 +1993,6 @@ def _guild_channel_factory(channel_type: int): return CategoryChannel, value elif value is ChannelType.news: return TextChannel, value - elif value is ChannelType.store: - return StoreChannel, value elif value is ChannelType.stage_voice: return StageChannel, value else: diff --git a/discord/enums.py b/discord/enums.py index 0f9b03f45b..3c7cdb1b34 100644 --- a/discord/enums.py +++ b/discord/enums.py @@ -186,7 +186,6 @@ class ChannelType(Enum): group = 3 category = 4 news = 5 - store = 6 news_thread = 10 public_thread = 11 private_thread = 12 diff --git a/discord/ext/commands/converter.py b/discord/ext/commands/converter.py index 617d8b5d9b..c40aaef90a 100644 --- a/discord/ext/commands/converter.py +++ b/discord/ext/commands/converter.py @@ -74,7 +74,6 @@ "PartialEmojiConverter", "CategoryChannelConverter", "IDConverter", - "StoreChannelConverter", "ThreadConverter", "GuildChannelConverter", "GuildStickerConverter", @@ -564,25 +563,6 @@ async def convert(self, ctx: Context, argument: str) -> discord.CategoryChannel: return GuildChannelConverter._resolve_channel(ctx, argument, "categories", discord.CategoryChannel) -class StoreChannelConverter(IDConverter[discord.StoreChannel]): - """Converts to a :class:`~discord.StoreChannel`. - - All lookups are via the local guild. If in a DM context, then the lookup - is done by the global cache. - - The lookup strategy is as follows (in order): - - 1. Lookup by ID. - 2. Lookup by mention. - 3. Lookup by name. - - .. versionadded:: 1.7 - """ - - async def convert(self, ctx: Context, argument: str) -> discord.StoreChannel: - return GuildChannelConverter._resolve_channel(ctx, argument, "channels", discord.StoreChannel) - - class ThreadConverter(IDConverter[discord.Thread]): """Coverts to a :class:`~discord.Thread`. @@ -1063,7 +1043,6 @@ def is_generic_type(tp: Any, *, _GenericAlias: Type = _GenericAlias) -> bool: discord.Emoji: EmojiConverter, discord.PartialEmoji: PartialEmojiConverter, discord.CategoryChannel: CategoryChannelConverter, - discord.StoreChannel: StoreChannelConverter, discord.Thread: ThreadConverter, discord.abc.GuildChannel: GuildChannelConverter, discord.GuildSticker: GuildStickerConverter, diff --git a/discord/guild.py b/discord/guild.py index 4263379436..9cb9d19c50 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -91,7 +91,6 @@ from .channel import ( CategoryChannel, StageChannel, - StoreChannel, TextChannel, VoiceChannel, ) @@ -107,7 +106,7 @@ from .webhook import Webhook VocalGuildChannel = Union[VoiceChannel, StageChannel] - GuildChannel = Union[VoiceChannel, StageChannel, TextChannel, CategoryChannel, StoreChannel] + GuildChannel = Union[VoiceChannel, StageChannel, TextChannel, CategoryChannel] ByCategoryItem = Tuple[Optional[CategoryChannel], List[GuildChannel]] @@ -207,7 +206,7 @@ class Guild(Hashable): - ``ANIMATED_ICON``: Guild can upload an animated icon. - ``BANNER``: Guild can upload and use a banner. (i.e. :attr:`.banner`) - ``CHANNEL_BANNER``: Guild can upload and use a channel banners. - - ``COMMERCE``: Guild can sell things using store channels. + - ``COMMERCE``: Guild can sell things using store channels, which have now been removed. - ``COMMUNITY``: Guild is a community server. - ``DISCOVERABLE``: Guild shows up in Server Discovery. - ``FEATURABLE``: Guild is able to be featured in Server Discovery. diff --git a/discord/interactions.py b/discord/interactions.py index 88a0345547..818ce38b58 100644 --- a/discord/interactions.py +++ b/discord/interactions.py @@ -55,7 +55,6 @@ CategoryChannel, PartialMessageable, StageChannel, - StoreChannel, TextChannel, VoiceChannel, ) @@ -77,7 +76,6 @@ StageChannel, TextChannel, CategoryChannel, - StoreChannel, Thread, PartialMessageable, ] diff --git a/discord/types/channel.py b/discord/types/channel.py index c9f16ce7ff..e707d32de3 100644 --- a/discord/types/channel.py +++ b/discord/types/channel.py @@ -39,7 +39,7 @@ class PermissionOverwrite(TypedDict): deny: str -ChannelType = Literal[0, 1, 2, 3, 4, 5, 6, 10, 11, 12, 13] +ChannelType = Literal[0, 1, 2, 3, 4, 5, 10, 11, 12, 13] class _BaseChannel(TypedDict): @@ -93,10 +93,6 @@ class CategoryChannel(_BaseGuildChannel): type: Literal[4] -class StoreChannel(_BaseGuildChannel): - type: Literal[6] - - class _StageChannelOptional(TypedDict, total=False): rtc_region: Optional[str] topic: str @@ -134,7 +130,6 @@ class ThreadChannel(_BaseChannel, _ThreadChannelOptional): NewsChannel, VoiceChannel, CategoryChannel, - StoreChannel, StageChannel, ThreadChannel, ] diff --git a/docs/api.rst b/docs/api.rst index 65123e632a..834490e4d4 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -1452,26 +1452,27 @@ of :class:`enum.Enum`. .. attribute:: text A text channel. + .. attribute:: voice A voice channel. + .. attribute:: private A private text channel. Also called a direct message. + .. attribute:: group A private group text channel. + .. attribute:: category A category channel. + .. attribute:: news A guild news channel. - .. attribute:: store - - A guild store channel. - .. attribute:: stage_voice A guild stage voice channel. @@ -4320,15 +4321,6 @@ ThreadMember .. autoclass:: ThreadMember() :members: -StoreChannel -~~~~~~~~~~~~~ - -.. attributetable:: StoreChannel - -.. autoclass:: StoreChannel() - :members: - :inherited-members: - VoiceChannel ~~~~~~~~~~~~~ diff --git a/docs/ext/commands/api.rst b/docs/ext/commands/api.rst index 73f11fdcac..47595488c0 100644 --- a/docs/ext/commands/api.rst +++ b/docs/ext/commands/api.rst @@ -386,9 +386,6 @@ Converters .. autoclass:: discord.ext.commands.VoiceChannelConverter :members: -.. autoclass:: discord.ext.commands.StoreChannelConverter - :members: - .. autoclass:: discord.ext.commands.StageChannelConverter :members: diff --git a/docs/ext/commands/commands.rst b/docs/ext/commands/commands.rst index e1b7be2255..06fe92fd72 100644 --- a/docs/ext/commands/commands.rst +++ b/docs/ext/commands/commands.rst @@ -383,7 +383,6 @@ A lot of discord models work out of the gate as a parameter: - :class:`TextChannel` - :class:`VoiceChannel` - :class:`StageChannel` (since v1.7) -- :class:`StoreChannel` (since v1.7) - :class:`CategoryChannel` - :class:`Invite` - :class:`Guild` (since v1.7) @@ -421,8 +420,6 @@ converter is given below: +--------------------------+-------------------------------------------------+ | :class:`StageChannel` | :class:`~ext.commands.StageChannelConverter` | +--------------------------+-------------------------------------------------+ -| :class:`StoreChannel` | :class:`~ext.commands.StoreChannelConverter` | -+--------------------------+-------------------------------------------------+ | :class:`CategoryChannel` | :class:`~ext.commands.CategoryChannelConverter` | +--------------------------+-------------------------------------------------+ | :class:`Invite` | :class:`~ext.commands.InviteConverter` |