|
65 | 65 | "GroupChannel",
|
66 | 66 | "PartialMessageable",
|
67 | 67 | "ForumChannel",
|
| 68 | + "MediaChannel", |
68 | 69 | "ForumTag",
|
69 | 70 | )
|
70 | 71 |
|
@@ -853,7 +854,6 @@ async def edit(self, *, reason=None, **options):
|
853 | 854 | HTTPException
|
854 | 855 | Editing the channel failed.
|
855 | 856 | """
|
856 |
| - |
857 | 857 | payload = await self._edit(options, reason=reason)
|
858 | 858 | if payload is not None:
|
859 | 859 | # the payload will always be the proper channel payload
|
@@ -1056,7 +1056,7 @@ def guidelines(self) -> str | None:
|
1056 | 1056 |
|
1057 | 1057 | @property
|
1058 | 1058 | def requires_tag(self) -> bool:
|
1059 |
| - """Whether a tag is required to be specified when creating a thread in this forum channel. |
| 1059 | + """Whether a tag is required to be specified when creating a thread in this forum or media channel. |
1060 | 1060 |
|
1061 | 1061 | Tags are specified in :attr:`applied_tags`.
|
1062 | 1062 |
|
@@ -1169,6 +1169,9 @@ async def edit(self, *, reason=None, **options):
|
1169 | 1169 | HTTPException
|
1170 | 1170 | Editing the channel failed.
|
1171 | 1171 | """
|
| 1172 | + if "require_tag" in options: |
| 1173 | + options["flags"] = ChannelFlags._from_value(self.flags.value) |
| 1174 | + options["flags"].require_tag = options.pop("require_tag") |
1172 | 1175 |
|
1173 | 1176 | payload = await self._edit(options, reason=reason)
|
1174 | 1177 | if payload is not None:
|
@@ -1351,6 +1354,196 @@ async def create_thread(
|
1351 | 1354 | return ret
|
1352 | 1355 |
|
1353 | 1356 |
|
| 1357 | +class MediaChannel(ForumChannel): |
| 1358 | + """Represents a Discord media channel. Subclass of :class:`ForumChannel`. |
| 1359 | +
|
| 1360 | + .. container:: operations |
| 1361 | +
|
| 1362 | + .. describe:: x == y |
| 1363 | +
|
| 1364 | + Checks if two channels are equal. |
| 1365 | +
|
| 1366 | + .. describe:: x != y |
| 1367 | +
|
| 1368 | + Checks if two channels are not equal. |
| 1369 | +
|
| 1370 | + .. describe:: hash(x) |
| 1371 | +
|
| 1372 | + Returns the channel's hash. |
| 1373 | +
|
| 1374 | + .. describe:: str(x) |
| 1375 | +
|
| 1376 | + Returns the channel's name. |
| 1377 | +
|
| 1378 | + .. versionadded:: 2.7 |
| 1379 | +
|
| 1380 | + Attributes |
| 1381 | + ---------- |
| 1382 | + name: :class:`str` |
| 1383 | + The channel name. |
| 1384 | + guild: :class:`Guild` |
| 1385 | + The guild the channel belongs to. |
| 1386 | + id: :class:`int` |
| 1387 | + The channel ID. |
| 1388 | + category_id: Optional[:class:`int`] |
| 1389 | + The category channel ID this channel belongs to, if applicable. |
| 1390 | + topic: Optional[:class:`str`] |
| 1391 | + The channel's topic. ``None`` if it doesn't exist. |
| 1392 | +
|
| 1393 | + .. note:: |
| 1394 | +
|
| 1395 | + :attr:`guidelines` exists as an alternative to this attribute. |
| 1396 | + position: Optional[:class:`int`] |
| 1397 | + The position in the channel list. This is a number that starts at 0. e.g. the |
| 1398 | + top channel is position 0. Can be ``None`` if the channel was received in an interaction. |
| 1399 | + last_message_id: Optional[:class:`int`] |
| 1400 | + The last message ID of the message sent to this channel. It may |
| 1401 | + *not* point to an existing or valid message. |
| 1402 | + slowmode_delay: :class:`int` |
| 1403 | + The number of seconds a member must wait between sending messages |
| 1404 | + in this channel. A value of `0` denotes that it is disabled. |
| 1405 | + Bots and users with :attr:`~Permissions.manage_channels` or |
| 1406 | + :attr:`~Permissions.manage_messages` bypass slowmode. |
| 1407 | + nsfw: :class:`bool` |
| 1408 | + If the channel is marked as "not safe for work". |
| 1409 | +
|
| 1410 | + .. note:: |
| 1411 | +
|
| 1412 | + To check if the channel or the guild of that channel are marked as NSFW, consider :meth:`is_nsfw` instead. |
| 1413 | + default_auto_archive_duration: :class:`int` |
| 1414 | + The default auto archive duration in minutes for threads created in this channel. |
| 1415 | +
|
| 1416 | + flags: :class:`ChannelFlags` |
| 1417 | + Extra features of the channel. |
| 1418 | +
|
| 1419 | + available_tags: List[:class:`ForumTag`] |
| 1420 | + The set of tags that can be used in a forum channel. |
| 1421 | +
|
| 1422 | + default_sort_order: Optional[:class:`SortOrder`] |
| 1423 | + The default sort order type used to order posts in this channel. |
| 1424 | +
|
| 1425 | + default_thread_slowmode_delay: Optional[:class:`int`] |
| 1426 | + The initial slowmode delay to set on newly created threads in this channel. |
| 1427 | +
|
| 1428 | + default_reaction_emoji: Optional[:class:`str` | :class:`discord.GuildEmoji`] |
| 1429 | + The default forum reaction emoji. |
| 1430 | + """ |
| 1431 | + |
| 1432 | + @property |
| 1433 | + def media_download_options_hidden(self) -> bool: |
| 1434 | + """Whether media download options are hidden in this media channel. |
| 1435 | +
|
| 1436 | + .. versionadded:: 2.7 |
| 1437 | + """ |
| 1438 | + return self.flags.hide_media_download_options |
| 1439 | + |
| 1440 | + @overload |
| 1441 | + async def edit( |
| 1442 | + self, |
| 1443 | + *, |
| 1444 | + reason: str | None = ..., |
| 1445 | + name: str = ..., |
| 1446 | + topic: str = ..., |
| 1447 | + position: int = ..., |
| 1448 | + nsfw: bool = ..., |
| 1449 | + sync_permissions: bool = ..., |
| 1450 | + category: CategoryChannel | None = ..., |
| 1451 | + slowmode_delay: int = ..., |
| 1452 | + default_auto_archive_duration: ThreadArchiveDuration = ..., |
| 1453 | + default_thread_slowmode_delay: int = ..., |
| 1454 | + default_sort_order: SortOrder = ..., |
| 1455 | + default_reaction_emoji: GuildEmoji | int | str | None = ..., |
| 1456 | + available_tags: list[ForumTag] = ..., |
| 1457 | + require_tag: bool = ..., |
| 1458 | + hide_media_download_options: bool = ..., |
| 1459 | + overwrites: Mapping[Role | Member | Snowflake, PermissionOverwrite] = ..., |
| 1460 | + ) -> ForumChannel | None: ... |
| 1461 | + |
| 1462 | + async def edit(self, *, reason=None, **options): |
| 1463 | + """|coro| |
| 1464 | +
|
| 1465 | + Edits the channel. |
| 1466 | +
|
| 1467 | + You must have the :attr:`~Permissions.manage_channels` permission to |
| 1468 | + use this. |
| 1469 | +
|
| 1470 | + Parameters |
| 1471 | + ---------- |
| 1472 | + name: :class:`str` |
| 1473 | + The new channel name. |
| 1474 | + topic: :class:`str` |
| 1475 | + The new channel's topic. |
| 1476 | + position: :class:`int` |
| 1477 | + The new channel's position. |
| 1478 | + nsfw: :class:`bool` |
| 1479 | + To mark the channel as NSFW or not. |
| 1480 | + sync_permissions: :class:`bool` |
| 1481 | + Whether to sync permissions with the channel's new or pre-existing |
| 1482 | + category. Defaults to ``False``. |
| 1483 | + category: Optional[:class:`CategoryChannel`] |
| 1484 | + The new category for this channel. Can be ``None`` to remove the |
| 1485 | + category. |
| 1486 | + slowmode_delay: :class:`int` |
| 1487 | + Specifies the slowmode rate limit for user in this channel, in seconds. |
| 1488 | + A value of `0` disables slowmode. The maximum value possible is `21600`. |
| 1489 | + reason: Optional[:class:`str`] |
| 1490 | + The reason for editing this channel. Shows up on the audit log. |
| 1491 | + overwrites: Dict[Union[:class:`Role`, :class:`Member`, :class:`~discord.abc.Snowflake`], :class:`PermissionOverwrite`] |
| 1492 | + The overwrites to apply to channel permissions. Useful for creating secret channels. |
| 1493 | + default_auto_archive_duration: :class:`int` |
| 1494 | + The new default auto archive duration in minutes for threads created in this channel. |
| 1495 | + Must be one of ``60``, ``1440``, ``4320``, or ``10080``. |
| 1496 | + default_thread_slowmode_delay: :class:`int` |
| 1497 | + The new default slowmode delay in seconds for threads created in this channel. |
| 1498 | +
|
| 1499 | + default_sort_order: Optional[:class:`SortOrder`] |
| 1500 | + The default sort order type to use to order posts in this channel. |
| 1501 | +
|
| 1502 | + default_reaction_emoji: Optional[:class:`discord.GuildEmoji` | :class:`int` | :class:`str`] |
| 1503 | + The default reaction emoji. |
| 1504 | + Can be a unicode emoji or a custom emoji in the forms: |
| 1505 | + :class:`GuildEmoji`, snowflake ID, string representation (e.g., '<a:emoji_name:emoji_id>'). |
| 1506 | +
|
| 1507 | + available_tags: List[:class:`ForumTag`] |
| 1508 | + The set of tags that can be used in this channel. Must be less than `20`. |
| 1509 | +
|
| 1510 | + require_tag: :class:`bool` |
| 1511 | + Whether a tag should be required to be specified when creating a thread in this channel. |
| 1512 | +
|
| 1513 | + hide_media_download_options: :class:`bool` |
| 1514 | + Whether media download options should be hidden in this media channel. |
| 1515 | +
|
| 1516 | + Returns |
| 1517 | + ------- |
| 1518 | + Optional[:class:`.MediaChannel`] |
| 1519 | + The newly edited media channel. If the edit was only positional |
| 1520 | + then ``None`` is returned instead. |
| 1521 | +
|
| 1522 | + Raises |
| 1523 | + ------ |
| 1524 | + InvalidArgument |
| 1525 | + If position is less than 0 or greater than the number of channels, or if |
| 1526 | + the permission overwrite information is not in proper form. |
| 1527 | + Forbidden |
| 1528 | + You do not have permissions to edit the channel. |
| 1529 | + HTTPException |
| 1530 | + Editing the channel failed. |
| 1531 | + """ |
| 1532 | + |
| 1533 | + if "require_tag" in options or "hide_media_download_options" in options: |
| 1534 | + flags = ChannelFlags._from_value(self.flags.value) |
| 1535 | + flags.require_tag = options.pop("require_tag", flags.require_tag) |
| 1536 | + flags.hide_media_download_options = options.pop( |
| 1537 | + "hide_media_download_options", flags.hide_media_download_options |
| 1538 | + ) |
| 1539 | + options["flags"] = flags |
| 1540 | + |
| 1541 | + payload = await self._edit(options, reason=reason) |
| 1542 | + if payload is not None: |
| 1543 | + # the payload will always be the proper channel payload |
| 1544 | + return self.__class__(state=self._state, guild=self.guild, data=payload) # type: ignore |
| 1545 | + |
| 1546 | + |
1354 | 1547 | class VocalGuildChannel(discord.abc.Connectable, discord.abc.GuildChannel, Hashable):
|
1355 | 1548 | __slots__ = (
|
1356 | 1549 | "name",
|
@@ -3232,8 +3425,12 @@ def _guild_channel_factory(channel_type: int):
|
3232 | 3425 | return TextChannel, value
|
3233 | 3426 | elif value is ChannelType.stage_voice:
|
3234 | 3427 | return StageChannel, value
|
| 3428 | + elif value is ChannelType.directory: |
| 3429 | + return None, value # todo: Add DirectoryChannel when applicable |
3235 | 3430 | elif value is ChannelType.forum:
|
3236 | 3431 | return ForumChannel, value
|
| 3432 | + elif value is ChannelType.media: |
| 3433 | + return MediaChannel, value |
3237 | 3434 | else:
|
3238 | 3435 | return None, value
|
3239 | 3436 |
|
|
0 commit comments