diff options
| author | Nadir Chowdhury <[email protected]> | 2021-04-04 03:43:41 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-04-03 22:43:41 -0400 |
| commit | 1b2688518eb5c229a7e8bee089d0c505cfae4018 (patch) | |
| tree | 68a09f131d098b59698c9560dd94c8de54b9c2be /discord/guild.py | |
| parent | [docs] Add rtc_region parameter for Guild.create_voice_channel (diff) | |
| download | discord.py-1b2688518eb5c229a7e8bee089d0c505cfae4018.tar.xz discord.py-1b2688518eb5c229a7e8bee089d0c505cfae4018.zip | |
Implement StageChannel and related methods
Diffstat (limited to 'discord/guild.py')
| -rw-r--r-- | discord/guild.py | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/discord/guild.py b/discord/guild.py index 4b7ade89..2cc5679f 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -372,6 +372,18 @@ class Guild(Hashable): return r @property + def stage_channels(self): + """List[:class:`StageChannel`]: A list of voice channels that belongs to this guild. + + .. versionadded:: 1.7 + + This is sorted by the position and are in UI order from top to bottom. + """ + r = [ch for ch in self._channels.values() if isinstance(ch, StageChannel)] + r.sort(key=lambda c: (c.position, c.id)) + return r + + @property def me(self): """:class:`Member`: Similar to :attr:`Client.user` except an instance of :class:`Member`. This is essentially used to get the member version of yourself. @@ -979,6 +991,38 @@ class Guild(Hashable): self._channels[channel.id] = channel return channel + async def create_stage_channel(self, name, *, topic=None, category=None, overwrites=None, reason=None, position=None): + """|coro| + + This is similar to :meth:`create_text_channel` except makes a :class:`StageChannel` instead. + + .. note:: + + The ``slowmode_delay`` and ``nsfw`` parameters are not supported in this function. + + .. versionadded:: 1.7 + + Raises + ------ + Forbidden + You do not have the proper permissions to create this channel. + HTTPException + Creating the channel failed. + InvalidArgument + The permission overwrite information is not in proper form. + + Returns + ------- + :class:`StageChannel` + The channel that was just created. + """ + data = await self._create_channel(name, overwrites, ChannelType.stage_voice, category, reason=reason, position=position, topic=topic) + channel = StageChannel(state=self._state, guild=self, data=data) + + # temporarily add to the cache + self._channels[channel.id] = channel + return channel + async def create_category(self, name, *, overwrites=None, reason=None, position=None): """|coro| |