Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Store Channels #1215

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
173 changes: 0 additions & 173 deletions discord/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
"StageChannel",
"DMChannel",
"CategoryChannel",
"StoreChannel",
"GroupChannel",
"PartialMessageable",
)
Expand All @@ -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
Expand Down Expand Up @@ -1646,175 +1644,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"<StoreChannel id={self.id} name={self.name!r} position={self.position} nsfw={self.nsfw}>"

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")


Expand Down Expand Up @@ -2169,8 +1998,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:
Expand Down
1 change: 0 additions & 1 deletion discord/enums.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,6 @@ class ChannelType(Enum):
group = 3
category = 4
news = 5
store = 6
news_thread = 10
public_thread = 11
private_thread = 12
Expand Down
21 changes: 0 additions & 21 deletions discord/ext/commands/converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@
"PartialEmojiConverter",
"CategoryChannelConverter",
"IDConverter",
"StoreChannelConverter",
"ThreadConverter",
"GuildChannelConverter",
"GuildStickerConverter",
Expand Down Expand Up @@ -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`.

Expand Down Expand Up @@ -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,
Expand Down
5 changes: 2 additions & 3 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@
from .channel import (
CategoryChannel,
StageChannel,
StoreChannel,
TextChannel,
VoiceChannel,
)
Expand All @@ -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]]


Expand Down Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions discord/interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
CategoryChannel,
PartialMessageable,
StageChannel,
StoreChannel,
TextChannel,
VoiceChannel,
)
Expand All @@ -77,7 +76,6 @@
StageChannel,
TextChannel,
CategoryChannel,
StoreChannel,
Thread,
PartialMessageable,
]
Expand Down
7 changes: 1 addition & 6 deletions discord/types/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -134,7 +130,6 @@ class ThreadChannel(_BaseChannel, _ThreadChannelOptional):
NewsChannel,
VoiceChannel,
CategoryChannel,
StoreChannel,
StageChannel,
ThreadChannel,
]
Expand Down
18 changes: 5 additions & 13 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1494,26 +1494,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.
Expand Down Expand Up @@ -4362,15 +4363,6 @@ ThreadMember
.. autoclass:: ThreadMember()
:members:

StoreChannel
~~~~~~~~~~~~~

.. attributetable:: StoreChannel

.. autoclass:: StoreChannel()
:members:
:inherited-members:

VoiceChannel
~~~~~~~~~~~~~

Expand Down
3 changes: 0 additions & 3 deletions docs/ext/commands/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -391,9 +391,6 @@ Converters
.. autoclass:: discord.ext.commands.VoiceChannelConverter
:members:

.. autoclass:: discord.ext.commands.StoreChannelConverter
:members:

.. autoclass:: discord.ext.commands.StageChannelConverter
:members:

Expand Down
3 changes: 0 additions & 3 deletions docs/ext/commands/commands.rst
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,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)
Expand Down Expand Up @@ -426,8 +425,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` |
Expand Down